Skip to content

Commit b769f9f

Browse files
committed
[Sema] TypeWrappers: Adjust synthesized type wrapper init calls to pass the wrapped type
1 parent 5f2cd38 commit b769f9f

File tree

7 files changed

+125
-94
lines changed

7 files changed

+125
-94
lines changed

lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,11 @@ void LifetimeChecker::injectTypeWrapperStorageInitalization() {
12911291
loc, selfRef, parentType->getTypeWrapperProperty());
12921292
}
12931293

1294+
auto wrappedType = MetatypeType::get(self->getType().getASTType(),
1295+
MetatypeRepresentation::Thick);
1296+
auto wrappedMetatype =
1297+
b.createMetatype(loc, F.getLoweredType(wrappedType));
1298+
12941299
auto typeWrapperType =
12951300
b.createMetatype(loc, F.getLoweredType(MetatypeType::get(
12961301
storagePropRef->getType().getASTType())));
@@ -1305,14 +1310,17 @@ void LifetimeChecker::injectTypeWrapperStorageInitalization() {
13051310
wrapperInitArgs.push_back(*localWrapperObj);
13061311
}
13071312

1313+
wrapperInitArgs.push_back(wrappedMetatype);
13081314
wrapperInitArgs.push_back(storageObj);
13091315
wrapperInitArgs.push_back(typeWrapperType);
13101316

13111317
// <wrapper-var> = <TypeWrapper>.init(storage: tmpStorage)
13121318
auto wrapperInitResult = b.createApply(
13131319
loc, typeWrapperInitRef,
13141320
SubstitutionMap::get(typeWrapperInit->getGenericSignature(),
1315-
/*substitutions=*/{storageType.getASTType()},
1321+
/*substitutions=*/
1322+
{wrappedType->getMetatypeInstanceType(),
1323+
storageType.getASTType()},
13161324
/*conformances=*/{}),
13171325
wrapperInitArgs);
13181326

lib/Sema/TypeCheckTypeWrapper.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,12 @@ GetTypeWrapperProperty::evaluate(Evaluator &evaluator,
205205
->castTo<AnyGenericType>();
206206
assert(typeWrapperType);
207207

208-
// $storage: Wrapper<$Storage>
208+
// $storage: Wrapper<<ParentType>, <ParentType>.$Storage>
209209
auto propertyTy = BoundGenericType::get(
210210
typeWrapper, /*Parent=*/typeWrapperType->getParent(),
211-
/*genericArgs=*/{storage->getInterfaceType()->getMetatypeInstanceType()});
211+
/*genericArgs=*/
212+
{parent->getDeclaredInterfaceType(),
213+
storage->getDeclaredInterfaceType()});
212214

213215
return injectProperty(parent, ctx.Id_TypeWrapperProperty, propertyTy,
214216
VarDecl::Introducer::Var, AccessLevel::Internal);
@@ -478,10 +480,21 @@ BraceStmt *SynthesizeTypeWrappedTypeMemberwiseInitializerBody::evaluate(
478480
DeclNameRef::createConstructor(), /*implicit=*/true);
479481
{ initRef->setFunctionRefKind(FunctionRefKind::DoubleApply); }
480482

481-
// .init($Storage(...))
483+
auto *selfTypeRef = TypeExpr::createImplicitForDecl(
484+
DeclNameLoc(), parent, parent->getDeclContext(),
485+
ctor->mapTypeIntoContext(parent->getInterfaceType()));
486+
487+
auto *selfRef = new (ctx)
488+
DotSelfExpr(selfTypeRef, /*dot=*/SourceLoc(), /*self=*/SourceLoc());
489+
selfRef->setImplicit();
490+
491+
// .init($Storage(for:storage:))
482492
Expr *typeWrapperInit = CallExpr::createImplicit(
483493
ctx, initRef,
484-
ArgumentList::forImplicitSingle(ctx, ctx.Id_storage, storageInit));
494+
ArgumentList::createImplicit(
495+
ctx,
496+
{Argument(/*labelLoc=*/SourceLoc(), ctx.Id_for, selfRef),
497+
Argument(/*labelLoc=*/SourceLoc(), ctx.Id_storage, storageInit)}));
485498

