Skip to content
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

[SR-15269] SE-0299 won't work in case of overloads #57591

Open
groue opened this issue Oct 1, 2021 · 0 comments
Open

[SR-15269] SE-0299 won't work in case of overloads #57591

groue opened this issue Oct 1, 2021 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@groue
Copy link

groue commented Oct 1, 2021

Previous ID SR-15269
Radar None
Original Reporter @groue
Type Bug
Environment

Xcode 13.0 (13A233)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: a9cb4639075680dd9ff53f7f9c8b37e4

Issue Description:

Hello,

The Swift 5.5 compiler won't accept the shorthand notation .staticMember for existential values, as described by SE-0299 Extending Static Member Lookup in Generic Contexts, when there exist an overload that accepts another input.

I stumbled upon this issue while trying to enhance an API that provides both a method that accepts a variadic input, as well as an array, as a convenience. The overloads prevents the user from using the shorthand notation, ruining SE-0299 benefits.

See in the sample code below four examples, two successes, and two unexpected compiler errors:

// ======
// SE-0299 setup

protocol P { }
struct S: P { }
extension P where Self == S {
    static var s: Self { S() }
}

// ======
// SE-0299 successes

func f1(_ p: P) { }
f1(.s) // OK

func f2(_ ps: P...) { }
f2(.s) // OK

// ======
// SE-0299 failures

func f3(_ ps: P...) { }
func f3(_ ps: [P]) { }
f3(.s) // error: Type '[P]' has no member 's'

func f4(_ p: P) { }
func f4(_ int: Int) { }
f4(.s) // error: Type 'Int' has no member 's'
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

1 participant