Skip to content

Commit b6e6ace

Browse files
committed
Property wrapper backing initializers are not dynamically replaceable
1 parent 86a76cb commit b6e6ace

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/SIL/SILDeclRef.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,8 @@ bool SILDeclRef::canBeDynamicReplacement() const {
10651065
bool SILDeclRef::isDynamicallyReplaceable() const {
10661066
if (kind == SILDeclRef::Kind::DefaultArgGenerator)
10671067
return false;
1068-
if (isStoredPropertyInitializer())
1068+
if (isStoredPropertyInitializer() ||
1069+
kind == SILDeclRef::Kind::PropertyWrapperBackingInitializer)
10691070
return false;
10701071

10711072
// Class allocators are not dynamic replaceable.

test/SILGen/dynamically_replaceable.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,3 +404,17 @@ public func testWithLocalFun() {
404404
let unamedClosure = { print("foo") }
405405
unamedClosure()
406406
}
407+
408+
@propertyWrapper
409+
struct WrapperWithInitialValue<T> {
410+
var wrappedValue: T
411+
412+
init(wrappedValue initialValue: T) {
413+
self.wrappedValue = initialValue
414+
}
415+
}
416+
417+
// CHECK-LABEL: sil hidden [ossa] @$s23dynamically_replaceable10SomeStructV1tSbvpfP
418+
public struct SomeStruct {
419+
@WrapperWithInitialValue var t = false
420+
}

0 commit comments

Comments
 (0)