Skip to content

Detect InsertedApply on Apply to break synthetic apply loops, not just Select#25463

Open
SolalPirelli wants to merge 3 commits intoscala:mainfrom
dotty-staging:solal/stackoverflow-24782
Open

Detect InsertedApply on Apply to break synthetic apply loops, not just Select#25463
SolalPirelli wants to merge 3 commits intoscala:mainfrom
dotty-staging:solal/stackoverflow-24782

Conversation

@SolalPirelli
Copy link
Contributor

Fixes #24782

How much have your relied on LLM-based tools in this contribution?

not

How was the solution tested?

new automated test

@SolalPirelli SolalPirelli marked this pull request as ready for review March 9, 2026 15:09
def apply(): Fill[N] => Any = ???

Fun[1]()(???)
Fun[1]()()(???)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkfile is missing :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, thanks, added

}
extension[N <: Int] (f: Fun[N])
def apply: Fill[N] => Any = ???
def apply(): Fill[N] => Any = ???
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 explicitly

This test and the other have too many elements in them that it is not clear what their purpose is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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". :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created #25504

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stackoverflow due to infinite loop in ProtoTypes

3 participants