Skip to content

Commit 9aab864

Browse files
committed
[SILGen] conformsToInvertible of no-implicit-copy
The "no implicit copy" parameters such as a `consuming` or `borrowing` parameter of an otherwise Copyable type was not being handled correctly by `conformsToInvertible`. We don't have conformances for SIL types in the AST, so they're supposed to be handled earlier. fixes rdar://120462547
1 parent e041226 commit 9aab864

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/AST/Type.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ static bool alwaysNoncopyable(Type ty) {
180180
static CanType preprocessType(GenericEnvironment *env, Type orig) {
181181
Type type = orig;
182182

183+
// Always strip off SILMoveOnlyWrapper.
184+
if (auto wrapper = type->getAs<SILMoveOnlyWrappedType>())
185+
type = wrapper->getInnerType();
186+
183187
// Turn any type parameters into archetypes.
184188
if (env)
185189
if (!type->hasArchetype() || type->hasOpenedExistential())

test/SILGen/moveonly_basics.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-swift-emit-silgen -module-name test %s | %FileCheck %s --enable-var-scope
2+
// RUN: %target-swift-emit-silgen -enable-experimental-feature NoncopyableGenerics -module-name test %s | %FileCheck %s --enable-var-scope
23

34
class Retainable {}
45

@@ -27,3 +28,11 @@ func testHasStatic_1() {
2728
func testHasStatic_2() {
2829
_ = HasStatic.b.y
2930
}
31+
32+
33+
struct NormalType {}
34+
func expectWrapper(_ a : consuming NormalType) {}
35+
36+
// CHECK-LABEL: sil hidden [ossa] @$s4test13expectWrapperyyAA10NormalTypeVnF : $@convention(thin) (NormalType) -> () {
37+
// CHECK: bb0({{.*}} : @noImplicitCopy @_eagerMove $NormalType):
38+
// CHECK: alloc_box ${ var @moveOnly NormalType }, var

0 commit comments

Comments
 (0)