-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Extension method overload not picked up when parameter is conditional #20335
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
Labels
Comments
If I modify second case like this, it compiles.
Mabye the issue is related with type inference. |
also |
Alex1005a
added a commit
to Alex1005a/scala3
that referenced
this issue
May 21, 2025
noti0na1
added a commit
that referenced
this issue
May 22, 2025
…3212) Fixes #20335 The problem seems to be that the compiler does not try to look for extensions and implicit conversions in case of an error, which is generally correct, for performance reasons. But if the argument type does not match the one the function expects, it is correct to try to find an extension with the appropriate type.
tgodzik
pushed a commit
to scala/scala3-lts
that referenced
this issue
May 26, 2025
…ith type mismatch error [Cherry-picked 0632096]
tgodzik
pushed a commit
to scala/scala3-lts
that referenced
this issue
May 26, 2025
[Cherry-picked 6fcab69]
EnzeXing
pushed a commit
to EnzeXing/dotty
that referenced
this issue
May 27, 2025
…ith type mismatch error
EnzeXing
pushed a commit
to EnzeXing/dotty
that referenced
this issue
May 27, 2025
tgodzik
added a commit
to scala/scala3-lts
that referenced
this issue
May 27, 2025
Backport "Fix scala#20335: Try extensions for arguments with type mismatch error" to 3.3 LTS
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
3.4.1
Minimized code
Scastie: https://scastie.scala-lang.org/YNoWvmUYTHSWmgpHzWwj9A
Output
Expectation
The same code compiles well with Scala 2: https://scastie.scala-lang.org/lfVKMgn4RRWpelXheh5rjQ
I tried using
extension
but the result is the same.Note that this happens when there is already a method of the same name defined on the class (
plus
in my example exists inOffsetDateTime
with different parameters).The text was updated successfully, but these errors were encountered: