Skip to content

Commit 7cd3b98

Browse files
committed
---
yaml --- r: 348603 b: refs/heads/master c: 0b06834 h: refs/heads/master i: 348601: 562d7d3 348599: 5bcfb15
1 parent 974ea53 commit 7cd3b98

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: f2f105ea6fdbe8ee7ee60967b6db6bbfb809f930
2+
refs/heads/master: 0b0683461ce40de1fb34903d689d9f95a939213d
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/SILGen/SILGenLValue.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,9 @@ namespace {
13841384
VarDecl *field = dyn_cast<VarDecl>(Storage);
13851385
VarDecl *backingVar = field->getPropertyWrapperBackingProperty();
13861386
assert(backingVar);
1387-
CanType ValType = backingVar->getType()->getCanonicalType();
1387+
CanType ValType =
1388+
SGF.F.mapTypeIntoContext(backingVar->getInterfaceType())
1389+
->getCanonicalType();
13881390
SILType varStorageType =
13891391
SGF.SGM.Types.getSubstitutedStorageType(backingVar, ValType);
13901392
auto typeData =
@@ -1407,7 +1409,7 @@ namespace {
14071409
assert(field->getAttachedPropertyWrappers().size() == 1);
14081410
auto wrapperInfo = field->getAttachedPropertyWrapperTypeInfo(0);
14091411
auto ctor = wrapperInfo.wrappedValueInit;
1410-
SubstitutionMap subs = backingVar->getType()->getMemberSubstitutionMap(
1412+
SubstitutionMap subs = ValType->getMemberSubstitutionMap(
14111413
SGF.getModule().getSwiftModule(), ctor);
14121414

14131415
Type ity = ctor->getInterfaceType();
@@ -1418,8 +1420,8 @@ namespace {
14181420
.asForeign(requiresForeignEntryPoint(ctor));
14191421
RValue initFuncRV =
14201422
SGF.emitApplyPropertyWrapperAllocator(loc, subs,initRef,
1421-
backingVar->getType(),
1422-
CanAnyFunctionType(substIty));
1423+
ValType,
1424+
CanAnyFunctionType(substIty));
14231425
ManagedValue initFn = std::move(initFuncRV).getAsSingleValue(SGF, loc);
14241426

14251427
// Create the allocating setter function. It captures the base address.

trunk/test/SILGen/property_wrappers.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,20 @@ public class Container {
447447
}
448448
}
449449

450+
// SR-11303 / rdar://problem/54311335 - crash due to wrong archetype used in generated SIL
451+
public protocol TestProtocol {}
452+
public class TestClass<T> {
453+
@WrapperWithInitialValue var value: T
454+
455+
// CHECK-LABEL: sil hidden [ossa] @$s17property_wrappers9TestClassC5value8protocolACyxGx_qd__tcAA0C8ProtocolRd__lufc
456+
// CHECK: metatype $@thin WrapperWithInitialValue<T>.Type
457+
// CHECK: function_ref @$s17property_wrappers23WrapperWithInitialValueV07wrappedF0ACyxGx_tcfCTc
458+
init<U: TestProtocol>(value: T, protocol: U) {
459+
self.value = value
460+
}
461+
}
462+
463+
450464
// CHECK-LABEL: sil_vtable ClassUsingWrapper {
451465
// CHECK-NEXT: #ClassUsingWrapper.x!getter.1: (ClassUsingWrapper) -> () -> Int : @$s17property_wrappers17ClassUsingWrapperC1xSivg // ClassUsingWrapper.x.getter
452466
// CHECK-NEXT: #ClassUsingWrapper.x!setter.1: (ClassUsingWrapper) -> (Int) -> () : @$s17property_wrappers17ClassUsingWrapperC1xSivs // ClassUsingWrapper.x.setter

0 commit comments

Comments
 (0)