diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-01-11 19:01:09 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-03-24 14:59:26 +1000 |
commit | 3d9d1f6c99d2ee803402b02cccba72086af74b38 (patch) | |
tree | 852b76b3a707cd7e55689863f4e23d2a9dac6795 /test | |
parent | e6e5b146f19ac7bebf046a4bc0cbc0b8ce88a3a1 (diff) | |
download | scala-3d9d1f6c99d2ee803402b02cccba72086af74b38.tar.gz scala-3d9d1f6c99d2ee803402b02cccba72086af74b38.tar.bz2 scala-3d9d1f6c99d2ee803402b02cccba72086af74b38.zip |
SI-9074 Fix generic substitution with package objects, overloading
Takes a leaf out of dotty's book [1] and makes `asSeenFrom`
transparently change the prefix from the package class to the
package object when needed.
This fixes generic subsitution during overload resolution, as
reported in SI-9074.
This subsumes the former fix for SI-6225, which is removed here.
[1] https://github.com/lampepfl/dotty/pull/282
Diffstat (limited to 'test')
-rw-r--r-- | test/files/pos/t9074.scala | 24 | ||||
-rw-r--r-- | test/files/pos/t9074b.scala | 15 |
2 files changed, 39 insertions, 0 deletions
diff --git a/test/files/pos/t9074.scala b/test/files/pos/t9074.scala new file mode 100644 index 0000000000..67db281f54 --- /dev/null +++ b/test/files/pos/t9074.scala @@ -0,0 +1,24 @@ +package blam { + + package foo { + + trait F[T] { + def f(d: Double, t: T): T = ??? + def f(d: Int, t: T): T = ??? + def f(d: String, t: T): T = ??? + + def g[A](a: T): T = ??? + def g(a: Int) = ??? + } + } + + package object foo extends foo.F[Double] { + override def f(d: Double, t: Double): Double = ??? + } +} + +object Test { + import blam._ + foo.f("3", 4.0) + foo.g[Any](1d) : Double +} diff --git a/test/files/pos/t9074b.scala b/test/files/pos/t9074b.scala new file mode 100644 index 0000000000..dadcebf399 --- /dev/null +++ b/test/files/pos/t9074b.scala @@ -0,0 +1,15 @@ +trait Echo [T] { + def echo(t: T): Unit +} + +trait IntEcho extends Echo[Int] { + def echo(t: Int) = println(t) +} + +object echo extends IntEcho +package object echo1 extends IntEcho + +object App extends App { + echo.echo(1) + echo1.echo(1) +} |