Skip to content

Commit a43fbed

Browse files
committed
[Type checker] Extend redundant-conformance warning to imported types.
Fix a silly gap in my fix for rdar://problem/31104415, where imported types that gain conformances through their overlays were still getting errors. Fixes SR-4820 / rdar://problem/32134724.
1 parent 31f7dfe commit a43fbed

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
@@ -6101,13 +6101,15 @@ void TypeChecker::checkConformancesInContext(DeclContext *dc,
61016101
auto extendedNominal =
61026102
diag.ExistingDC->getAsNominalTypeOrNominalTypeExtensionContext();
61036103
if (existingModule != dc->getParentModule() &&
6104-
(existingModule == extendedNominal->getParentModule() ||
6104+
(existingModule->getName() ==
6105+
extendedNominal->getParentModule()->getName() ||
61056106
existingModule == diag.Protocol->getParentModule())) {
61066107
// Warn about the conformance.
61076108
diagnose(diag.Loc, diag::redundant_conformance_adhoc,
61086109
dc->getDeclaredInterfaceType(),
61096110
diag.Protocol->getName(),
6110-
existingModule == extendedNominal->getParentModule(),
6111+
existingModule->getName() ==
6112+
extendedNominal->getParentModule()->getName(),
61116113
existingModule->getName());
61126114

61136115
// 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)