Skip to content

Commit fd1bb20

Browse files
committed
[Property wrappers] Don't infer "final" for the projected property.
Fixes crash reported as rdar://problem/55982409.
1 parent 1d7d58a commit fd1bb20

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ IsFinalRequest::evaluate(Evaluator &evaluator, ValueDecl *decl) const {
11641164

11651165
// Backing storage for 'lazy' or property wrappers is always final.
11661166
if (VD->isLazyStorageProperty() ||
1167-
VD->getOriginalWrappedProperty())
1167+
VD->getOriginalWrappedProperty(PropertyWrapperSynthesizedPropertyKind::Backing))
11681168
return true;
11691169

11701170
if (auto *nominalDecl = VD->getDeclContext()->getSelfClassDecl()) {

test/SILGen/property_wrappers.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,18 @@ struct ComposedInit {
495495
}
496496
}
497497

498+
// rdar://problem/55982409 - crash due to improperly inferred 'final'
499+
@propertyWrapper
500+
public struct MyWrapper<T> {
501+
public var wrappedValue: T
502+
public var projectedValue: Self { self }
503+
public init(wrappedValue: T) { self.wrappedValue = wrappedValue }
504+
}
505+
506+
open class TestMyWrapper {
507+
public init() {}
508+
@MyWrapper open var useMyWrapper: Int? = nil
509+
}
498510

499511
// CHECK-LABEL: sil_vtable ClassUsingWrapper {
500512
// CHECK-NEXT: #ClassUsingWrapper.x!getter.1: (ClassUsingWrapper) -> () -> Int : @$s17property_wrappers17ClassUsingWrapperC1xSivg // ClassUsingWrapper.x.getter
@@ -503,3 +515,6 @@ struct ComposedInit {
503515
// CHECK-NEXT: #ClassUsingWrapper.init!allocator.1: (ClassUsingWrapper.Type) -> () -> ClassUsingWrapper : @$s17property_wrappers17ClassUsingWrapperCACycfC
504516
// CHECK-NEXT: #ClassUsingWrapper.deinit!deallocator.1: @$s17property_wrappers17ClassUsingWrapperCfD
505517
// CHECK-NEXT: }
518+
519+
// CHECK-LABEL: sil_vtable [serialized] TestMyWrapper
520+
// CHECK: #TestMyWrapper.$useMyWrapper!getter.1

0 commit comments

Comments
 (0)