Skip to content

Commit 6d43c88

Browse files
committed
Optimization: don't run override checks between Java definitions
This is the same optimization I implemented in Scala 2 a while ago: scala/scala@ba53545 We never run RefChecks on a Java class, but we can run it on a Scala class which inherits from a Java class B which itself inherits from another Java class A. In that case we don't need to check that members of B correctly override members of A.
1 parent 2da2c0b commit 6d43c88

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,14 +474,14 @@ object RefChecks {
474474
* - matching names and types, but different target names
475475
*/
476476
override def matches(sym1: Symbol, sym2: Symbol): Boolean =
477-
sym1.isType
478-
|| {
477+
!(sym1.owner.is(JavaDefined, butNot = Trait) && sym2.owner.is(JavaDefined, butNot = Trait)) && // javac already handles these checks
478+
(sym1.isType || {
479479
val sd1 = sym1.asSeenFrom(clazz.thisType)
480480
val sd2 = sym2.asSeenFrom(clazz.thisType)
481481
sd1.matchesLoosely(sd2)
482482
&& (sym1.hasTargetName(sym2.targetName)
483483
|| compatibleTypes(sym1, sd1.info, sym2, sd2.info))
484-
}
484+
})
485485
end opc
486486

487487
while opc.hasNext do

0 commit comments

Comments
 (0)