10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
13
+ #include " swift/Frontend/ModuleInterfaceSupport.h"
13
14
#include " swift/AST/ASTContext.h"
14
15
#include " swift/AST/ASTPrinter.h"
15
16
#include " swift/AST/Decl.h"
20
21
#include " swift/AST/Module.h"
21
22
#include " swift/AST/ModuleNameLookup.h"
22
23
#include " swift/AST/NameLookupRequests.h"
24
+ #include " swift/AST/PrettyStackTrace.h"
23
25
#include " swift/AST/ProtocolConformance.h"
24
26
#include " swift/AST/TypeCheckRequests.h"
25
27
#include " swift/AST/TypeRepr.h"
26
28
#include " swift/Basic/Assertions.h"
27
29
#include " swift/Basic/STLExtras.h"
28
30
#include " swift/Frontend/Frontend.h"
29
- #include " swift/Frontend/ModuleInterfaceSupport.h"
30
31
#include " swift/Frontend/PrintingDiagnosticConsumer.h"
31
32
#include " swift/SILOptimizer/PassManager/Passes.h"
32
33
#include " swift/Serialization/SerializationOptions.h"
@@ -530,6 +531,7 @@ class InheritedProtocolCollector {
530
531
// / protocols.
531
532
void recordProtocols (InheritedTypes directlyInherited, const Decl *D,
532
533
bool skipExtra = false ) {
534
+ PrettyStackTraceDecl stackTrace (" recording protocols for" , D);
533
535
std::optional<AvailableAttrList> availableAttrs;
534
536
535
537
for (int i : directlyInherited.getIndices ()) {
@@ -602,11 +604,19 @@ class InheritedProtocolCollector {
602
604
// /
603
605
// / \sa recordProtocols
604
606
static void collectProtocols (PerTypeMap &map, const Decl *D) {
607
+ PrettyStackTraceDecl stackTrace (" collecting protocols for" , D);
605
608
InheritedTypes directlyInherited = InheritedTypes (D);
606
609
const NominalTypeDecl *nominal;
607
610
const IterableDeclContext *memberContext;
608
611
609
612
auto shouldInclude = [](const ExtensionDecl *extension) {
613
+ // In lazy typechecking mode we may be resolving the extended type for the
614
+ // first time here, so we need to call getExtendedType() to cause
615
+ // diagnostics to be emitted if necessary.
616
+ (void )extension->getExtendedType ();
617
+ if (extension->isInvalid ())
618
+ return false ;
619
+
610
620
if (extension->isConstrainedExtension ()) {
611
621
// Conditional conformances never apply to inherited protocols, nor
612
622
// can they provide unconditional conformances that might be used in
@@ -615,9 +625,9 @@ class InheritedProtocolCollector {
615
625
}
616
626
return true ;
617
627
};
628
+
618
629
if ((nominal = dyn_cast<NominalTypeDecl>(D))) {
619
630
memberContext = nominal;
620
-
621
631
} else if (auto *extension = dyn_cast<ExtensionDecl>(D)) {
622
632
if (!shouldInclude (extension)) {
623
633
return ;
@@ -697,6 +707,9 @@ class InheritedProtocolCollector {
697
707
const PrintOptions &printOptions,
698
708
ModuleDecl *M,
699
709
const NominalTypeDecl *nominal) const {
710
+ PrettyStackTraceDecl stackTrace (" printing synthesized extensions for" ,
711
+ nominal);
712
+
700
713
if (ExtraProtocols.empty ())
701
714
return ;
702
715
@@ -881,6 +894,8 @@ const StringLiteral InheritedProtocolCollector::DummyProtocolName =
881
894
bool swift::emitSwiftInterface (raw_ostream &out,
882
895
ModuleInterfaceOptions const &Opts,
883
896
ModuleDecl *M) {
897
+ PrettyStackTraceDecl stackTrace (" emitting swiftinterface for" , M);
898
+
884
899
assert (M);
885
900
886
901
llvm::SmallSet<StringRef, 4 > aliasModuleNamesTargets;
0 commit comments