Skip to content

Commit e584195

Browse files
committed
SIL: Use the right generic signature for computing SIL function type for coroutine accessors
The function type's generic signature will have already been dropped at this point if all generic parameters were fully concrete, so use the original generic signature to compute the reduced type of the yield type. Fixes #61040.
1 parent cfb6f8c commit e584195

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,9 +1960,12 @@ static CanSILFunctionType getSILFunctionType(
19601960

19611961
if (reqtSubs) {
19621962
valueType = valueType.subst(*reqtSubs);
1963+
coroutineSubstYieldType = valueType->getReducedType(
1964+
genericSig);
1965+
} else {
1966+
coroutineSubstYieldType = valueType->getReducedType(
1967+
accessor->getGenericSignature());
19631968
}
1964-
1965-
coroutineSubstYieldType = valueType->getReducedType(genericSig);
19661969
}
19671970

19681971
bool shouldBuildSubstFunctionType = [&]{

test/SILGen/constrained_extensions.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,16 @@ func referenceNestedTypes() {
227227
_ = Array<AnyObject>.NestedClass()
228228
_ = Array<AnyObject>.DerivedClass()
229229
}
230+
231+
struct S<T> {
232+
struct X {}
233+
}
234+
235+
// CHECK-LABEL: sil hidden [ossa] @$s22constrained_extensions1SVAASiRszlEyAC1XVySi_GSicir : $@yield_once @convention(method) (Int, S<Int>) -> @yields S<Int>.X
236+
extension S<Int> {
237+
subscript(index:Int) -> X {
238+
_read {
239+
fatalError()
240+
}
241+
}
242+
}

0 commit comments

Comments
 (0)