Skip to content

Commit 0af151f

Browse files
authored
Merge pull request #78071 from hamishknight/thats-canon-now
[SourceKit] Use canonical type in `printTypeUSR`
2 parents d462d72 + 30a8f19 commit 0af151f

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

lib/AST/USRGeneration.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ static inline StringRef getUSRSpacePrefix() {
3939

4040
bool ide::printTypeUSR(Type Ty, raw_ostream &OS) {
4141
assert(!Ty->hasArchetype() && "cannot have contextless archetypes mangled.");
42+
Ty = Ty->getCanonicalType()->getRValueType();
4243
Mangle::ASTMangler Mangler(Ty->getASTContext());
43-
OS << Mangler.mangleTypeAsUSR(Ty->getRValueType());
44+
OS << Mangler.mangleTypeAsUSR(Ty);
4445
return false;
4546
}
4647

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@resultBuilder struct Builder {
2+
static func buildBlock<T>(_ x: T) -> T { x }
3+
}
4+
5+
struct S {}
6+
7+
struct R<T> {
8+
init(@Builder fn: () -> T) {}
9+
}
10+
11+
// rdar://141168628 - Make sure we can compute the USR here without crashing.
12+
R {
13+
S()
14+
// RUN: %sourcekitd-test -req=conformingmethods -pos %(line + 1):2 %s -- %s | %FileCheck %s
15+
}
16+
// CHECK: key.typeusr: "$s13rdar1411686281RVyAA1SVGD"

test/SourceKit/CursorInfo/cursor_info_container.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ func SArrayGen() -> [S] { return [] }
6565
// CHECK6: <Container>$s21cursor_info_container1EOmD</Container>
6666

6767
// RUN: %sourcekitd-test -req=cursor -pos=37:22 %s -- %s | %FileCheck -check-prefix=CHECK7 %s
68-
// CHECK7: <Container>$s21cursor_info_container1SVXSaD</Container>
68+
// CHECK7: <Container>$sSay21cursor_info_container1SVGD</Container>

0 commit comments

Comments
 (0)