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-15265] callAsFunction only works with methods, and not closures #57587

Open
davedelong opened this issue Sep 30, 2021 · 1 comment
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@davedelong
Copy link

Previous ID SR-15265
Radar rdar://problem/83741546
Original Reporter @davedelong
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 40b0a063f8cd60ce1bf23223e06f45e9

Issue Description:

Given that things like string interpolation and result builders are syntactic transformations, I would've expected this to work:

struct Call1 {
    func callAsFunction() { print("hello, 1") }
}

struct Call2 {
    var callAsFunction: () -> Void
}

let c1 = Call1()
c1()
// should be rewritten to be c1.callAsFunction()

let c2 = Call2(callAsFunction: { print("hello, 2") })
c2() // error: Cannot call value of non-function type 'Call2'
// should be rewritten to be c2.callAsFunction()
@beccadax
Copy link
Contributor

@swift-ci create

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants