LoadableByAddress: Fix shouldTransformYields to use substituted types

rdar://149281263
issues/80818
This commit is contained in:
Arnold Schwaighofer
2025-04-21 13:01:38 -07:00
parent b76047a846
commit 521fb07523
2 changed files with 33 additions and 3 deletions

View File

@@ -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,

View File

@@ -30,3 +30,30 @@ public class Test {
}
}
}
// So did this test case.
enum E {
case a
}
protocol P {
associatedtype A
typealias S = C<A>.S
var v: E { get set }
var v2: (t: Int, i: S)? { get set }
}
class C<A> {
struct S { }
init(_: ClosedRange<Double>) { }
}
class C2<T>: P {
typealias A = T
var v: E = .a
var v2: (t: Int, i: S)?
}