Skip to content

Optimize check for by-name expressions#8231

Merged
lrytz merged 1 commit intoscala:2.12.xfrom
retronym:topic/by-name-ref
Jul 16, 2019
Merged

Optimize check for by-name expressions#8231
lrytz merged 1 commit intoscala:2.12.xfrom
retronym:topic/by-name-ref

Conversation

@retronym
Copy link
Member

@retronym retronym commented Jul 16, 2019

Rule out some cases by the type of tree / flags before
looking at the symbol's info.

Rule out some cases by the type of tree of flags before
looking at the symbol's info.
@scala-jenkins scala-jenkins added this to the 2.12.9 milestone Jul 16, 2019
@retronym retronym added the performance the need for speed. usually compiler performance, sometimes runtime performance. label Jul 16, 2019
def isByNameRef(tree: Tree) = (
tree.isTerm
&& (tree.symbol ne null)
&& !(tree.symbol.hasPackageFlag || tree.isInstanceOf[This] || tree.isInstanceOf[Super])
Copy link
Member

Choose a reason for hiding this comment

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

Could we narrow it down to tree.isInstanceOf[Ident]?

Copy link
Member Author

@retronym retronym Jul 16, 2019

Choose a reason for hiding this comment

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

Nope, by-name types flow through generics, so can currently turn up in Select-s as well. There are some existing partest that rely on this.

It's a pretty murky area of the spec/implementation, so I chose a blacklist rather than a whitelist here.

Copy link
Member

Choose a reason for hiding this comment

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

👍 thanks!

@lrytz lrytz merged commit 2c51aee into scala:2.12.x Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance the need for speed. usually compiler performance, sometimes runtime performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants