Skip to content

Fix #2960: Only allow one inserted apply per tree #2962

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

Merged
merged 3 commits into from
Aug 16, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Aug 8, 2017

This fix prevents infinite chains of inserted apply's. Fixes #2960.

odersky added 3 commits August 8, 2017 13:16
This fix prevents infinite chains of inserted apply's. Fixes scala#2960.
The parameter is never queried in current code, just passed along.
@@ -1818,9 +1819,17 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
*/
def tryInsertApplyOrImplicit(tree: Tree, pt: ProtoType)(fallBack: => Tree)(implicit ctx: Context): Tree = {

def isSyntheticApply(tree: Tree): Boolean = tree match {
case tree: Select => tree.getAttachment(InsertedApply).isDefined
Copy link
Member

Choose a reason for hiding this comment

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

Why is an attachment needed instead of checking if the tree selects nme.apply ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. It depends how we want to specity it:

1st choice: An apply is inserted on any expression in function position unless that expression is already an inserted apply.

2nd choice: An apply is inserted on any expression in function position unless that expression is itself an apply selection or call.

Which way should we go? Here's where it makes a difference. Consider the case where we want to expand to

f.apply(...).apply(...)

If we give only one apply, which one should be the inserted one? According to the PR, it must be the second apply. If we followed 2nd choice, this would be rejected instead.

Copy link
Contributor Author

@odersky odersky Aug 9, 2017

Choose a reason for hiding this comment

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

One reason to keep the current PR is that the first apply could be macro generated where the macro returns a map, say. Then it would seem sensical to insert the 2nd apply automatically, as for any other map.

@odersky
Copy link
Contributor Author

odersky commented Aug 16, 2017

Can this go in now?

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

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

LGTM, but adding a need-spec tag so we remember to specify this at some point.

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

Successfully merging this pull request may close these issues.

Dotty compiler crashes with StackOverflowError on symbol literal
2 participants