Skip to content

Consistent override checking #9477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions tests/neg/i9109.scala
Original file line number Diff line number Diff line change
@@ -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
}