-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix:Resolve ambiguous overload between empty param list and v… #24873
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
base: main
Are you sure you want to change the base?
Fix:Resolve ambiguous overload between empty param list and v… #24873
Conversation
ff7ffe2 to
dd76912
Compare
|
Just for fun, alternative syntax for the boolean expression: experimenting with "selection of match" and also " The test includes a top-level expression, but really the expectation is that other tests should fail. The question to ask here is whether the fix still obeys item Worth adding that github allows opening a "draft" PR, to work out the kinks. |
odersky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the reasoning behind the PR sound, the code can be simplified.
| // When tp1 is nullary (empty parameter list), it's as good as tp2 only if | ||
| // tp2 is not a varargs method (which is less specific than an explicit empty list) | ||
| tp2 match | ||
| case tp2: MethodType => !tp2.isVarArgsMethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isVarArgsMethod works also for non-method types, so the whole logic can be simplified to
tp1.paramInfos.isEmpty
&& tp2.isInstanceOf[LambdaType]
&& !tp2.isVarArgsMethod
odersky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick fix!
|
The test still doesn't compile, and I'm afraid the regression test is already in at #24876. I wasn't convinced on the ticket that the fix is desirable, and I'm curious to see if it also changes the "ambiguous extension" test. |
|
@som-snytt Regarding #24876 , I see your concern about whether this fix is desirable. The core issue I was addressing is that when choosing between an empty parameter list () and a varargs method, the empty list should be preferred as more specific. However, I understand this might have broader implications. I'll check how this change affects the "ambiguous extension" test you mentioned. Could you point me to that test file so I can verify the behavior? |
tests/pos/i24871.scala
Outdated
| for | ||
| List(x) <- X()(.0) | ||
| yield | ||
| x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test file is an ordinary compilation unit, so a top-level expression isn't supported.
|
@krrish175-byte At the bottom of the page, "Some checks..." lists jobs, with a red x at the failed one. Clicking that shows results, with the failure somewhere. |
|
@som-snytt |
|
Hi, any update on this pr? |
|
As you can see from "checks were not successful", the test still fails. Also, the regression test You must run the test under sbt with Where The code comment is not correct. The ticket is about several overloads in several param lists, which remains ambiguous. (I think that is correct or reasonable.) |
Closing issue
closes #24871