Files
swift-mirror/test/decl/class/circular_inheritance.swift
Slava Pestov 7b6736df29 Sema: When validating a nested type, only validate the parent, do not type check it
There's no need to walk the siblings of the nested type. This fixes
a class of infinite recursion issues when inheriting from nested
types.
2016-06-18 17:05:27 -07:00

29 lines
876 B
Swift

// RUN: %target-parse-verify-swift
class C : B { } // expected-error{{circular class inheritance 'C' -> 'B' -> 'A' -> 'C'}}
class B : A { } // expected-note{{class 'B' declared here}}
class A : C { } // expected-note{{class 'A' declared here}}
class TrivialCycle : TrivialCycle {} // expected-error{{circular class inheritance TrivialCycle}}
protocol P : P {} // expected-error{{circular protocol inheritance P}}
class Isomorphism : Automorphism { }
class Automorphism : Automorphism { } // expected-error{{circular class inheritance Automorphism}}
let _ = A()
// This should probably be made to work, but for now test that it produces a crappy
// diagnostic instead of crashing
class Left : Right.Hand {
class Hand {}
}
class Right : Left.Hand { // expected-error {{'Hand' is not a member type of 'Left'}}
class Hand {}
}
class Outer {
class Inner : Outer {}
}