Skip to content

Commit 3166ef3

Browse files
authored
Merge pull request #86159 from slavapestov/slava/fix-issue-86118-6.3
[6.3] SILGen: Fix assert when emitting re-abstraction thunk in edge case involving opaque return type
2 parents 18861a3 + bffd46b commit 3166ef3

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3426,7 +3426,9 @@ CanSILFunctionType swift::buildSILFunctionThunkType(
34263426

34273427
if (!capturedEnvs.empty() ||
34283428
expectedType->hasPrimaryArchetype() ||
3429-
sourceType->hasPrimaryArchetype()) {
3429+
sourceType->hasPrimaryArchetype() ||
3430+
(inputSubstType && inputSubstType->hasPrimaryArchetype()) ||
3431+
(outputSubstType && outputSubstType->hasPrimaryArchetype())) {
34303432
// Get the existing generic signature.
34313433
baseGenericSig = fn->getLoweredFunctionType()
34323434
->getInvocationGenericSignature();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %target-swift-emit-silgen %s
2+
3+
// https://github.com/swiftlang/swift/issues/86118
4+
5+
// The AST type of the thunk depends on the generic signature, but the
6+
// lowered type does not, because we can see the opaque return type's
7+
// underlying type from the expansion point, and it does not involve
8+
// type parameters. Make sure this does not cause us to assert.
9+
10+
public struct G<T> {
11+
public static func f(_: Any, _: Any) -> some Any {
12+
return 123
13+
}
14+
}
15+
16+
public func g<T>(_: T) {
17+
let fn: (Any, Any) -> _ = G<T>.f
18+
let fn2: (Int, Int) -> _ = fn
19+
}

0 commit comments

Comments
 (0)