@@ -2064,6 +2064,27 @@ static void checkProtocolRefinementRequirements(ProtocolDecl *proto) {
2064
2064
}
2065
2065
}
2066
2066
2067
+ static void dumpGenericSignature (ASTContext &ctx, GenericContext *GC) {
2068
+ if (ctx.TypeCheckerOpts .DebugGenericSignatures ) {
2069
+ llvm::errs () << " \n " ;
2070
+ if (auto *VD = dyn_cast_or_null<ValueDecl>(GC->getAsDecl ())) {
2071
+ VD->dumpRef (llvm::errs ());
2072
+ llvm::errs () << " \n " ;
2073
+ } else {
2074
+ GC->printContext (llvm::errs ());
2075
+ }
2076
+ auto sig = GC->getGenericSignature ();
2077
+ llvm::errs () << " Generic signature: " ;
2078
+ PrintOptions Opts;
2079
+ Opts.ProtocolQualifiedDependentMemberTypes = true ;
2080
+ sig->print (llvm::errs (), Opts);
2081
+ llvm::errs () << " \n " ;
2082
+ llvm::errs () << " Canonical generic signature: " ;
2083
+ sig.getCanonicalSignature ()->print (llvm::errs (), Opts);
2084
+ llvm::errs () << " \n " ;
2085
+ }
2086
+ }
2087
+
2067
2088
namespace {
2068
2089
class DeclChecker : public DeclVisitor <DeclChecker> {
2069
2090
public:
@@ -2711,9 +2732,12 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2711
2732
void visitSubscriptDecl (SubscriptDecl *SD) {
2712
2733
auto *DC = SD->getDeclContext ();
2713
2734
2735
+ // Force creation of the generic signature.
2736
+ (void ) SD->getGenericSignature ();
2737
+ dumpGenericSignature (Ctx, SD);
2738
+
2714
2739
// Force requests that can emit diagnostics.
2715
2740
(void ) SD->getInterfaceType ();
2716
- (void ) SD->getGenericSignature ();
2717
2741
2718
2742
if (!SD->isInvalid ()) {
2719
2743
TypeChecker::checkReferencedGenericParams (SD);
@@ -2803,8 +2827,11 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2803
2827
}
2804
2828
2805
2829
void visitTypeAliasDecl (TypeAliasDecl *TAD) {
2806
- // Force requests that can emit diagnostics .
2830
+ // Force creation of the generic signature .
2807
2831
(void ) TAD->getGenericSignature ();
2832
+ dumpGenericSignature (Ctx, TAD);
2833
+
2834
+ // Force requests that can emit diagnostics.
2808
2835
(void ) TAD->getUnderlyingType ();
2809
2836
2810
2837
// Make sure to check the underlying type.
@@ -2930,6 +2957,10 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2930
2957
void visitEnumDecl (EnumDecl *ED) {
2931
2958
checkUnsupportedNestedType (ED);
2932
2959
2960
+ // Force creation of the generic signature.
2961
+ (void ) ED->getGenericSignature ();
2962
+ dumpGenericSignature (Ctx, ED);
2963
+
2933
2964
// Temporary restriction until we figure out pattern matching and
2934
2965
// enum case construction with packs.
2935
2966
if (auto genericSig = ED->getGenericSignature ()) {
@@ -3012,6 +3043,10 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
3012
3043
void visitStructDecl (StructDecl *SD) {
3013
3044
checkUnsupportedNestedType (SD);
3014
3045
3046
+ // Force creation of the generic signature.
3047
+ (void ) SD->getGenericSignature ();
3048
+ dumpGenericSignature (Ctx, SD);
3049
+
3015
3050
checkGenericParams (SD);
3016
3051
3017
3052
// Force lowering of stored properties.
@@ -3206,6 +3241,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
3206
3241
3207
3242
// Force creation of the generic signature.
3208
3243
(void ) CD->getGenericSignature ();
3244
+ dumpGenericSignature (Ctx, CD);
3209
3245
3210
3246
checkGenericParams (CD);
3211
3247
@@ -3317,7 +3353,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
3317
3353
auto *superFile = Super->getModuleScopeContext ();
3318
3354
if (auto *serialized = dyn_cast<SerializedASTFile>(superFile)) {
3319
3355
const auto effVersion =
3320
- CD-> getASTContext () .LangOpts .EffectiveLanguageVersion ;
3356
+ Ctx .LangOpts .EffectiveLanguageVersion ;
3321
3357
if (serialized->getLanguageVersionBuiltWith () != effVersion) {
3322
3358
CD->diagnose (
3323
3359
diag::
@@ -3433,6 +3469,8 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
3433
3469
llvm::errs () << " \n " ;
3434
3470
}
3435
3471
3472
+ dumpGenericSignature (Ctx, PD);
3473
+
3436
3474
if (!reqSig.getErrors ()) {
3437
3475
// Always verify signatures, even if building without asserts.
3438
3476
//
@@ -3463,6 +3501,8 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
3463
3501
(void ) FD->getOperatorDecl ();
3464
3502
(void ) FD->getDynamicallyReplacedDecl ();
3465
3503
3504
+ dumpGenericSignature (Ctx, FD);
3505
+
3466
3506
if (!isa<AccessorDecl>(FD)) {
3467
3507
if (!FD->isInvalid ()) {
3468
3508
checkGenericParams (FD);
@@ -3875,9 +3915,12 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
3875
3915
}
3876
3916
3877
3917
void visitConstructorDecl (ConstructorDecl *CD) {
3878
- (void ) CD->getInterfaceType ();
3918
+ // Force creation of the generic signature.
3919
+ (void ) CD->getGenericSignature ();
3920
+ dumpGenericSignature (Ctx, CD);
3879
3921
3880
3922
// Compute these requests in case they emit diagnostics.
3923
+ (void ) CD->getInterfaceType ();
3881
3924
(void ) CD->getInitKind ();
3882
3925
3883
3926
if (!CD->isInvalid ()) {
0 commit comments