IRGen: Fix edge case where we emit debug info type with the wrong generic signature

PR #63789 introduced verification of the generic parameters appearing in
debug info, but I missed an edge case where we have to push a different
generic signature.

Fixes #63869.
This commit is contained in:
Slava Pestov
2023-02-24 15:08:36 -05:00
parent 9d9e015a9f
commit 5c718cf67a
2 changed files with 21 additions and 3 deletions

View File

@@ -621,7 +621,11 @@ private:
case DeclContextKind::MacroDecl:
return getOrCreateContext(DC->getParent());
case DeclContextKind::GenericTypeDecl: {
// The generic signature of this nominal type has no relation to the current
// function's generic signature.
auto *NTD = cast<NominalTypeDecl>(DC);
GenericContextScope scope(IGM, NTD->getGenericSignature().getCanonicalSignature());
auto Ty = NTD->getDeclaredInterfaceType();
// Create a Forward-declared type.
auto DbgTy = DebugTypeInfo::getForwardDecl(Ty);
@@ -673,9 +677,6 @@ private:
// The function return type is the first element in the list.
createParameterType(Parameters, getResultTypeForDebugInfo(IGM, FnTy));
// Actually, the input type is either a single type or a tuple
// type. We currently represent a function with one n-tuple argument
// as an n-ary function.
for (auto Param : FnTy->getParameters())
createParameterType(
Parameters, IGM.silConv.getSILType(

View File

@@ -0,0 +1,17 @@
// RUN: %target-swift-frontend -emit-ir -g %s
public protocol P {
associatedtype Element
}
public struct G<T, U> {
public struct Nested {}
public init(_: (Nested) -> ()) {}
}
public extension P {
var values: G<Element, Int> {
G<Element, Int> { x in }
}
}