Skip to content

Commit ddb64a4

Browse files
committed
[SE-0258] Remove incorrect assertion in SIL verifier for assign_by_wrapper.
The assertion was checking that the number of indirect result types matched up with the number of indirect input types, which is... not correct. The correct checks are later on, and the actual SIL itself is correct. Fixes rdar://problem/52467175.
1 parent 065d7a1 commit ddb64a4

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

lib/SIL/SILVerifier.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,13 +1967,9 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
19671967
"assign instruction can only exist in raw SIL");
19681968
require(Dest->getType().isAddress(), "Must store to an address dest");
19691969

1970-
unsigned indirectInitResults = Src->getType().isAddress() ? 1 : 0;
1971-
19721970
SILValue initFn = AI->getInitializer();
19731971
CanSILFunctionType initTy = initFn->getType().castTo<SILFunctionType>();
19741972
SILFunctionConventions initConv(initTy, AI->getModule());
1975-
require(initConv.getNumIndirectSILResults() == indirectInitResults,
1976-
"init function has wrong number of indirect results");
19771973
unsigned firstArgIdx = initConv.getSILArgIndexOfFirstParam();
19781974
require(initConv.getNumSILArguments() == firstArgIdx + 1,
19791975
"init function has wrong number of arguments");
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@propertyWrapper
2+
public struct MyPublished<Value> {
3+
private var stored: Value
4+
5+
public var wrappedValue: Value {
6+
get { stored }
7+
set { stored = newValue }
8+
}
9+
10+
public init(initialValue: Value) {
11+
stored = initialValue
12+
}
13+
14+
public var projectedValue: Self {
15+
mutating get { self }
16+
set { self = newValue }
17+
}
18+
}

test/SILGen/property_wrappers.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
// RUN: %target-swift-emit-silgen -primary-file %s | %FileCheck %s
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module -o %t -enable-library-evolution %S/Inputs/property_wrapper_defs.swift
3+
// RUN: %target-swift-emit-silgen -primary-file %s -I %t | %FileCheck %s
4+
import property_wrapper_defs
25

36
@propertyWrapper
47
struct Wrapper<T> {
@@ -407,6 +410,20 @@ struct WithTuples {
407410
}
408411
}
409412

413+
// Resilience with DI of wrapperValue assignments.
414+
// rdar://problem/52467175
415+
class TestResilientDI {
416+
@MyPublished var data: Int? = nil
417+
418+
// CHECK: assign_by_wrapper {{%.*}} : $Optional<Int> to {{%.*}} : $*MyPublished<Optional<Int>>, init {{%.*}} : $@callee_guaranteed (Optional<Int>) -> @out MyPublished<Optional<Int>>, set {{%.*}} : $@callee_guaranteed (Optional<Int>) -> ()
419+
420+
func doSomething() {
421+
self.data = Int()
422+
}
423+
}
424+
425+
426+
410427
// CHECK-LABEL: sil_vtable ClassUsingWrapper {
411428
// CHECK-NEXT: #ClassUsingWrapper.x!getter.1: (ClassUsingWrapper) -> () -> Int : @$s17property_wrappers17ClassUsingWrapperC1xSivg // ClassUsingWrapper.x.getter
412429
// CHECK-NEXT: #ClassUsingWrapper.x!setter.1: (ClassUsingWrapper) -> (Int) -> () : @$s17property_wrappers17ClassUsingWrapperC1xSivs // ClassUsingWrapper.x.setter

0 commit comments

Comments
 (0)