Skip to content

Commit 44a86cb

Browse files
authored
Merge pull request #9507 from DougGregor/redundant-conformance-warnings-imported
2 parents 365c0c2 + a43fbed commit 44a86cb

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6117,13 +6117,15 @@ void TypeChecker::checkConformancesInContext(DeclContext *dc,
61176117
auto extendedNominal =
61186118
diag.ExistingDC->getAsNominalTypeOrNominalTypeExtensionContext();
61196119
if (existingModule != dc->getParentModule() &&
6120-
(existingModule == extendedNominal->getParentModule() ||
6120+
(existingModule->getName() ==
6121+
extendedNominal->getParentModule()->getName() ||
61216122
existingModule == diag.Protocol->getParentModule())) {
61226123
// Warn about the conformance.
61236124
diagnose(diag.Loc, diag::redundant_conformance_adhoc,
61246125
dc->getDeclaredInterfaceType(),
61256126
diag.Protocol->getName(),
6126-
existingModule == extendedNominal->getParentModule(),
6127+
existingModule->getName() ==
6128+
extendedNominal->getParentModule()->getName(),
61276129
existingModule->getName());
61286130

61296131
// Complain about any declarations in this extension whose names match
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-typecheck-verify-swift -swift-version 3
2+
3+
// REQUIRES: objc_interop
4+
5+
import Foundation
6+
7+
extension NSRange : Hashable { // expected-warning{{conformance of '_NSRange' to protocol 'Hashable' was already stated in the type's module 'Foundation'}}
8+
var hashValue: Int { return 0 } // expected-note{{var 'hashValue' will not be used to satisfy the conformance to 'Hashable'}}
9+
}

0 commit comments

Comments
 (0)