diff options
Diffstat (limited to 'test/files/pos')
-rw-r--r-- | test/files/pos/alladin763.scala | 37 | ||||
-rw-r--r-- | test/files/pos/t6778.scala | 5 | ||||
-rw-r--r-- | test/files/pos/t7784.scala | 13 | ||||
-rw-r--r-- | test/files/pos/t8462.scala | 11 | ||||
-rw-r--r-- | test/files/pos/t8862a.scala | 47 | ||||
-rw-r--r-- | test/files/pos/t8862b.scala | 12 | ||||
-rw-r--r-- | test/files/pos/t9074.scala | 24 | ||||
-rw-r--r-- | test/files/pos/t9074b.scala | 15 | ||||
-rw-r--r-- | test/files/pos/t9131.scala | 12 |
9 files changed, 176 insertions, 0 deletions
diff --git a/test/files/pos/alladin763.scala b/test/files/pos/alladin763.scala new file mode 100644 index 0000000000..29c9b25318 --- /dev/null +++ b/test/files/pos/alladin763.scala @@ -0,0 +1,37 @@ +// Test from http://lrytz.github.io/scala-aladdin-bugtracker/displayItem.do%3Fid=763.html +// and expanded with package object variants + + +trait Foo { type T; def apply() : T } +object e extends Foo { type T = Int; def apply() = 42 } + +package p { + trait T[X] { def O : { def apply(): X } } + object `package` extends T[Int] { + def O: { def apply(): Int } = new { def apply(): Int = 42 } + } + + object Test { + val x: Int = O() + } +} + +object Test { + + val f = new Foo { type T = Int; def apply() = 42 } + + def main(args: Array[String]): Unit = { + val g = new Foo { type T = Int; def apply() = 42 } + + (e: Foo)() + val ee: Int = e() + + (f: Foo)() + val ff: Int = f() + + (g: Foo)() + val gg: Int = g() + + val pp: Int = p.O() + } +} diff --git a/test/files/pos/t6778.scala b/test/files/pos/t6778.scala new file mode 100644 index 0000000000..b7483c8fce --- /dev/null +++ b/test/files/pos/t6778.scala @@ -0,0 +1,5 @@ +object test extends AnyRef with App { + // Check that random can be called with parenthesis. + scala.math.random() +} + diff --git a/test/files/pos/t7784.scala b/test/files/pos/t7784.scala new file mode 100644 index 0000000000..e6824a4203 --- /dev/null +++ b/test/files/pos/t7784.scala @@ -0,0 +1,13 @@ +object Test { + final val a = "" + var b: a.type = a + b = a + + final val x = classOf[Object] + var y: x.type = x + y = x + + final val e = Thread.State.NEW + var e1: e.type = e + e1 = e +} diff --git a/test/files/pos/t8462.scala b/test/files/pos/t8462.scala new file mode 100644 index 0000000000..6946cf8e5e --- /dev/null +++ b/test/files/pos/t8462.scala @@ -0,0 +1,11 @@ + +trait ConstantOps { + def exprs = ( + 1 << 2L : Int, // was: error: type mismatch; found : Long(4L) + 64 >> 2L : Int, // was: error: type mismatch; found : Long(4L) + 64 >>> 2L : Int, // was: error: type mismatch; found : Long(4L) + 'a' << 2L : Int, + 'a' >> 2L : Int, + 'a'>>> 2L : Int + ) +} diff --git a/test/files/pos/t8862a.scala b/test/files/pos/t8862a.scala new file mode 100644 index 0000000000..f9576707ba --- /dev/null +++ b/test/files/pos/t8862a.scala @@ -0,0 +1,47 @@ +package p { + + abstract class C[A] { + def x: A + implicit def oops: A = x + implicit def oopso: Option[A] = None + } + + package q { + + class Oops + + object `package` extends C[Oops] { + override def x = new Oops + } + + object Blah { + oops + oopso + + // implicits found in enclosing context + implicitly[Oops] + implicitly[Option[Oops]] + } + } +} + +package other { + + object Blah { + // implicits found through this import + import p.q._ + + oops + oopso + + implicitly[Oops] + implicitly[Option[Oops]] + } + + + object Blee { + // implicits found through the companion implicits + implicitly[p.q.Oops] + implicitly[Option[p.q.Oops]] + } +} diff --git a/test/files/pos/t8862b.scala b/test/files/pos/t8862b.scala new file mode 100644 index 0000000000..8be7fb5fab --- /dev/null +++ b/test/files/pos/t8862b.scala @@ -0,0 +1,12 @@ +package p { + trait T[X] { def O : { def apply(): X } } + object `package` extends T[Int] { + def O: { def apply(): Int } = new { def apply(): Int = 42 } + } + + object Test { + def main(args: Array[String]): Unit = { + val x: Int = O() + } + } +} 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) +} diff --git a/test/files/pos/t9131.scala b/test/files/pos/t9131.scala new file mode 100644 index 0000000000..1a186a0a24 --- /dev/null +++ b/test/files/pos/t9131.scala @@ -0,0 +1,12 @@ +class Test { + + def byNameFunc(f: (=> (() => Any)) => Any): Unit = () + + def test = { + // "value apply is not a member of => () => Any" + byNameFunc(z => z()) + // okay + byNameFunc(z => z.apply()) + byNameFunc(z => {val f = z; f()}) + } +} |