Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/SIL/IR/SILFunctionType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3605,7 +3605,9 @@ CanSILFunctionType swift::buildSILFunctionThunkType(

if (!capturedEnvs.empty() ||
expectedType->hasPrimaryArchetype() ||
sourceType->hasPrimaryArchetype()) {
sourceType->hasPrimaryArchetype() ||
(inputSubstType && inputSubstType->hasPrimaryArchetype()) ||
(outputSubstType && outputSubstType->hasPrimaryArchetype())) {
// Get the existing generic signature.
baseGenericSig = fn->getLoweredFunctionType()
->getInvocationGenericSignature();
Expand Down
19 changes: 19 additions & 0 deletions test/SILGen/opaque_result_type_thunk.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// RUN: %target-swift-emit-silgen %s

// https://github.com/swiftlang/swift/issues/86118

// The AST type of the thunk depends on the generic signature, but the
// lowered type does not, because we can see the opaque return type's
// underlying type from the expansion point, and it does not involve
// type parameters. Make sure this does not cause us to assert.

public struct G<T> {
public static func f(_: Any, _: Any) -> some Any {
return 123
}
}

public func g<T>(_: T) {
let fn: (Any, Any) -> _ = G<T>.f
let fn2: (Int, Int) -> _ = fn
}