Skip to content

Commit 5856123

Browse files
authored
Merge pull request #9477 from dotty-staging/fix-override-check
Consistent override checking
2 parents 493f192 + 32a10d5 commit 5856123

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,10 @@ object RefChecks {
762762
*/
763763
def hasMatchingSym(inclazz: Symbol, member: Symbol): Boolean = {
764764

765-
def isSignatureMatch(sym: Symbol) = !sym.isTerm ||
766-
clazz.thisType.memberInfo(sym).matchesLoosely(member.info)
765+
def isSignatureMatch(sym: Symbol) = sym.isType || {
766+
val self = clazz.thisType
767+
sym.asSeenFrom(self).matches(member.asSeenFrom(self))
768+
}
767769

768770
/* The rules for accessing members which have an access boundary are more
769771
* restrictive in java than scala. Since java has no concept of package nesting,

tests/neg/i9109.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class A {
2+
def foo[T <: Cloneable](x: T): Unit = {}
3+
}
4+
class B extends A {
5+
override def foo[T <: Serializable](x: T): Unit = {} // error: method foo has a different signature than the overridden declaration
6+
}

0 commit comments

Comments
 (0)