Skip to content

Commit 449c7eb

Browse files
committed
[Sema] Fix the source compatibility check for member operators with
existential arguments to not return before checking the second argument type.
1 parent de8726e commit 449c7eb

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,8 @@ bool swift::isMemberOperator(FuncDecl *decl, Type type) {
19031903
// accepts member operators on protocols with existential
19041904
// type arguments. We should consider banning this in Swift 6.
19051905
if (auto existential = paramType->getAs<ExistentialType>()) {
1906-
return selfNominal == existential->getConstraintType()->getAnyNominal();
1906+
if (selfNominal == existential->getConstraintType()->getAnyNominal())
1907+
return true;
19071908
}
19081909

19091910
// For a protocol, is it the 'Self' type parameter?

test/type/explicit_existential.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,11 @@ enum E2: RawRepresentable {
185185
return ConcreteComposition()
186186
}
187187
}
188+
189+
public protocol MyError {}
190+
191+
extension MyError {
192+
static func ~=(lhs: any Error, rhs: Self) -> Bool {
193+
return true
194+
}
195+
}

0 commit comments

Comments
 (0)