diff --git a/lib/IRGen/LoadableByAddress.cpp b/lib/IRGen/LoadableByAddress.cpp
index 165c918f88241..f37f17f1b8f9e 100644
--- a/lib/IRGen/LoadableByAddress.cpp
+++ b/lib/IRGen/LoadableByAddress.cpp
@@ -375,12 +375,14 @@ static bool modResultType(SILFunction *F, irgen::IRGenModule &Mod,
static bool shouldTransformYields(GenericEnvironment *genEnv,
CanSILFunctionType loweredTy,
irgen::IRGenModule &Mod,
- LargeSILTypeMapper &Mapper) {
+ LargeSILTypeMapper &Mapper,
+ TypeExpansionContext expansion) {
if (!modifiableFunction(loweredTy)) {
return false;
}
for (auto &yield : loweredTy->getYields()) {
- auto yieldStorageType = yield.getSILStorageInterfaceType();
+ auto yieldStorageType = yield.getSILStorageType(Mod.getSILModule(),
+ loweredTy, expansion);
auto newYieldStorageType =
Mapper.getNewSILType(genEnv, yieldStorageType, Mod);
if (yieldStorageType != newYieldStorageType)
@@ -394,7 +396,8 @@ static bool modYieldType(SILFunction *F, irgen::IRGenModule &Mod,
GenericEnvironment *genEnv = getSubstGenericEnvironment(F);
auto loweredTy = F->getLoweredFunctionType();
- return shouldTransformYields(genEnv, loweredTy, Mod, Mapper);
+ return shouldTransformYields(genEnv, loweredTy, Mod, Mapper,
+ F->getTypeExpansionContext());
}
SILParameterInfo LargeSILTypeMapper::getNewParameter(GenericEnvironment *env,
diff --git a/test/IRGen/loadable_by_address.swift b/test/IRGen/loadable_by_address.swift
index c5804b9235f55..4de89f870b350 100644
--- a/test/IRGen/loadable_by_address.swift
+++ b/test/IRGen/loadable_by_address.swift
@@ -30,3 +30,30 @@ public class Test {
}
}
}
+
+// So did this test case.
+enum E {
+ case a
+}
+
+protocol P {
+ associatedtype A
+ typealias S = C.S
+
+ var v: E { get set }
+
+ var v2: (t: Int, i: S)? { get set }
+}
+
+class C {
+ struct S { }
+
+ init(_: ClosedRange) { }
+}
+
+class C2: P {
+ typealias A = T
+ var v: E = .a
+
+ var v2: (t: Int, i: S)?
+}