File tree Expand file tree Collapse file tree 2 files changed +43
-4
lines changed
validation-test/compiler_crashers_2_fixed Expand file tree Collapse file tree 2 files changed +43
-4
lines changed Original file line number Diff line number Diff line change @@ -6127,13 +6127,25 @@ Expr *swift::findOriginalPropertyWrapperInitialValue(VarDecl *var,
6127
6127
if (!call->isImplicit ())
6128
6128
return { true , E };
6129
6129
6130
- // ... producing a value of the same nominal type as the innermost
6131
- // property wrapper.
6130
+ // ... which may call the constructor of another property
6131
+ // wrapper if there are multiple wrappers attached to the
6132
+ // property.
6133
+ if (auto tuple = dyn_cast<TupleExpr>(call->getArg ())) {
6134
+ if (tuple->getNumElements () > 0 ) {
6135
+ auto elem = tuple->getElement (0 );
6136
+ if (elem->isImplicit () && isa<CallExpr>(elem)) {
6137
+ return { true , E };
6138
+ }
6139
+ }
6140
+ }
6141
+
6142
+ // ... producing a value of the same nominal type as the
6143
+ // innermost property wrapper.
6132
6144
if (!call->getType () ||
6133
6145
call->getType ()->getAnyNominal () != innermostNominal)
6134
- return { true , E };
6146
+ return { false , E };
6135
6147
6136
- // Find the implicit initialValue argument.
6148
+ // Find the implicit initialValue/wrappedValue argument.
6137
6149
if (auto tuple = dyn_cast<TupleExpr>(call->getArg ())) {
6138
6150
ASTContext &ctx = innermostNominal->getASTContext ();
6139
6151
for (unsigned i : range (tuple->getNumElements ())) {
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -emit-sil %s
2
+
3
+ @propertyWrapper
4
+ struct Foo < T> {
5
+ init ( wrappedValue: T ) {
6
+ self . wrappedValue = wrappedValue
7
+ }
8
+
9
+ var wrappedValue : T
10
+ }
11
+
12
+ @propertyWrapper
13
+ struct Bar < T> {
14
+ init ( wrappedValue: T ) {
15
+ self . wrappedValue = wrappedValue
16
+ }
17
+
18
+ var wrappedValue : T
19
+ }
20
+
21
+ struct Container {
22
+ @Foo @Foo var x : Int = 0
23
+ @Foo @Foo @Bar @Bar var y : Int = 1
24
+ @Foo @Bar @Foo @Foo var z : Int = 2
25
+ }
26
+
27
+ _ = Container ( )
You can’t perform that action at this time.
0 commit comments