Skip to content

Property wrapper backing initializers are not dynamically replaceable #28590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/SIL/SILDeclRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,8 @@ bool SILDeclRef::canBeDynamicReplacement() const {
bool SILDeclRef::isDynamicallyReplaceable() const {
if (kind == SILDeclRef::Kind::DefaultArgGenerator)
return false;
if (isStoredPropertyInitializer())
if (isStoredPropertyInitializer() ||
kind == SILDeclRef::Kind::PropertyWrapperBackingInitializer)
return false;

// Class allocators are not dynamic replaceable.
Expand Down
14 changes: 14 additions & 0 deletions test/SILGen/dynamically_replaceable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -404,3 +404,17 @@ public func testWithLocalFun() {
let unamedClosure = { print("foo") }
unamedClosure()
}

@propertyWrapper
struct WrapperWithInitialValue<T> {
var wrappedValue: T

init(wrappedValue initialValue: T) {
self.wrappedValue = initialValue
}
}

// CHECK-LABEL: sil hidden [ossa] @$s23dynamically_replaceable10SomeStructV1tSbvpfP
public struct SomeStruct {
@WrapperWithInitialValue var t = false
}