Skip to content

Commit 5d8bfb0

Browse files
authored
Re-apply "Playground Transform: Fix assertion failure in generic code" (#6747)
This regression was introduced in the following commit: <6cbb494> Fixes <rdar://problem/29935266>.
1 parent 3157d9e commit 5d8bfb0

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

lib/Sema/PlaygroundTransform.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,7 @@ class Instrumenter : InstrumenterBase {
742742
/*IsCaptureList*/false, SourceLoc(),
743743
Context.getIdentifier(NameBuf),
744744
MaybeLoadInitExpr->getType(), TypeCheckDC);
745-
746-
VD->setInterfaceType(VD->getType());
745+
VD->setInterfaceType(TypeCheckDC->mapTypeOutOfContext(VD->getType()));
747746
VD->setImplicit();
748747

749748
NamedPattern *NP = new (Context) NamedPattern(VD, /*implicit*/ true);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: cp %s %t/main.swift
4+
// RUN: %target-build-swift -Xfrontend -playground -Xfrontend -debugger-support -o %t/main %S/Inputs/PlaygroundsRuntime.swift %t/main.swift
5+
// RUN: %target-run %t/main | %FileCheck %s
6+
// RUN: %target-build-swift -Xfrontend -pc-macro -Xfrontend -playground -Xfrontend -debugger-support -o %t/main %S/Inputs/PlaygroundsRuntime.swift %S/Inputs/SilentPCMacroRuntime.swift %t/main.swift
7+
// RUN: %target-run %t/main | %FileCheck %s
8+
// REQUIRES: executable_test
9+
10+
func id<T>(_ t: T) -> T {
11+
return t
12+
}
13+
14+
for i in 0..<3 {
15+
_ = id(i)
16+
}
17+
18+
// CHECK: $builtin_log_scope_entry
19+
// CHECK-NEXT: $builtin_log_scope_entry
20+
// CHECK-NEXT: $builtin_log[='0']
21+
// CHECK-NEXT: $builtin_log_scope_exit
22+
// CHECK-NEXT: $builtin_log[='0']
23+
// CHECK-NEXT: $builtin_log_scope_exit
24+
// CHECK-NEXT: $builtin_log_scope_entry
25+
// CHECK-NEXT: $builtin_log_scope_entry
26+
// CHECK-NEXT: $builtin_log[='1']
27+
// CHECK-NEXT: $builtin_log_scope_exit
28+
// CHECK-NEXT: $builtin_log[='1']
29+
// CHECK-NEXT: $builtin_log_scope_exit
30+
// CHECK-NEXT: $builtin_log_scope_entry
31+
// CHECK-NEXT: $builtin_log_scope_entry
32+
// CHECK-NEXT: $builtin_log[='2']
33+
// CHECK-NEXT: $builtin_log_scope_exit
34+
// CHECK-NEXT: $builtin_log[='2']
35+
// CHECK-NEXT: $builtin_log_scope_exit

0 commit comments

Comments
 (0)