Skip to content

Commit 3fe15fe

Browse files
committed
Sema: Fix PlaygroundTransform for noncopyable generics
1 parent d3aa3a8 commit 3fe15fe

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

lib/Sema/PlaygroundTransform.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,11 +799,15 @@ class Instrumenter : InstrumenterBase {
799799

800800
bool shouldLog(ASTNode node) {
801801
// Don't try to log ~Copyable types, as we can't pass them to the generic logging functions yet.
802-
if (auto *VD = dyn_cast_or_null<ValueDecl>(node.dyn_cast<Decl *>()))
803-
return VD->hasInterfaceType() ? !VD->getInterfaceType()->isNoncopyable() : true;
804-
if (auto *E = node.dyn_cast<Expr *>())
802+
if (auto *VD = dyn_cast_or_null<ValueDecl>(node.dyn_cast<Decl *>())) {
803+
auto interfaceTy = VD->getInterfaceType();
804+
auto contextualTy = VD->getInnermostDeclContext()->mapTypeIntoContext(interfaceTy);
805+
return !contextualTy->isNoncopyable();
806+
} else if (auto *E = node.dyn_cast<Expr *>()) {
805807
return !E->getType()->isNoncopyable();
806-
return true;
808+
} else {
809+
return true;
810+
}
807811
}
808812

809813
Added<Stmt *> buildLoggerCall(Added<Expr *> E, SourceRange SR,

test/PlaygroundTransform/generics.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// RUN: %target-run %t/main2 | %FileCheck %s
1010
// REQUIRES: executable_test
1111

12-
// XFAIL: noncopyable_generics
13-
1412
import PlaygroundSupport
1513

1614
func id<T>(_ t: T) -> T {

test/PlaygroundTransform/implicit_return_func_binaryoperation_args.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// RUN: %target-run %t/main2 | %FileCheck %s
1010
// REQUIRES: executable_test
1111

12-
// XFAIL: noncopyable_generics
13-
1412
import PlaygroundSupport
1513

1614
func add<I : SignedNumeric>(_ lhs: I, _ rhs: I) -> I {

test/PlaygroundTransform/implicit_return_func_is.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// RUN: %target-run %t/main2 | %FileCheck %s
1010
// REQUIRES: executable_test
1111

12-
// XFAIL: noncopyable_generics
13-
1412
import PlaygroundSupport
1513

1614
func iss<T>(_ instance: Any, anInstanceOf type: T.Type) -> Bool {

0 commit comments

Comments
 (0)