Skip to content

Commit 177d989

Browse files
committed
SILGen: Don't emit property descriptors for ~Escapable types.
Key paths can't reference them, so we don't need to refer to them resiliently. Fixes rdar://151628396.
1 parent 21c1790 commit 177d989

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

lib/SIL/IR/SIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ static bool isUnsupportedKeyPathValueType(Type ty) {
344344
// They would also need a new ABI that's yet to be implemented in order to
345345
// be properly supported, so let's suppress the descriptor for now if either
346346
// the container or storage type of the declaration is non-copyable.
347-
if (ty->isNoncopyable())
347+
if (ty->isNoncopyable() || !ty->isEscapable())
348348
return true;
349349

350350
return false;
@@ -356,7 +356,7 @@ bool AbstractStorageDecl::exportsPropertyDescriptor() const {
356356

357357
if (!isStatic()) {
358358
if (auto contextTy = getDeclContext()->getDeclaredTypeInContext()) {
359-
if (contextTy->isNoncopyable()) {
359+
if (contextTy->isNoncopyable() || !contextTy->isEscapable()) {
360360
return false;
361361
}
362362
}

test/SILOptimizer/lifetime_dependence/verify_library_diagnostics.swift

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,8 @@ public struct NEImmortal: ~Escapable {
2929

3030
class C {}
3131

32-
// Test diagnostics on keypath getter.
33-
//
34-
// rdar://150073405 ([SILGen] support synthesized _modify on top of borrowed getters with library evolution)
35-
//
36-
// This produces the error:
37-
// <unknown>:0: error: unexpected error produced: lifetime-dependent value returned by generated thunk
38-
// '$s4test17ImplicitAccessorsV10neComputedAA10NEImmortalVvpACTK'
39-
//
40-
// Since this error has no source file, we can't verify the diagnostic!
41-
/*
32+
// Test that we don't implicitly try to create a keypath getter, since
33+
// ~Escapable types are not yet supported by keypaths.
4234
public struct ImplicitAccessors {
4335
let c: C
4436

@@ -50,7 +42,6 @@ public struct ImplicitAccessors {
5042
}
5143
}
5244
}
53-
*/
5445

5546
public struct NoncopyableImplicitAccessors : ~Copyable & ~Escapable {
5647
public var ne: NE

0 commit comments

Comments
 (0)