-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
The Note in the doc comment for class ImplicitShortcuts explains why this is necessary.
There was a problem hiding this 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._ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
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.