Skip to content

Commit 05c6934

Browse files
committed
Sema: Name lookup of protocol typealiases from expression context
Fixes <rdar://problem/34911524>.
1 parent 1f84641 commit 05c6934

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

lib/Sema/TypeCheckNameLookup.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ namespace {
121121
if (!Options.contains(NameLookupFlags::ProtocolMembers) ||
122122
!isa<ProtocolDecl>(foundDC) ||
123123
isa<GenericTypeParamDecl>(found) ||
124+
isa<TypeAliasDecl>(found) ||
124125
(isa<FuncDecl>(found) && cast<FuncDecl>(found)->isOperator())) {
125126
addResult(found);
126127
return;

test/decl/typealias/generic.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,10 @@ class AnotherGeneric<T> {}
338338

339339
protocol P {
340340
associatedtype A
341-
typealias G1<T> = MyType<Self, T> // expected-note {{did you mean 'G1'?}}
342-
typealias G2<T> = MyType<T, A> // expected-note {{did you mean 'G2'?}}
343-
typealias G3<T> = () -> () // expected-note {{did you mean 'G3'?}}
344-
typealias G4<T> = (T) -> () // expected-note {{did you mean 'G4'?}}
341+
typealias G1<T> = MyType<Self, T>
342+
typealias G2<T> = MyType<T, A>
343+
typealias G3<T> = () -> ()
344+
typealias G4<T> = (T) -> ()
345345

346346
func firstRequirement(_: G1<Int>)
347347
func secondRequirement(_: G2<Int>)
@@ -368,19 +368,19 @@ struct S : P {
368368
func fourthRequirement(_: G4<Int>) {}
369369

370370
func firstRequirementGeneric<T>(_: G1<T>) {
371-
_ = G1<T>.self // FIXME // expected-error {{use of unresolved identifier 'G1'}}
371+
_ = G1<T>.self
372372
}
373373

374374
func secondRequirementGeneric<T>(_: G2<T>) {
375-
_ = G2<T>.self // FIXME // expected-error {{use of unresolved identifier 'G2'}}
375+
_ = G2<T>.self
376376
}
377377

378378
func thirdRequirementGeneric<T>(_: G3<T>, _: T) {
379-
_ = G3<T>.self // FIXME // expected-error {{use of unresolved identifier 'G3'}}
379+
_ = G3<T>.self
380380
}
381381

382382
func fourthRequirementGeneric<T>(_: G4<T>) {
383-
_ = G4<T>.self // FIXME // expected-error {{use of unresolved identifier 'G4'}}
383+
_ = G4<T>.self
384384
}
385385

386386
func expressionContext() {

test/decl/typealias/protocol.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ struct T5 : P5 {
190190
// Unqualified lookup finds typealiases in protocol extensions
191191
protocol P7 {
192192
associatedtype A
193+
typealias Z = A
193194
}
194195

195196
extension P7 {
@@ -203,6 +204,7 @@ struct S7 : P7 {
203204

204205
func inExpressionContext() {
205206
_ = Y.self
207+
_ = Z.self
206208
_ = T5.T1.self
207209
_ = T5.T2.self
208210
}

0 commit comments

Comments
 (0)