diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala index afb5e1a03b41..ba6302f335de 100644 --- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala @@ -762,8 +762,10 @@ object RefChecks { */ def hasMatchingSym(inclazz: Symbol, member: Symbol): Boolean = { - def isSignatureMatch(sym: Symbol) = !sym.isTerm || - clazz.thisType.memberInfo(sym).matchesLoosely(member.info) + def isSignatureMatch(sym: Symbol) = sym.isType || { + val self = clazz.thisType + sym.asSeenFrom(self).matches(member.asSeenFrom(self)) + } /* The rules for accessing members which have an access boundary are more * restrictive in java than scala. Since java has no concept of package nesting, diff --git a/tests/neg/i9109.scala b/tests/neg/i9109.scala new file mode 100644 index 000000000000..7f17a24ffd54 --- /dev/null +++ b/tests/neg/i9109.scala @@ -0,0 +1,6 @@ +class A { + def foo[T <: Cloneable](x: T): Unit = {} +} +class B extends A { + override def foo[T <: Serializable](x: T): Unit = {} // error: method foo has a different signature than the overridden declaration +}