mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This reverts commit ce7b2bcf09, tweaking
a few validation tests appropriately (1 crasher fixed, two -verify
tests that needed updating).
69 lines
2.7 KiB
Swift
69 lines
2.7 KiB
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
class HasFunc {
|
|
func HasFunc(_: HasFunc) { // expected-error {{use of undeclared type 'HasFunc'}}
|
|
}
|
|
func HasFunc() -> HasFunc { // expected-error {{use of undeclared type 'HasFunc'}}
|
|
return HasFunc()
|
|
}
|
|
func SomethingElse(_: SomethingElse) { // expected-error {{use of undeclared type 'SomethingElse'}}
|
|
return nil
|
|
}
|
|
func SomethingElse() -> SomethingElse? { // expected-error {{use of undeclared type 'SomethingElse'}}
|
|
return nil
|
|
}
|
|
}
|
|
|
|
class HasGenericFunc {
|
|
func HasGenericFunc<HasGenericFunc : HasGenericFunc>(x: HasGenericFunc) -> HasGenericFunc { // expected-error {{inheritance from non-protocol, non-class type 'HasGenericFunc'}}
|
|
return x
|
|
}
|
|
func SomethingElse<SomethingElse : SomethingElse>(_: SomethingElse) -> SomethingElse? { // expected-error {{inheritance from non-protocol, non-class type 'SomethingElse'}}
|
|
return nil
|
|
}
|
|
}
|
|
|
|
class HasProp {
|
|
var HasProp: HasProp { // expected-error {{'HasProp' used within its own type}} expected-error 2 {{use of undeclared type 'HasProp'}}
|
|
return HasProp()
|
|
}
|
|
var SomethingElse: SomethingElse? { // expected-error {{'SomethingElse' used within its own type}} expected-error 2 {{use of undeclared type 'SomethingElse'}}
|
|
return nil
|
|
}
|
|
}
|
|
|
|
protocol SomeProtocol {}
|
|
protocol ReferenceSomeProtocol {
|
|
var SomeProtocol: SomeProtocol { get } // expected-error {{'SomeProtocol' used within its own type}} expected-error 2 {{use of undeclared type 'SomeProtocol'}}
|
|
}
|
|
|
|
func TopLevelFunc(x: TopLevelFunc) -> TopLevelFunc { return x } // expected-error {{use of undeclared type 'TopLevelFunc'}}'
|
|
func TopLevelGenericFunc<TopLevelGenericFunc : TopLevelGenericFunc>(x: TopLevelGenericFunc) -> TopLevelGenericFunc { return x } // expected-error {{inheritance from non-protocol, non-class type 'TopLevelGenericFunc'}}
|
|
func TopLevelGenericFunc2<T : TopLevelGenericFunc2>(x: T) -> T { return x} // expected-error {{use of undeclared type 'TopLevelGenericFunc2'}}
|
|
var TopLevelVar: TopLevelVar? { return nil } // expected-error 2 {{use of undeclared type 'TopLevelVar'}}
|
|
|
|
|
|
protocol AProtocol {
|
|
associatedtype e : e // expected-error {{inheritance from non-protocol, non-class type 'Self.e'}}
|
|
}
|
|
|
|
|
|
|
|
// <rdar://problem/15604574> Protocol conformance checking needs to be delayed
|
|
protocol P15604574 {
|
|
associatedtype FooResult
|
|
func foo() -> FooResult
|
|
}
|
|
|
|
class AcceptsP<T : P15604574> { }
|
|
|
|
class X {
|
|
func foo() -> AcceptsP<X> { } // expected-error {{type 'X' does not conform to protocol 'P15604574'}}
|
|
}
|
|
|
|
// <rdar://problem/17144076> recursive typealias causes a segfault in the type checker
|
|
struct SomeStruct<A> {
|
|
typealias A = A // expected-error {{type alias 'A' circularly references itself}}
|
|
}
|
|
|