Detect InsertedApply on Apply to break synthetic apply loops, not just Select#25463
Detect InsertedApply on Apply to break synthetic apply loops, not just Select#25463SolalPirelli wants to merge 3 commits intoscala:mainfrom
InsertedApply on Apply to break synthetic apply loops, not just Select#25463Conversation
| def apply(): Fill[N] => Any = ??? | ||
|
|
||
| Fun[1]()(???) | ||
| Fun[1]()()(???) |
There was a problem hiding this comment.
As discussed on Slack, per §6.6 of the language ref, apply should only be used if there are parameters. This is the only positive test I could find in which this was happening.
There was a problem hiding this comment.
oops, thanks, added
| } | ||
| extension[N <: Int] (f: Fun[N]) | ||
| def apply: Fill[N] => Any = ??? | ||
| def apply(): Fill[N] => Any = ??? |
There was a problem hiding this comment.
https://github.com/scala/scala3/pull/25463/changes#r2906064294
So defining def apply is not allowed?
There was a problem hiding this comment.
per conversation on Slack, no, parameterless apply should not be used since the language reference only talks about parameterized insertions of apply, see the recent thread in compiler-development
There was a problem hiding this comment.
Okay, then can we have a clear test that shows explicitly this. Something like:
object A:
def apply: Int = ???
val x: Int = A // error: must call apply explicitlyThis test and the other have too many elements in them that it is not clear what their purpose is.
There was a problem hiding this comment.
It would be nice to have some systematic tests of language features, yeah, but for that we'd need an unambiguous language reference first, the slack thread already mentions some corner cases like "what if apply is of a custom function-like type". :/
There was a problem hiding this comment.
but for that we'd need an unambiguous language reference first
I agree. If that is intended to be the case, and if you find the wording to be ambiguous, you can also update the wording to at least cover this case?
bf3bd0a to
338092a
Compare
Fixes #24782
How much have your relied on LLM-based tools in this contribution?
not
How was the solution tested?
new automated test