Skip to content

Fix #9462: Identify inserted apply's more reliably in the Dynamic treatment. #9582

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

Conversation

sjrd
Copy link
Member

@sjrd sjrd commented Aug 18, 2020

Previously, identifying when there was an inserted apply, which had to be carried through the Dynamic treatment, was done on a syntactical basis. This would mishandle cases written as

  someContainer.someDynamic()

as it would think that this was an explicit dynamic call for "someDynamic" on someContainer (although someContainer is not even a scala.Dynamic itself, but someContainer.someDynamic is).

We now reliably detect inserted applys by looking at the result of the pre-type-checking of the function part, and testing whether there is a synthetic Select(_, nme.apply) node.

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

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

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Commit Messages

We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).

Please stick to these guidelines for commit messages:

  1. Separate subject from body with a blank line
  2. When fixing an issue, start your commit message with Fix #<ISSUE-NBR>:
  3. Limit the subject line to 72 characters
  4. Capitalize the subject line
  5. Do not end the subject line with a period
  6. Use the imperative mood in the subject line ("Add" instead of "Added")
  7. Wrap the body at 80 characters
  8. Use the body to explain what and why vs. how

adapted from https://chris.beams.io/posts/git-commit

Have an awesome day! ☀️

…c treatment.

Previously, identifying when there was an inserted apply, which had
to be carried through the Dynamic treatment, was done on a
syntactical basis. This would mishandle cases written as

  someContainer.someDynamic()

as it would think that this was an explicit dynamic call for
`"someDynamic"` on `someContainer` (although `someContainer` is not
even a `scala.Dynamic` itself, but `someContainer.someDynamic` is).

We now reliably detect inserted applys by looking at the result of
the pre-type-checking of the function part, and testing whether
there is a synthetic `Select(_, nme.apply)` node.
@sjrd sjrd force-pushed the fix-dynamic-insertion-of-apply-insertion branch from 50f351f to 22010f6 Compare August 19, 2020 07:26
@sjrd sjrd marked this pull request as ready for review August 19, 2020 07:26
@sjrd sjrd requested a review from nicolasstucki August 19, 2020 07:28
@sjrd sjrd changed the title Fix #9462: Identify inserted apply's more reliably in the Dynamic tre… Fix #9462: Identify inserted apply's more reliably in the Dynamic treatment. Aug 19, 2020
* my depth there.
* In the meantime, this makes tests pass.
*/
case TypeApply(fun, _) => !fun.isInstanceOf[Select]
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we also check that the name of fun has a synthetic span?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, no

Copy link
Contributor

Choose a reason for hiding this comment

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

What kind of trees do we get here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Anything. For the test that was failing, it was TypeApply(Ident("qual"), List(oneTArg)).

Copy link
Member Author

Choose a reason for hiding this comment

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

Where I was expecting typedFunPart to have returned TypeApply(Select(Ident("qual"), nme.apply), List(oneTarg)) instead, where the Select node would have had a synthetic span.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we can get a TypeApply(Block(..., Select(..., nme.apply)), ...). I guess those would never be inserted applies.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, in that case, for an inserted apply, the Select should be around the Block, not inside it.

@sjrd sjrd merged commit b1d3e8f into scala:master Aug 19, 2020
@sjrd sjrd deleted the fix-dynamic-insertion-of-apply-insertion branch August 19, 2020 16:32
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.

3 participants