Skip to content

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.
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