-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #3989: Check that members of concrete classes are type-correct
This fixes the second half of #3989. Some tests had to be updated or re-classified because they were unsound before.
- Loading branch information
Showing
6 changed files
with
65 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
object Test extends App { | ||
trait A[+X] { def get: X } | ||
case class B[X](x: X) extends A[X] { def get: X = x } | ||
class C[X](x: Any) extends B[Any](x) with A[X] // error: not a legal implementation of `get' | ||
def g(a: A[Int]): Int = a.get | ||
g(new C[Int]("foo")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import java.util.Comparator | ||
|
||
trait Trait1[T] { def foo(arg: Comparator[T]): Unit } | ||
trait Trait1[T] { def foo(arg: Comparator[T]): String } | ||
|
||
trait Trait2[T] extends Trait1[T] { def foo(arg: Comparator[String]): Int = 0 } | ||
|
||
class Class1 extends Trait2[String] { } | ||
class Class1 extends Trait2[String] { } // error: not a legal implementation of `foo' | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
val c = new Class1 | ||
c.foo(Ordering[String]) | ||
val t: Trait1[String] = c | ||
val x: String = t.foo(Ordering[String]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters