Skip to content

Commit acd5a76

Browse files
authored
Merge pull request #86131 from slavapestov/fix-issue-86118
SILGen: Fix assert when emitting re-abstraction thunk in edge case involving opaque return type
2 parents 80152b2 + d497e65 commit acd5a76

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
@@ -3605,7 +3605,9 @@ CanSILFunctionType swift::buildSILFunctionThunkType(
36053605

36063606
if (!capturedEnvs.empty() ||
36073607
expectedType->hasPrimaryArchetype() ||
3608-
sourceType->hasPrimaryArchetype()) {
3608+
sourceType->hasPrimaryArchetype() ||
3609+
(inputSubstType && inputSubstType->hasPrimaryArchetype()) ||
3610+
(outputSubstType && outputSubstType->hasPrimaryArchetype())) {
36093611
// Get the existing generic signature.
36103612
baseGenericSig = fn->getLoweredFunctionType()
36113613
->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)