Skip to content

Fix #4753: Ignore implicit shortcuts in RefChecks #4772

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 5 commits into from
Jul 7, 2018

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jul 6, 2018

The Note in the doc comment for class ImplicitShortcuts explains why
this is necessary.

Also, need to special case bridge generation to handle implicit shortcuts correctly.

odersky added 2 commits July 6, 2018 18:04
The Note in the doc comment for class ImplicitShortcuts explains why
this is necessary.
@odersky odersky changed the title Ignore implicit shortcuts in RefChecks Fix #4753: Ignore implicit shortcuts in RefChecks Jul 6, 2018
@odersky odersky requested a review from liufengyun July 6, 2018 16:48
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

Otherwise, LGTM

@@ -314,7 +314,7 @@ object Erasure {
}
}

class Typer extends typer.ReTyper with NoChecking {
class Typer(erasurePhase: DenotTransformer) extends typer.ReTyper with NoChecking {
import Boxing._
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change the type of myErasurePhase in Context to DenotTransformer, so that we don't need to pass the duplicate information around and keep the design consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. But then we have to cast myErasurePhase there, as phaseOf gives a phase, not a DenotTransformer.

@@ -44,8 +44,20 @@ import collection.mutable
* (2) A reference `qual.apply` where `qual` has implicit function type and
* `qual` refers to a method `m` is rewritten to a reference to `m$direct`,
* keeping the same type and value arguments as they are found in `qual`.
*
* Note: The phase adds direct methods for all defined methods with IFT results,
* as well as for all methods that are referenced. It does NOT do an
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I miss something here, the part as well as doesn't read well, are they not included in all defined methods with IFT results?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try to express this clearer.

def directQual(tree: Tree): Tree = tree match {
case Apply(fn, args) => cpy.Apply(tree)(directQual(fn), args)
case TypeApply(fn, args) => cpy.TypeApply(tree)(directQual(fn), args)
case Block(stats, expr) => cpy.Block(tree)(stats, directQual(expr))
case tree: RefTree =>
def rewire(tp: Type, sym: Symbol) = tp match {
case tp: NamedType => tp.prefix.select(sym)
case _ => sym.termRef
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain when the last case is reachable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure. Just to be defensive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try to eliminate the last case. It's better to fail fast if we misunderstand something.

member.isType || {
val mbr = member.symbol
mbr.isSuperAccessor || // not yet synthesized
ShortcutImplicits.isImplicitShortcut(mbr) || // only synthesized when referenced
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment "only synthesized when referenced" is confusing, if I understand correctly direct method trees are always synthesized.

* info transformer that adds these methods everywhere where an IFT returning
* method exists.
* Adding such an info transformer is impractical because it would mean
* that we have to force the types of all members of classes that are referenced.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't quite understand how info transformer works. Maybe a future compiler session on the topic, I know several in the team are interested in the topic.

@odersky odersky merged commit 64bd0fe into scala:master Jul 7, 2018
@allanrenucci allanrenucci deleted the fix-#4753 branch July 7, 2018 12:08
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.

2 participants