Skip to content

Commit e249fe8

Browse files
committed
[Namelookup] Wallk into GenericIdentTypeRepr
1 parent 286772a commit e249fe8

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

lib/AST/NameLookup.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2797,7 +2797,6 @@ bool TypeRepr::isProtocol(DeclContext *dc){
27972797
auto &ctx = dc->getASTContext();
27982798
return findIf([&ctx, dc](TypeRepr *ty) {
27992799
return declsAreProtocols(directReferencesForTypeRepr(ctx.evaluator, ctx, ty, dc));
2800-
28012800
});
28022801
}
28032802

@@ -2851,6 +2850,8 @@ CollectedOpaqueReprs swift::collectOpaqueReturnTypeReprs(TypeRepr *r, ASTContext
28512850
if (!compositionRepr->isTypeReprAny())
28522851
Reprs.push_back(compositionRepr);
28532852
return Action::SkipChildren();
2853+
} else if (auto generic = dyn_cast<GenericIdentTypeRepr>(repr)) {
2854+
return Action::Continue();
28542855
} else if (auto declRefTR = dyn_cast<DeclRefTypeRepr>(repr)) {
28552856
if (declRefTR->isProtocol(dc))
28562857
Reprs.push_back(declRefTR);

test/type/opaque_parameterized_existential.swift

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,31 @@ protocol P<T> {
99
associatedtype T
1010
}
1111

12-
extension Never: P { typealias T = Never }
12+
struct S: P {
13+
typealias T = Self
14+
}
1315

1416
// I do not like them written clear
15-
func test() -> any P<some P> { fatalError() } // expected-error {{'some' types cannot be used in constraints on existential types}}
16-
17-
// I do not like them nested here
18-
func test() -> any P<[some P]> { fatalError() } // expected-error {{'some' types cannot be used in constraints on existential types}}
17+
func test() -> any P<some P> { S() } // expected-error {{'some' types cannot be used in constraints on existential types}}
1918

2019
// I do not like them under questions
21-
func test() -> any P<(some P)??> { fatalError() } // expected-error {{'some' types cannot be used in constraints on existential types}}
20+
func test() -> any P<(some P)??> { S() } // expected-error {{'some' types cannot be used in constraints on existential types}}
2221

2322
// I do not like meta-type intentions
24-
func test() -> (any P<some P>).Type { fatalError() } // expected-error {{'some' types cannot be used in constraints on existential types}}
23+
func test() -> (any P<some P>).Type { S() } // expected-error {{'some' types cannot be used in constraints on existential types}}
2524

2625
// I do not like them (meta)static-ly
27-
func test() -> any P<some P>.Type { fatalError() } // expected-error {{'some' types cannot be used in constraints on existential types}}
26+
func test() -> any P<some P>.Type { S() } // expected-error {{'some' types cannot be used in constraints on existential types}}
2827

2928
// I do not like them tupled-three
30-
func test() -> (Int, any P<some P>, Int) { fatalError() } // expected-error {{'some' types cannot be used in constraints on existential types}}
29+
func test() -> (Int, any P<some P>, Int) { S() } // expected-error {{'some' types cannot be used in constraints on existential types}}
3130

3231
// I do not like them in generics
3332
struct Wrapper<T> {}
34-
func test() -> any P<Wrapper<some P>> { fatalError() } // expected-error {{'some' types cannot be used in constraints on existential types}}
33+
func test() -> any P<Wrapper<some P>> { S() } // expected-error {{'some' types cannot be used in constraints on existential types}}
3534

3635
// Your attempts to nest them put me in hysterics.
37-
func test(_ x: any P<some P>) {} // expected-error {{'some' types cannot be used in constraints on existential types}}
36+
func test(_ x: any P<some P>) { } // expected-error {{'some' types cannot be used in constraints on existential types}}
3837

3938
// No, I do not like nested some type params,
4039
// I do not like them Σam-i-am

0 commit comments

Comments
 (0)