forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinvalid_constraint_lookup.swift
32 lines (28 loc) · 1.11 KB
/
invalid_constraint_lookup.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// RUN: %target-parse-verify-swift
protocol P {
typealias A
func generate() -> Int
}
func f<U: P>(rhs: U) -> X<U.A> { // expected-error {{use of undeclared type 'X'}}
// FIXME: This diagnostic isn't great, it happens because the generic constraint
// 'U' from the invalid type signature never gets resolved.
let g = rhs.generate() // expected-error {{type of expression is ambiguous without more context}}
}
struct Zzz<T> {
subscript (a: Foo) -> Zzz<T> { // expected-error 2 {{use of undeclared type 'Foo'}}
get: // expected-error {{expected '{' to start getter definition}}
set:
for i in value {}
}
}
protocol _CollectionType {
typealias Index
typealias _Element
subscript(i: Index) -> _Element {get}
}
protocol CollectionType : _CollectionType, SequenceType {
subscript(i: Index) -> Generator.Element {get set }
}
func insertionSort<C: Mutable> (inout elements: C, i: C.Index) { // expected-error {{use of undeclared type 'Mutable'}} expected-error {{'Index' is not a member type of 'C'}}
var x: C.Generator.Element = elements[i] // expected-error {{'Generator' is not a member type of 'C'}}
}