@@ -729,6 +729,16 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
729
729
if (!DC)
730
730
return TheCU;
731
731
732
+ auto createContext = [&](NominalTypeDecl &NTD) {
733
+ GenericContextScope scope (
734
+ IGM, NTD.getGenericSignature ().getCanonicalSignature ());
735
+
736
+ auto Ty = NTD.getDeclaredInterfaceType ();
737
+ // Create a Forward-declared type.
738
+ auto DbgTy = DebugTypeInfo::getForwardDecl (Ty);
739
+ return getOrCreateType (DbgTy);
740
+ };
741
+
732
742
if (isa<FuncDecl>(DC))
733
743
if (auto *Decl = IGM.getSILModule ().lookUpFunction (SILDeclRef (
734
744
cast<AbstractFunctionDecl>(DC), SILDeclRef::Kind::Func)))
@@ -742,7 +752,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
742
752
743
753
// We don't model these in DWARF.
744
754
case DeclContextKind::Initializer:
745
- case DeclContextKind::ExtensionDecl:
746
755
case DeclContextKind::SubscriptDecl:
747
756
case DeclContextKind::EnumElementDecl:
748
757
case DeclContextKind::TopLevelCodeDecl:
@@ -761,16 +770,17 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
761
770
return getOrCreateContext (DC->getParent ());
762
771
case DeclContextKind::MacroDecl:
763
772
return getOrCreateContext (DC->getParent ());
773
+ case DeclContextKind::ExtensionDecl: {
774
+ auto *ED = cast<ExtensionDecl>(DC);
775
+ if (auto *NTD = ED->getExtendedNominal ())
776
+ return createContext (*NTD);
777
+ return getOrCreateContext (DC->getParent ());
778
+ }
764
779
case DeclContextKind::GenericTypeDecl: {
765
- // The generic signature of this nominal type has no relation to the current
766
- // function's generic signature.
780
+ // The generic signature of this nominal type has no relation to the
781
+ // current function's generic signature.
767
782
auto *NTD = cast<NominalTypeDecl>(DC);
768
- GenericContextScope scope (IGM, NTD->getGenericSignature ().getCanonicalSignature ());
769
-
770
- auto Ty = NTD->getDeclaredInterfaceType ();
771
- // Create a Forward-declared type.
772
- auto DbgTy = DebugTypeInfo::getForwardDecl (Ty);
773
- return getOrCreateType (DbgTy);
783
+ return createContext (*NTD);
774
784
}
775
785
}
776
786
return TheCU;
0 commit comments