mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
It’s real intent is to check only the generic signature of the DeclContext provided to name lookup, then enclosing contexts. Use it for functions and initializers as well, so we have uniform lookup behavior for entities that can have generic parameters. A follow-up commit contains some minor, semi-related tweaks along with a pile of updates to the compiler crash testsuite. Swift SVN r26654
44 lines
1.9 KiB
Swift
44 lines
1.9 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 2 {{use of undeclared type 'HasProp'}}
|
|
return HasProp()
|
|
}
|
|
var SomethingElse: SomethingElse? { // expected-error 2 {{use of undeclared type 'SomethingElse'}}
|
|
return nil
|
|
}
|
|
}
|
|
|
|
protocol SomeProtocol {}
|
|
protocol ReferenceSomeProtocol {
|
|
var SomeProtocol: SomeProtocol { get } // 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'}}
|