Skip to content

Commit ca23f25

Browse files
committed
Address reviewers comments
1 parent 9565ed1 commit ca23f25

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

compiler/src/dotty/tools/dotc/transform/ShortcutImplicits.scala

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ import collection.mutable
4545
* `qual` refers to a method `m` is rewritten to a reference to `m$direct`,
4646
* keeping the same type and value arguments as they are found in `qual`.
4747
*
48-
* Note: The phase adds direct methods for all defined methods with IFT results,
49-
* as well as for all methods that are referenced. It does NOT do an
48+
* Note: The phase adds direct methods for all methods with IFT results that
49+
* are defined in the transformed compilation unit, as well as for all
50+
* methods that are referenced from inside the unit. It does NOT do an
5051
* info transformer that adds these methods everywhere where an IFT returning
51-
* method exists.
52+
* method exists (including in separately compiled classes).
5253
* Adding such an info transformer is impractical because it would mean
5354
* that we have to force the types of all members of classes that are referenced.
5455
* But not adding an info transformer can lead to inconsistencies in RefChecks.
@@ -95,12 +96,8 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisPh
9596
case TypeApply(fn, args) => cpy.TypeApply(tree)(directQual(fn), args)
9697
case Block(stats, expr) => cpy.Block(tree)(stats, directQual(expr))
9798
case tree: RefTree =>
98-
def rewire(tp: Type, sym: Symbol) = tp match {
99-
case tp: NamedType => tp.prefix.select(sym)
100-
case _ => sym.termRef
101-
}
10299
cpy.Ref(tree)(DirectMethodName(tree.name.asTermName))
103-
.withType(rewire(tree.tpe, directMethod(tree.symbol)))
100+
.withType(tree.tpe.asInstanceOf[NamedType].prefix.select(directMethod(tree.symbol)))
104101
}
105102
directQual(tree.qualifier)
106103
} else tree

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ object RefChecks {
450450
member.isType || {
451451
val mbr = member.symbol
452452
mbr.isSuperAccessor || // not yet synthesized
453-
ShortcutImplicits.isImplicitShortcut(mbr) || // only synthesized when referenced
453+
ShortcutImplicits.isImplicitShortcut(mbr) || // only synthesized when referenced, see Note in ShortcutImplicits
454454
mbr.is(JavaDefined) && hasJavaErasedOverriding(mbr)
455455
}
456456

0 commit comments

Comments
 (0)