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

Overload resolution does not prefer method that would need less conversions #14318

Open
NinoFloris opened this issue Nov 14, 2022 · 2 comments
Open
Labels
Area-Compiler-Checking Type checking, attributes and all aspects of logic checking Feature Improvement Needs-RFC
Milestone

Comments

@NinoFloris
Copy link
Contributor

NinoFloris commented Nov 14, 2022

Found in #14302

type M() =
    static member A(m: int64 array, n: int64) = 1
    static member A(m: System.ReadOnlySpan<int64>, n: int64) = 2

let test() = M.A([|10L|], 1)

I would say we should prefer the first overload here instead of failing with an overload error.

https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AbEAzAzgHwBcBPABxgAIBZACgEoKBeAWACgKOLdCBDQgSzAUAtjGHAYUCgEEawkBX4A7Qqgo8oUHsTQUlC5apQNGFAIxtOXXgKGjxkmXIUBlYtzEA6AEoweAEwB5JQxiF1IeJQAeQ1QAPl19RRVUEwoAJjY2DBhCCkIYbnomak9ZAG18MwAGABl8AF1dMzogA=

@T-Gro
Copy link
Member

T-Gro commented Nov 18, 2022

The proposal is, count number of conversions per matching overload (ignoring the "kind" of conversion, nullable and others treated with same weight?). And then only if there is an overload that needs strictly less conversions then all the others, it wins ?

@T-Gro
Copy link
Member

T-Gro commented Nov 18, 2022

I am trying to think of a case where this would be counter-untuive for code reader, i.e. one where the kind of conversion should be considered stronger then a mere count.

@T-Gro T-Gro added Feature Improvement Area-Compiler-Checking Type checking, attributes and all aspects of logic checking and removed Bug labels Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compiler-Checking Type checking, attributes and all aspects of logic checking Feature Improvement Needs-RFC
Projects
Status: New
Development

No branches or pull requests

3 participants