@@ -565,20 +565,22 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
565
565
if (current == other || (other->hasInterfaceType () && other->isInvalid ()))
566
566
continue ;
567
567
568
+ auto *otherDC = other->getDeclContext ();
569
+
568
570
// Skip declarations in other modules.
569
- if (currentModule != other-> getModuleContext ())
571
+ if (currentModule != otherDC-> getParentModule ())
570
572
continue ;
571
573
572
574
// If both declarations are in the same file, only diagnose the second one.
573
- if (currentFile == other-> getDeclContext () ->getParentSourceFile ())
575
+ if (currentFile == otherDC ->getParentSourceFile ())
574
576
if (current->getLoc ().isValid () &&
575
577
ctx.SourceMgr .isBeforeInBuffer (
576
578
current->getLoc (), other->getLoc ()))
577
579
continue ;
578
580
579
581
// Don't compare methods vs. non-methods (which only happens with
580
582
// operators).
581
- if (currentDC->isTypeContext () != other-> getDeclContext () ->isTypeContext ())
583
+ if (currentDC->isTypeContext () != otherDC ->isTypeContext ())
582
584
continue ;
583
585
584
586
// In local context, only consider exact name matches.
@@ -592,7 +594,7 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
592
594
if (!conflicting (currentSig, otherSig))
593
595
continue ;
594
596
595
- // Skip declarations in other files.
597
+ // Skip inaccessible declarations in other files.
596
598
// In practice, this means we will warn on a private declaration that
597
599
// shadows a non-private one, but only in the file where the shadowing
598
600
// happens. We will warn on conflicting non-private declarations in both
@@ -605,6 +607,15 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
605
607
if (other->isInvalid ())
606
608
continue ;
607
609
610
+ // Allow redeclarations of typealiases in different constrained
611
+ // extensions.
612
+ if (isa<TypeAliasDecl>(current) &&
613
+ isa<TypeAliasDecl>(other) &&
614
+ currentDC != otherDC &&
615
+ currentDC->getGenericSignatureOfContext ().getCanonicalSignature () !=
616
+ otherDC->getGenericSignatureOfContext ().getCanonicalSignature ())
617
+ continue ;
618
+
608
619
// Thwart attempts to override the same declaration more than once.
609
620
const auto *currentOverride = current->getOverriddenDecl ();
610
621
const auto *otherOverride = other->getOverriddenDecl ();
0 commit comments