486499
body.push_back(new (ctx) AssignExpr(storageVarRef, /*EqualLoc=*/SourceLoc(),
487500
typeWrapperInit,
@@ -532,8 +545,8 @@ GetTypeWrapperInitializer::evaluate(Evaluator &evaluator,
532545
auto &ctx = typeWrapper->getASTContext();
533546
assert(typeWrapper->getAttrs().hasAttribute<TypeWrapperAttr>());
534547

535-
auto ctors = typeWrapper->lookupDirect(
536-
DeclName(ctx, DeclBaseName::createConstructor(), {ctx.Id_storage}));
548+
auto ctors = typeWrapper->lookupDirect(DeclName(
549+
ctx, DeclBaseName::createConstructor(), {ctx.Id_for, ctx.Id_storage}));
537550

538551
if (ctors.size() != 1)
539552
return nullptr;

test/Interpreter/Inputs/type_wrapper_defs.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
@typeWrapper
2-
public struct Wrapper<S> {
2+
public struct Wrapper<W, S> {
33
var underlying: S
44

5-
public init(storage: S) {
6-
print("Wrapper.init(\(storage))")
5+
public init(for wrappedType: W.Type, storage: S) {
6+
print("Wrapper.init(for: \(wrappedType), storage: \(storage))")
77
self.underlying = storage
88
}
99

test/Interpreter/type_wrappers.swift

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import type_wrapper_defs
1616

1717
var p: Person<String> = .init(name: "P", projects: ["A", "B"])
18-
// CHECK: Wrapper.init($Storage(name: "P", projects: ["A", "B"]))
18+
// CHECK: Wrapper.init(for: Person<String>, storage: $Storage(name: "P", projects: ["A", "B"]))
1919

2020
print(p.name)
2121
// CHECK: in getter
@@ -48,7 +48,7 @@ print(p.projects)
4848
// CHECK-NEXT: ["A", "B", "C", "D"]
4949

5050
var pDefaults = PersonWithDefaults()
51-
// CHECK: Wrapper.init($Storage(name: "<no name>", age: 99))
51+
// CHECK: Wrapper.init(for: PersonWithDefaults, storage: $Storage(name: "<no name>", age: 99))
5252

5353
print(pDefaults.name)
5454
// CHECK: in getter
@@ -94,7 +94,7 @@ print(pDefaultsName.age)
9494

9595
func testPropertyWrappers() {
9696
var wrapped1 = PropWrapperTest(test: 42)
97-
// CHECK: Wrapper.init($Storage(_test: type_wrapper_defs.PropWrapper<Swift.Int>(value: 42)))
97+
// CHECK: Wrapper.init(for: PropWrapperTest, storage: $Storage(_test: type_wrapper_defs.PropWrapper<Swift.Int>(value: 42)))
9898
do {
9999
print(wrapped1.test)
100100
// CHECK: in getter
@@ -110,7 +110,7 @@ func testPropertyWrappers() {
110110
}
111111

112112
var wrapped2 = DefaultedPropWrapperTest()
113-
// CHECK: Wrapper.init($Storage(_test: type_wrapper_defs.PropWrapper<Swift.Int>(value: 0)))
113+
// CHECK: Wrapper.init(for: DefaultedPropWrapperTest, storage: $Storage(_test: type_wrapper_defs.PropWrapper<Swift.Int>(value: 0)))
114114
do {
115115
print(wrapped2.test)
116116
// CHECK: in getter
@@ -126,7 +126,7 @@ func testPropertyWrappers() {
126126
}
127127

128128
var wrapped3 = DefaultedPropWrapperTest(test: 1)
129-
// CHECK: Wrapper.init($Storage(_test: type_wrapper_defs.PropWrapper<Swift.Int>(value: 1)))
129+
// CHECK: Wrapper.init(for: DefaultedPropWrapperTest, storage: $Storage(_test: type_wrapper_defs.PropWrapper<Swift.Int>(value: 1)))
130130
do {
131131
print(wrapped3.test)
132132
// CHECK: in getter
@@ -142,7 +142,7 @@ func testPropertyWrappers() {
142142
}
143143

144144
var wrapped4 = DefaultedPropWrapperWithArgTest()
145-
// CHECK: Wrapper.init($Storage(_test: type_wrapper_defs.PropWrapper<Swift.Int>(value: 3)))
145+
// CHECK: Wrapper.init(for: DefaultedPropWrapperWithArgTest, storage: $Storage(_test: type_wrapper_defs.PropWrapper<Swift.Int>(value: 3)))
146146
do {
147147
print(wrapped4.test)
148148
// CHECK: in getter
@@ -158,7 +158,7 @@ func testPropertyWrappers() {
158158
}
159159

160160
var wrapped5 = PropWrapperNoInitTest(a: PropWrapperWithoutInit(value: 1))
161-
// CHECK: Wrapper.init($Storage(_a: type_wrapper_defs.PropWrapperWithoutInit<Swift.Int>(value: 1), _b: type_wrapper_defs.PropWrapperWithoutInit<Swift.String>(value: "b")))
161+
// CHECK: Wrapper.init(for: PropWrapperNoInitTest, storage: $Storage(_a: type_wrapper_defs.PropWrapperWithoutInit<Swift.Int>(value: 1), _b: type_wrapper_defs.PropWrapperWithoutInit<Swift.String>(value: "b")))
162162
do {
163163
print(wrapped5.a)
164164
// CHECK: in getter
@@ -186,7 +186,7 @@ func testPropertyWrappers() {
186186
}
187187

188188
var wrapped6 = PropWrapperNoInitTest(a: PropWrapperWithoutInit(value: 1), b: PropWrapperWithoutInit(value: "hello"))
189-
// CHECK: Wrapper.init($Storage(_a: type_wrapper_defs.PropWrapperWithoutInit<Swift.Int>(value: 1), _b: type_wrapper_defs.PropWrapperWithoutInit<Swift.String>(value: "hello")))
189+
// CHECK: Wrapper.init(for: PropWrapperNoInitTest, storage: $Storage(_a: type_wrapper_defs.PropWrapperWithoutInit<Swift.Int>(value: 1), _b: type_wrapper_defs.PropWrapperWithoutInit<Swift.String>(value: "hello")))
190190
do {
191191
print(wrapped6.a)
192192
// CHECK: in getter
@@ -214,7 +214,7 @@ func testPropertyWrappers() {
214214
}
215215

216216
var wrapped7 = ComplexPropWrapperTest()
217-
// CHECK: Wrapper.init($Storage(_a: type_wrapper_defs.PropWrapper<Swift.Array<Swift.String>>(value: ["a"]), _b: type_wrapper_defs.PropWrapperWithoutInit<type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>>(value: type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>(value: [1, 2, 3]))))
217+
// CHECK: Wrapper.init(for: ComplexPropWrapperTest, storage: $Storage(_a: type_wrapper_defs.PropWrapper<Swift.Array<Swift.String>>(value: ["a"]), _b: type_wrapper_defs.PropWrapperWithoutInit<type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>>(value: type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>(value: [1, 2, 3]))))
218218
do {
219219
print(wrapped7.a)
220220
// CHECK: in getter
@@ -242,7 +242,7 @@ func testPropertyWrappers() {
242242
}
243243

244244
var wrapped8 = ComplexPropWrapperTest(a: ["a", "b"])
245-
// CHECK: Wrapper.init($Storage(_a: type_wrapper_defs.PropWrapper<Swift.Array<Swift.String>>(value: ["a", "b"]), _b: type_wrapper_defs.PropWrapperWithoutInit<type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>>(value: type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>(value: [1, 2, 3]))))
245+
// CHECK: Wrapper.init(for: ComplexPropWrapperTest, storage: $Storage(_a: type_wrapper_defs.PropWrapper<Swift.Array<Swift.String>>(value: ["a", "b"]), _b: type_wrapper_defs.PropWrapperWithoutInit<type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>>(value: type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>(value: [1, 2, 3]))))
246246
do {
247247
print(wrapped8.a)
248248
// CHECK: in getter
@@ -270,7 +270,7 @@ func testPropertyWrappers() {
270270
}
271271

272272
var wrapped9 = ComplexPropWrapperTest(b: PropWrapperWithoutInit(value: PropWrapper(wrappedValue: [0])))
273-
// CHECK: Wrapper.init($Storage(_a: type_wrapper_defs.PropWrapper<Swift.Array<Swift.String>>(value: ["a"]), _b: type_wrapper_defs.PropWrapperWithoutInit<type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>>(value: type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>(value: [0]))))
273+
// CHECK: Wrapper.init(for: ComplexPropWrapperTest, storage: $Storage(_a: type_wrapper_defs.PropWrapper<Swift.Array<Swift.String>>(value: ["a"]), _b: type_wrapper_defs.PropWrapperWithoutInit<type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>>(value: type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>(value: [0]))))
274274
do {
275275
print(wrapped9.a)
276276
// CHECK: in getter
@@ -298,7 +298,7 @@ func testPropertyWrappers() {
298298
}
299299

300300
var wrapped10 = ComplexPropWrapperTest(a: [], b: PropWrapperWithoutInit(value: PropWrapper(wrappedValue: [0])))
301-
// CHECK: Wrapper.init($Storage(_a: type_wrapper_defs.PropWrapper<Swift.Array<Swift.String>>(value: []), _b: type_wrapper_defs.PropWrapperWithoutInit<type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>>(value: type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>(value: [0]))))
301+
// CHECK: Wrapper.init(for: ComplexPropWrapperTest, storage: $Storage(_a: type_wrapper_defs.PropWrapper<Swift.Array<Swift.String>>(value: []), _b: type_wrapper_defs.PropWrapperWithoutInit<type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>>(value: type_wrapper_defs.PropWrapper<Swift.Array<Swift.Int>>(value: [0]))))
302302
do {
303303
print(wrapped10.a)
304304
// CHECK: in getter
@@ -326,7 +326,7 @@ func testPropertyWrappers() {
326326
}
327327

328328
var wrapped11 = PropWrapperNoProjectionTest()
329-
// CHECK: Wrapper.init($Storage(_a: type_wrapper_defs.PropWrapperWithoutProjection<Swift.Int>(value: 0), _b: type_wrapper_defs.PropWrapperWithoutProjection<type_wrapper_defs.PropWrapper<Swift.String>>(value: type_wrapper_defs.PropWrapper<Swift.String>(value: "b"))))
329+
// CHECK: Wrapper.init(for: PropWrapperNoProjectionTest, storage: $Storage(_a: type_wrapper_defs.PropWrapperWithoutProjection<Swift.Int>(value: 0), _b: type_wrapper_defs.PropWrapperWithoutProjection<type_wrapper_defs.PropWrapper<Swift.String>>(value: type_wrapper_defs.PropWrapper<Swift.String>(value: "b"))))
330330
do {
331331
print(wrapped11.a)
332332
// CHECK: in getter
@@ -358,7 +358,7 @@ testPropertyWrappers()
358358

359359
do {
360360
var person = PersonWithUnmanagedTest(name: "Arthur Dent")
361-
// CHECK: Wrapper.init($Storage(name: "Arthur Dent", _favoredColor: type_wrapper_defs.PropWrapper<Swift.String>(value: "red")))
361+
// CHECK: Wrapper.init(for: PersonWithUnmanagedTest, storage: $Storage(name: "Arthur Dent", _favoredColor: type_wrapper_defs.PropWrapper<Swift.String>(value: "red")))
362362

363363
print(person.name)
364364
// CHECK: in read-only getter
@@ -412,7 +412,7 @@ do {
412412

413413
do {
414414
var arthur = PersonWithIgnoredAge(name: "Arthur Dent", age: 30)
415-
// CHECK: Wrapper.init($Storage(name: "Arthur Dent"))
415+
// CHECK: Wrapper.init(for: PersonWithIgnoredAge, storage: $Storage(name: "Arthur Dent"))
416416

417417
print(arthur.name)
418418
// CHECK: in getter
@@ -430,7 +430,7 @@ do {
430430
// CHECK-NOT: in setter
431431

432432
var marvin = PersonWithIgnoredAge(name: "Marvin The Paranoid Android", manufacturer: "Sirius Cybernetics Corporation")
433-
// CHECK: Wrapper.init($Storage(name: "Marvin The Paranoid Android"))
433+
// CHECK: Wrapper.init(for: PersonWithIgnoredAge, storage: $Storage(name: "Marvin The Paranoid Android"))
434434

435435
print(marvin.name)
436436
// CHECK: in getter
@@ -454,31 +454,31 @@ do {
454454
// user-defined init tests
455455
do {
456456
_ = EmptyUserDefinedInitClassTest()
457-
// CHECK: Wrapper.init($Storage())
457+
// CHECK: Wrapper.init(for: EmptyUserDefinedInitClassTest, storage: $Storage())
458458
_ = EmptyUserDefinedInitStructTest()
459-
// CHECK: Wrapper.init($Storage())
459+
// CHECK: Wrapper.init(for: EmptyUserDefinedInitStructTest, storage: $Storage())
460460

461461
_ = TrivialUserDefinedInitClassTest(a: 42)
462-
// CHECK: Wrapper.init($Storage(a: 42))
462+
// CHECK: Wrapper.init(for: TrivialUserDefinedInitClassTest, storage: $Storage(a: 42))
463463

464464
_ = TrivialUserDefinedInitClassTest(withReassign: 42)
465-
// CHECK: Wrapper.init($Storage(a: 0))
465+
// CHECK: Wrapper.init(for: TrivialUserDefinedInitClassTest, storage: $Storage(a: 0))
466466
// CHECK-NEXT: in getter
467467
// CHECK-NEXT: 0
468468
// CHECK-NEXT: in setter => 42
469469
// CHECK-NEXT: in getter
470470
// CHECK-NEXT: 42
471471

472472
_ = TrivialUserDefinedInitStructTest(withReassign: 42)
473-
// CHECK: Wrapper.init($Storage(a: 0))
473+
// CHECK: Wrapper.init(for: TrivialUserDefinedInitStructTest, storage: $Storage(a: 0))
474474
// CHECK-NEXT: in getter
475475
// CHECK-NEXT: 0
476476
// CHECK-NEXT: in setter => 42
477477
// CHECK-NEXT: in getter
478478
// CHECK-NEXT: 42
479479

480480
let complex1 = ContextUserDefinedInitClassTest(c: ["hello": 42], placeholder: ("<placeholder>", -1))
481-
// CHECK: Wrapper.init($Storage(a: 0, _b: type_wrapper_defs.PropWrapper<(Swift.String, (Swift.Int, Swift.Array<Swift.Int>))>(value: ("", (0, [1, 2, 3]))), c: ["hello": 42]))
481+
// CHECK: Wrapper.init(for: ContextUserDefinedInitClassTest<String, Int>, storage: $Storage(a: 0, _b: type_wrapper_defs.PropWrapper<(Swift.String, (Swift.Int, Swift.Array<Swift.Int>))>(value: ("", (0, [1, 2, 3]))), c: ["hello": 42]))
482482
// CHECK-NEXT: in getter
483483
// CHECK-NEXT: ["hello": 42]
484484
// CHECK-NEXT: in getter
@@ -503,7 +503,7 @@ do {
503503
}
504504

505505
let complex2 = ContextUserDefinedInitStructTest(b: ("", (0, [1])), c: ["hello": 42], placeholder: ("<placeholder>", -1))
506-
// CHECK: Wrapper.init($Storage(a: 0, _b: type_wrapper_defs.PropWrapper<(Swift.String, (Swift.Int, Swift.Array<Swift.Int>))>(value: ("", (0, [1]))), c: ["hello": 42]))
506+
// CHECK: Wrapper.init(for: ContextUserDefinedInitStructTest<String, Int>, storage: $Storage(a: 0, _b: type_wrapper_defs.PropWrapper<(Swift.String, (Swift.Int, Swift.Array<Swift.Int>))>(value: ("", (0, [1]))), c: ["hello": 42]))
507507
// CHECK-NEXT: in getter
508508
// CHECK-NEXT: ["hello": 42]
509509
// CHECK-NEXT: in getter
@@ -528,33 +528,34 @@ do {
528528

529529
// cond: true, initialValue: nil
530530
_ = UserDefinedInitWithConditionalTest<Int>()
531-
// CHECK: Wrapper.init($Storage(val: nil))
531+
// CHECK: Wrapper.init(for: UserDefinedInitWithConditionalTest<Int>, storage: $Storage(val: nil))
532532
// CHECK-NEXT: in getter
533533
// CHECK-NEXT nil
534534

535535
// initalValue: nil
536536
_ = UserDefinedInitWithConditionalTest<[String: any BinaryInteger]>(cond: true)
537-
// CHECK: Wrapper.init($Storage(val: nil))
537+
// CHECK: Wrapper.init(for: UserDefinedInitWithConditionalTest<Dictionary<String, BinaryInteger>>, storage: $Storage(val: nil))
538538
// CHECK-NEXT: in getter
539539
// CHECK-NEXT: nil
540540

541541
do {
542542
let initialValue = (("a", 42), ("b", 0))
543543

544544
_ = UserDefinedInitWithConditionalTest(cond: true, initialValue: initialValue)
545-
// CHECK: Wrapper.init($Storage(val: Optional((("a", 42), ("b", 0)))))
545+
// CHECK: Wrapper.init(for: UserDefinedInitWithConditionalTest<((String, Int), (String, Int))>, storage: $Storage(val: Optional((("a", 42), ("b", 0)))))
546546
// CHECK-NEXT: in getter
547547
// CHECK-NEXT: Optional((("a", 42), ("b", 0)))
548548

549549
_ = UserDefinedInitWithConditionalTest(cond: false, initialValue: initialValue)
550-
// CHECK: Wrapper.init($Storage(val: nil))
550+
// CHECK: Wrapper.init(for: UserDefinedInitWithConditionalTest<((String, Int), (String, Int))>, storage: $Storage(val: nil))
551551
// CHECK-NEXT: in getter
552552
// CHECK-NEXT: nil
553553
}
554554
}
555555

556556
do {
557557
let test1 = ClassWithConvenienceInit(a: [1, 2, 3])
558+
// CHECK: Wrapper.init(for: ClassWithConvenienceInit<Array<Int>>, storage: $Storage(a: Optional([1, 2, 3]), b: "<placeholder>"))
558559
// CHECK: in getter
559560
// CHECK-NEXT: [1, 2, 3]
560561
// CHECK-NEXT: in getter
@@ -573,6 +574,7 @@ do {
573574
}
574575

575576
test((a: 1, b: 2.0, c: 3))
577+
// CHECK: Wrapper.init(for: ClassWithConvenienceInit<(Int, String, (a: Int, b: Double, c: Int))>, storage: $Storage(a: nil, b: "<placeholder>"))
576578
// -> from init(a: T?)
577579
// CHECK: in getter
578580
// CHECK-NEXT: nil
@@ -606,7 +608,7 @@ do {
606608
let test1 = TypeWithLetProperties(a: arg, b: 42) {
607609
arg.x.append(1)
608610
}
609-
// CHECK: Wrapper.init($Storage(a: X(x: []), b: 42))
611+
// CHECK: Wrapper.init(for: TypeWithLetProperties<X>, storage: $Storage(a: X(x: []), b: 42))
610612
// CHECK-NEXT: --Before onSet--
611613
// CHECK-NEXT: in read-only getter
612614
// CHECK-NEXT: X(x: [])
@@ -619,7 +621,7 @@ do {
619621
// CHECK-nEXT: 42
620622

621623
let test2 = TypeWithLetProperties(a: Optional.some([1, 2, 3]))
622-
// CHECK: Wrapper.init($Storage(a: Optional([1, 2, 3]), b: 0))
624+
// CHECK: Wrapper.init(for: TypeWithLetProperties<Optional<Array<Int>>>, storage: $Storage(a: Optional([1, 2, 3]), b: 0))
623625
// CHECK-NEXT: --Before onSet--
624626
// CHECK-NEXT: in read-only getter
625627
// CHECK-NEXT: Optional([1, 2, 3])

test/SILOptimizer/type_wrapper_definite_init_diagnostics.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// REQUIRES: asserts
44

55
@typeWrapper
6-
struct Wrapper<S> {
6+
struct Wrapper<W, S> {
77
var underlying: S
88

9-
init(storage: S) { self.underlying = storage }
9+
init(for: W.Type, storage: S) { self.underlying = storage }
1010

1111
subscript<V>(storageKeyPath path: KeyPath<S, V>) -> V {
1212
get { underlying[keyPath: path] }

test/SILOptimizer/type_wrapper_in_user_defined_init_lowering.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import Builtin
66
import Swift
77
import SwiftShims
88

9-
@typeWrapper class MyWrapper<S> {
9+
@typeWrapper class MyWrapper<W, S> {
1010
@_hasStorage var underlying: S { get set }
11-
init(storage s: S)
11+
init(for: W.Type, storage s: S)
1212
subscript<V>(storageKeyPath path: KeyPath<S, V>) -> V { get }
1313
subscript<V>(storageKeyPath path: WritableKeyPath<S, V>) -> V { get set }
1414
deinit

0 commit comments

Comments
 (0)