Skip to content

Commit 5c718cf

Browse files
committed
IRGen: Fix edge case where we emit debug info type with the wrong generic signature
PR swiftlang#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 swiftlang#63869.
1 parent 9d9e015 commit 5c718cf

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,11 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
621621
case DeclContextKind::MacroDecl:
622622
return getOrCreateContext(DC->getParent());
623623
case DeclContextKind::GenericTypeDecl: {
624+
// The generic signature of this nominal type has no relation to the current
625+
// function's generic signature.
624626
auto *NTD = cast<NominalTypeDecl>(DC);
627+
GenericContextScope scope(IGM, NTD->getGenericSignature().getCanonicalSignature());
628+
625629
auto Ty = NTD->getDeclaredInterfaceType();
626630
// Create a Forward-declared type.
627631
auto DbgTy = DebugTypeInfo::getForwardDecl(Ty);
@@ -673,9 +677,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
673677
// The function return type is the first element in the list.
674678
createParameterType(Parameters, getResultTypeForDebugInfo(IGM, FnTy));
675679

676-
// Actually, the input type is either a single type or a tuple
677-
// type. We currently represent a function with one n-tuple argument
678-
// as an n-ary function.
679680
for (auto Param : FnTy->getParameters())
680681
createParameterType(
681682
Parameters, IGM.silConv.getSILType(

test/DebugInfo/issue-63869.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %target-swift-frontend -emit-ir -g %s
2+
3+
public protocol P {
4+
associatedtype Element
5+
}
6+
7+
public struct G<T, U> {
8+
public struct Nested {}
9+
10+
public init(_: (Nested) -> ()) {}
11+
}
12+
13+
public extension P {
14+
var values: G<Element, Int> {
15+
G<Element, Int> { x in }
16+
}
17+
}

0 commit comments

Comments
 (0)