Skip to content

Fix #9109: More precise override check #9139

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
Jun 9, 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
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object OverridingPairs {
* relative to <base>.this do
*/
protected def matches(sym1: Symbol, sym2: Symbol): Boolean =
sym1.isType || self.memberInfo(sym1).matches(self.memberInfo(sym2))
sym1.isType || sym1.asSeenFrom(self).matches(sym2.asSeenFrom(self))

/** The symbols that can take part in an overriding pair */
private val decls = {
Expand Down
2 changes: 1 addition & 1 deletion tests/explicit-nulls/neg/override-java-object-arg2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Foo {

def bar(): Unit = {
val listener4 = new NotificationListener() { // error: duplicate symbol error
def handleNotification(n: Notification|Null, emitter: Object): Unit = {
def handleNotification(n: Notification|Null, emitter: Object): Unit = { // error
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/erased/erased-case-class.scala
Original file line number Diff line number Diff line change
@@ -1 +1 @@
case class Foo1(erased x: Int) // error
case class Foo1(erased x: Int) // error // error
4 changes: 2 additions & 2 deletions tests/neg/i7597.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
object Test extends App {
def foo[S <: String]: String => Int =
new (String => Int) { def apply(s: S): Int = 0 } // error
new (String => Int) { def apply(s: S): Int = 0 } // error // error

trait Fn[A, B] {
def apply(x: A): B
}

class C[S <: String] extends Fn[String, Int] { // error
def apply(s: S): Int = 0
def apply(s: S): Int = 0 // error
}

foo("")
Expand Down
4 changes: 4 additions & 0 deletions tests/pos-java-interop/i9109/A.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class A {
public <T extends java.io.Serializable> void foo(T x) {}
public <T extends Cloneable> void foo(T x) {}
}
3 changes: 3 additions & 0 deletions tests/pos-java-interop/i9109/B.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class B extends A {
override def foo[T <: Serializable](x: T): Unit = {}
}
7 changes: 7 additions & 0 deletions tests/pos/i9109.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class A {
def foo[T <: Serializable](x: T): Unit = {}
def foo[T <: Cloneable](x: T): Unit = {}
}
class B extends A {
override def foo[T <: Serializable](x: T): Unit = {}
}
2 changes: 1 addition & 1 deletion tests/pos/zoo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait Animal {
trait Cow extends Animal {
type IsMeat = Any
type Food <: Grass
def eats(food: Grass): Unit
def eats(food: Food): Unit
def gets: Food
}
trait Lion extends Animal {
Expand Down