Skip to content

Commit 622f49c

Browse files
committed
[Conformance checking] Cleanup renaming check, fix a test.
1 parent 5473e48 commit 622f49c

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ matchWitness(TypeChecker &tc,
806806
}
807807

808808
SmallVector<OptionalAdjustment, 2> optionalAdjustments;
809-
bool anyRenaming = false;
809+
bool anyRenaming = req->getFullName() != witness->getFullName();
810810
if (decomposeFunctionType) {
811811
// Decompose function types into parameters and result type.
812812
auto reqFnType = reqType->castTo<AnyFunctionType>();
@@ -853,12 +853,6 @@ matchWitness(TypeChecker &tc,
853853
if (reqParams[i].isVararg() != witnessParams[i].isVararg())
854854
return RequirementMatch(witness, MatchKind::TypeConflict, witnessType);
855855

856-
// Check the parameter names.
857-
if (reqParams[i].getName() != witnessParams[i].getName()) {
858-
// A parameter has been renamed.
859-
anyRenaming = true;
860-
}
861-
862856
// Gross hack: strip a level of unchecked-optionality off both
863857
// sides when matching against a protocol imported from Objective-C.
864858
auto types = getTypesToCompare(req, reqParams[i].getType(),

test/attr/attr_objc.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,6 +2033,7 @@ class ConformsToProtocolThrowsObjCName2 : ProtocolThrowsObjCName {
20332033
// expected-warning@-1{{instance method 'doThing' nearly matches optional requirement 'doThing' of protocol 'ProtocolThrowsObjCName'}}
20342034
// expected-note@-2{{move 'doThing' to an extension to silence this warning}}
20352035
// expected-note@-3{{make 'doThing' private to silence this warning}}{{9-9=private }}
2036+
// expected-note@-4{{candidate has non-matching type '(Int) throws -> String'}}
20362037
}
20372038

20382039
@objc class DictionaryTest {

0 commit comments

Comments
 (0)