Skip to content

Commit ef6ed95

Browse files
committed
Fix #9392: Allow override no-params java-defined methods which have a field with same name
s
1 parent 7427fb8 commit ef6ed95

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,20 @@ object OverridingPairs {
4040
* relative to <base>.this do
4141
*/
4242
protected def matches(sym1: Symbol, sym2: Symbol): Boolean =
43-
sym1.isType || sym1.asSeenFrom(self).matches(sym2.asSeenFrom(self))
43+
// Similar to dotty.tools.dotc.core.Denotations.SingleDenotation.matches
44+
// But in case MethodNotAMethodMatch, sym2 must not be JavaDefined
45+
def symMatches =
46+
val d1 = sym1.asSeenFrom(self)
47+
val d2 = sym2.asSeenFrom(self)
48+
import Signature.MatchDegree._
49+
d1.signature.matchDegree(d2.signature) match
50+
case FullMatch => true
51+
case MethodNotAMethodMatch => !ctx.erasedTypes && !d2.symbol.is(JavaDefined)
52+
case ParamMatch => !ctx.erasedTypes && d1.info.matches(d2.info)
53+
case NoMatch => false
54+
55+
sym1.isType || symMatches
56+
end matches
4457

4558
/** The symbols that can take part in an overriding pair */
4659
private val decls = {

0 commit comments

Comments
 (0)