Skip to content

Commit cf81104

Browse files
Merge pull request #80989 from aschwaighofer/loadable_by_address_fix_yields_pattern_subst_6.2
[6.2] LoadableByAddress: Fix shouldTransformYields to use (properly) substituted types
2 parents 121aa40 + 345d1a6 commit cf81104

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,14 @@ static bool modResultType(SILFunction *F, irgen::IRGenModule &Mod,
375375
static bool shouldTransformYields(GenericEnvironment *genEnv,
376376
CanSILFunctionType loweredTy,
377377
irgen::IRGenModule &Mod,
378-
LargeSILTypeMapper &Mapper) {
378+
LargeSILTypeMapper &Mapper,
379+
TypeExpansionContext expansion) {
379380
if (!modifiableFunction(loweredTy)) {
380381
return false;
381382
}
382383
for (auto &yield : loweredTy->getYields()) {
383-
auto yieldStorageType = yield.getSILStorageInterfaceType();
384+
auto yieldStorageType = yield.getSILStorageType(Mod.getSILModule(),
385+
loweredTy, expansion);
384386
auto newYieldStorageType =
385387
Mapper.getNewSILType(genEnv, yieldStorageType, Mod);
386388
if (yieldStorageType != newYieldStorageType)
@@ -394,7 +396,8 @@ static bool modYieldType(SILFunction *F, irgen::IRGenModule &Mod,
394396
GenericEnvironment *genEnv = getSubstGenericEnvironment(F);
395397
auto loweredTy = F->getLoweredFunctionType();
396398

397-
return shouldTransformYields(genEnv, loweredTy, Mod, Mapper);
399+
return shouldTransformYields(genEnv, loweredTy, Mod, Mapper,
400+
F->getTypeExpansionContext());
398401
}
399402

400403
SILParameterInfo LargeSILTypeMapper::getNewParameter(GenericEnvironment *env,

test/IRGen/loadable_by_address.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,30 @@ public class Test {
3030
}
3131
}
3232
}
33+
34+
// So did this test case.
35+
enum E {
36+
case a
37+
}
38+
39+
protocol P {
40+
associatedtype A
41+
typealias S = C<A>.S
42+
43+
var v: E { get set }
44+
45+
var v2: (t: Int, i: S)? { get set }
46+
}
47+
48+
class C<A> {
49+
struct S { }
50+
51+
init(_: ClosedRange<Double>) { }
52+
}
53+
54+
class C2<T>: P {
55+
typealias A = T
56+
var v: E = .a
57+
58+
var v2: (t: Int, i: S)?
59+
}

0 commit comments

Comments
 (0)