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-13844] Function Application not lookup dynamicCallable overload when has callAsFunction function #56242

Open
LucianoPAlmeida opened this issue Nov 12, 2020 · 2 comments
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

@LucianoPAlmeida
Copy link
Collaborator

Previous ID SR-13844
Radar rdar://problem/71330222
Original Reporter @LucianoPAlmeida
Type Bug

Attachment: Download

Environment

Xcode 12.2 Beta 3
Also a near master branch

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

md5: 90e5f387ad08981e91f545789901badf

Issue Description:

As text

@dynamicCallable
struct SR13503_DC_CAF {
  func dynamicallyCall(withArguments: [Int]) -> Int { 0 }
  
  func callAsFunction(_ a: Int) -> Int { 0 }
}

let value_sin_dc_caf = SR13503_DC_CAF()

_ = value_sin_dc_caf(1, 1) // Extra argument in call 

We have a type that is both dynamicCallable and a nominal callable type with a callAsFunction
the compiler seems to stop looking for overloads when it finds callable.

The only overload found is the callAsFunction

  (overload set choice binding $T1 := SR13503_DC_CAF)
  (overload set choice binding $T5 := (Int) -> Int) 

If one removes the `callAsFunction` definition this code type checks fine because it can find the dynamicCallable overload and apply correctly.

I believe this is a bug because it should actually attempt both and this code as it is should type check correctly applying dynamic call overload.

@LucianoPAlmeida
Copy link
Collaborator Author

cc @xedin

@typesanitizer
Copy link

@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