Files
swift-mirror/test/decl/class/circular_inheritance_2.swift
Doug Gregor 1ee6d8139a [Constraint solver] Cope with circular inheritance.
This loop in the constraint solver won't terminate when given
ill-formed code involving circular inheritance. Make it
terminate. Fixes rdar://problem/54296278.
2019-08-27 10:29:36 -07:00

9 lines
311 B
Swift

// RUN: %target-typecheck-verify-swift
// rdar://problem/54296278 - infinite loop
class Foo {}
class Bar: Bar {} // expected-error{{'Bar' inherits from itself}}
func foo(_ o: AnyObject) -> Foo? {
return o as? Bar // expected-error{{cannot convert return expression of type 'Bar?' to return type 'Foo?'}}
}