Skip to content

[5.1][Sema] Treat static methods as always applying their curried self param #25288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ bool constraints::areConservativelyCompatibleArgumentLabels(
bool hasCurriedSelf;
if (isa<SubscriptDecl>(decl)) {
hasCurriedSelf = false;
} else if (decl->isStatic() && isa<AbstractFunctionDecl>(decl)) {
// Static methods always have their Self.Type parameter applied.
hasCurriedSelf = true;
} else if (!baseType || baseType->is<ModuleType>()) {
hasCurriedSelf = false;
} else if (baseType->is<AnyMetatypeType>() && decl->isInstanceMember()) {
Expand Down
14 changes: 14 additions & 0 deletions test/Constraints/operator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,17 @@ func rdar46459603() {
_ = [arr.values] == [[e]]
// expected-error@-1 {{protocol type 'Any' cannot conform to 'Equatable' because only concrete types can conform to protocols}}
}

// SR-10843
infix operator ^^^
func ^^^ (lhs: String, rhs: String) {}

struct SR10843 {
static func ^^^ (lhs: SR10843, rhs: SR10843) {}
}

func sr10843() {
let s = SR10843()
(^^^)(s, s)
_ = (==)(0, 0)
}