@@ -565,20 +565,22 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
565565 if (current == other || (other->hasInterfaceType () && other->isInvalid ()))
566566 continue ;
567567
568+ auto *otherDC = other->getDeclContext ();
569+
568570 // Skip declarations in other modules.
569- if (currentModule != other-> getModuleContext ())
571+ if (currentModule != otherDC-> getParentModule ())
570572 continue ;
571573
572574 // If both declarations are in the same file, only diagnose the second one.
573- if (currentFile == other-> getDeclContext () ->getParentSourceFile ())
575+ if (currentFile == otherDC ->getParentSourceFile ())
574576 if (current->getLoc ().isValid () &&
575577 ctx.SourceMgr .isBeforeInBuffer (
576578 current->getLoc (), other->getLoc ()))
577579 continue ;
578580
579581 // Don't compare methods vs. non-methods (which only happens with
580582 // operators).
581- if (currentDC->isTypeContext () != other-> getDeclContext () ->isTypeContext ())
583+ if (currentDC->isTypeContext () != otherDC ->isTypeContext ())
582584 continue ;
583585
584586 // In local context, only consider exact name matches.
@@ -592,7 +594,7 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
592594 if (!conflicting (currentSig, otherSig))
593595 continue ;
594596
595- // Skip declarations in other files.
597+ // Skip inaccessible declarations in other files.
596598 // In practice, this means we will warn on a private declaration that
597599 // shadows a non-private one, but only in the file where the shadowing
598600 // happens. We will warn on conflicting non-private declarations in both
@@ -605,6 +607,15 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
605607 if (other->isInvalid ())
606608 continue ;
607609
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+
608619 // Thwart attempts to override the same declaration more than once.
609620 const auto *currentOverride = current->getOverriddenDecl ();
610621 const auto *otherOverride = other->getOverriddenDecl ();
0 commit comments