Skip to content

Commit b6b67c4

Browse files
authored
Merge pull request #29585 from akyrtzi/fix-missing-reference
[Sema/CSApply] Make sure that the member type references created for a `type(of: x).A` expression are visible to the `SourceEntityWalker`
2 parents b273ba2 + 6052288 commit b6b67c4

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/Sema/CSApply.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -845,11 +845,9 @@ namespace {
845845

846846
// If we're referring to a member type, it's just a type
847847
// reference.
848-
if (isa<TypeDecl>(member)) {
848+
if (auto *TD = dyn_cast<TypeDecl>(member)) {
849849
Type refType = simplifyType(openedType);
850-
auto ref =
851-
TypeExpr::createImplicitHack(memberLoc.getBaseNameLoc(),
852-
refType, context);
850+
auto ref = TypeExpr::createForDecl(memberLoc, TD, cs.DC, /*isImplicit=*/false);
853851
cs.setType(ref, refType);
854852
auto *result = new (context) DotSyntaxBaseIgnoredExpr(
855853
base, dotLoc, ref, refType);

test/Index/expressions.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,16 @@ func test1() { // CHECK: [[@LINE]]:6 | function/Swift | test1() | [[test1_USR:.*
4545
}
4646
}
4747
}
48+
49+
protocol AP {
50+
// CHECK: [[@LINE+1]]:18 | type-alias/associated-type/Swift | A | [[AP_P_USR:.*]] | Def,RelChild | rel: 1
51+
associatedtype A
52+
}
53+
// CHECK: [[@LINE+1]]:19 | param/Swift | x | [[TEST2_X_USR:.*]] | Def,RelChild | rel: 1
54+
func test2<X: AP>(x: X) {
55+
// CHECK: [[@LINE+1]]:9 | type-alias/associated-type/Swift | A | [[AP_P_USR]] | Ref,RelCont | rel: 1
56+
_ = X.A.self
57+
// CHECK: [[@LINE+2]]:16 | param/Swift | x | [[TEST2_X_USR]] | Ref,Read,RelCont | rel: 1
58+
// CHECK: [[@LINE+1]]:19 | type-alias/associated-type/Swift | A | [[AP_P_USR]] | Ref,RelCont | rel: 1
59+
_ = type(of: x).A.self
60+
}

0 commit comments

Comments
 (0)