Skip to content

Commit 2c01358

Browse files
DougGregorphausler
authored andcommitted
[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 ce24192 commit 2c01358

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
@@ -6089,13 +6089,15 @@ void TypeChecker::checkConformancesInContext(DeclContext *dc,
60896089
auto extendedNominal =
60906090
diag.ExistingDC->getAsNominalTypeOrNominalTypeExtensionContext();
60916091
if (existingModule != dc->getParentModule() &&
6092-
(existingModule == extendedNominal->getParentModule() ||
6092+
(existingModule->getName() ==
6093+
extendedNominal->getParentModule()->getName() ||
60936094
existingModule == diag.Protocol->getParentModule())) {
60946095
// Warn about the conformance.
60956096
diagnose(diag.Loc, diag::redundant_conformance_adhoc,
60966097
dc->getDeclaredInterfaceType(),
60976098
diag.Protocol->getName(),
6098-
existingModule == extendedNominal->getParentModule(),
6099+
existingModule->getName() ==
6100+
extendedNominal->getParentModule()->getName(),
60996101
existingModule->getName());
61006102

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