diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t7235.check | 4 | ||||
-rw-r--r-- | test/files/neg/t7235.scala | 14 | ||||
-rw-r--r-- | test/files/neg/t7238.check | 6 | ||||
-rw-r--r-- | test/files/neg/t7238.scala | 7 | ||||
-rw-r--r-- | test/files/pos/t7226.scala | 26 | ||||
-rw-r--r-- | test/files/pos/t7233.scala | 14 | ||||
-rw-r--r-- | test/files/pos/t7233b.scala | 8 | ||||
-rw-r--r-- | test/files/pos/t7234.scala | 15 | ||||
-rw-r--r-- | test/files/pos/t7234b.scala | 20 | ||||
-rw-r--r-- | test/files/run/repl-colon-type.check | 21 | ||||
-rw-r--r-- | test/files/run/repl-colon-type.scala | 4 | ||||
-rw-r--r-- | test/files/run/t5710-1.check | 1 | ||||
-rw-r--r-- | test/files/run/t5710-1.scala | 15 | ||||
-rw-r--r-- | test/files/run/t5710-2.check | 1 | ||||
-rw-r--r-- | test/files/run/t5710-2.scala | 15 | ||||
-rw-r--r-- | test/files/run/t6725-1.check | 2 | ||||
-rw-r--r-- | test/files/run/t6725-1.scala | 5 | ||||
-rw-r--r-- | test/files/run/t6725-2.check | 8 | ||||
-rw-r--r-- | test/files/run/t6725-2.scala | 6 | ||||
-rw-r--r-- | test/files/run/t7235.check | 4 | ||||
-rw-r--r-- | test/files/run/t7235.scala | 14 | ||||
-rw-r--r-- | test/files/run/t7240.check | 0 | ||||
-rw-r--r-- | test/files/run/t7240/Macros_1.scala | 48 | ||||
-rw-r--r-- | test/files/run/t7240/Test_2.scala | 3 |
24 files changed, 251 insertions, 10 deletions
diff --git a/test/files/neg/t7235.check b/test/files/neg/t7235.check new file mode 100644 index 0000000000..357a3dfd83 --- /dev/null +++ b/test/files/neg/t7235.check @@ -0,0 +1,4 @@ +t7235.scala:9: error: implementation restriction: cannot reify refinement type trees with non-empty bodies + val Block(List(ValDef(_, _, tpt: CompoundTypeTree, _)), _) = reify{ val x: C { def x: Int } = ??? }.tree + ^ +one error found diff --git a/test/files/neg/t7235.scala b/test/files/neg/t7235.scala new file mode 100644 index 0000000000..cfebad3fae --- /dev/null +++ b/test/files/neg/t7235.scala @@ -0,0 +1,14 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +class C + +object Test extends App { + val Block(List(ValDef(_, _, tpt: CompoundTypeTree, _)), _) = reify{ val x: C { def x: Int } = ??? }.tree + println(tpt) + println(tpt.templ.parents) + println(tpt.templ.self) + println(tpt.templ.body) +} diff --git a/test/files/neg/t7238.check b/test/files/neg/t7238.check new file mode 100644 index 0000000000..b87f83ff65 --- /dev/null +++ b/test/files/neg/t7238.check @@ -0,0 +1,6 @@ +t7238.scala:6: error: type mismatch; + found : Seq[Any] + required: Seq[String] + c.c()(Seq[Any](): _*) + ^ +one error found diff --git a/test/files/neg/t7238.scala b/test/files/neg/t7238.scala new file mode 100644 index 0000000000..d42dc8d385 --- /dev/null +++ b/test/files/neg/t7238.scala @@ -0,0 +1,7 @@ +trait Main { + trait C { + def c(x: Any = 0)(bs: String*) + } + def c: C + c.c()(Seq[Any](): _*) +} diff --git a/test/files/pos/t7226.scala b/test/files/pos/t7226.scala new file mode 100644 index 0000000000..06f0c95dc4 --- /dev/null +++ b/test/files/pos/t7226.scala @@ -0,0 +1,26 @@ +trait HK { + type Rep[X] + + // okay + def unzip2[A, B](ps: Rep[List[(A, B)]]) + unzip2(null.asInstanceOf[Rep[List[(Int, String)]]]) + + // okay + def unzipHK[A, B, C[_]](ps: Rep[C[(A, B)]]) + unzipHK(null.asInstanceOf[Rep[List[(Int, String)]]]) + + def unzipHKRet0[A, C[_]](ps: C[A]): C[Int] + def ls: List[String] + unzipHKRet0(ls) + + // fail + def unzipHKRet[A, C[_]](ps: Rep[C[A]]): Rep[C[Int]] + def rls: Rep[List[String]] + unzipHKRet(rls) +} + +trait HK1 { + type Rep[A] + def unzip1[A, B, C[_]](ps: Rep[C[(A, B)]]): (Rep[C[A]], Rep[C[B]]) + def doUnzip1[A, B](ps: Rep[List[(A, B)]]) = unzip1(ps) +} diff --git a/test/files/pos/t7233.scala b/test/files/pos/t7233.scala new file mode 100644 index 0000000000..ae15c08c35 --- /dev/null +++ b/test/files/pos/t7233.scala @@ -0,0 +1,14 @@ +object Foo { + def bar(i: Int) = i + + def ol(i: Int) = i + def ol(i: String) = i +} +object Test { + import Foo.{ bar => quux, toString => bar, ol => olRenamed} + + val f1 = quux _ + val f1Typed: (Int => Int) = f1 + + val f2: String => String = olRenamed _ +} diff --git a/test/files/pos/t7233b.scala b/test/files/pos/t7233b.scala new file mode 100644 index 0000000000..927c7fcfd1 --- /dev/null +++ b/test/files/pos/t7233b.scala @@ -0,0 +1,8 @@ +object Test { + // crash + def foo(a: Any) = { import a.{toString => toS}; toS } + + // okay + def ok1(a: String) = { import a.{isInstanceOf => iio}; iio[String] } + def ok2(a: Int) = { import a.{toInt => ti}; ti } +} diff --git a/test/files/pos/t7234.scala b/test/files/pos/t7234.scala new file mode 100644 index 0000000000..59a233d835 --- /dev/null +++ b/test/files/pos/t7234.scala @@ -0,0 +1,15 @@ +trait Main { + trait A { + type B + } + trait C { + def c(a: A, x: Int = 0)(b: a.B) + } + def c: C + def d(a: A, x: Int = 0)(b: a.B) + + def ok1(a: A)(b: a.B) = c.c(a, 42)(b) + def ok2(a: A)(b: a.B) = d(a)(b) + + def fail(a: A)(b: a.B) = c.c(a)(b) +} diff --git a/test/files/pos/t7234b.scala b/test/files/pos/t7234b.scala new file mode 100644 index 0000000000..fee98e87a8 --- /dev/null +++ b/test/files/pos/t7234b.scala @@ -0,0 +1,20 @@ +trait Main { + trait A { + type B + def b: B + } + trait C { + def c(a: A, x: Int = 0)(b: => a.B, bs: a.B*) + def d(a: A = null, x: Int = 0)(b1: => a.B = a.b, b2: a.B = a.b) + } + def c: C + def ok(a: A)(b: a.B) = c.c(a, 42)(b) + def fail(a: A)(b: a.B) = c.c(a)(b) + def fail2(a: A)(b: a.B) = c.c(a)(b, b) + def fail3(a: A)(b: a.B) = c.c(a)(b, Seq[a.B](b): _*) + + def fail4(a: A)(b: a.B) = c.d(a)() + def fail5(a: A)(b: a.B) = c.d(a)(b1 = a.b) + def fail6(a: A)(b: a.B) = c.d(a)(b2 = a.b) + def fail7(a: A)(b: a.B) = c.d()() +} diff --git a/test/files/run/repl-colon-type.check b/test/files/run/repl-colon-type.check index 56ddd74375..0cb18e989a 100644 --- a/test/files/run/repl-colon-type.check +++ b/test/files/run/repl-colon-type.check @@ -4,12 +4,6 @@ Type :help for more information. scala> scala> :type List[1, 2, 3] -<console>:2: error: identifier expected but integer literal found. - List[1, 2, 3] - ^ -<console>:3: error: ']' expected but '}' found. - } - ^ <console>:1: error: identifier expected but integer literal found. List[1, 2, 3] ^ @@ -45,12 +39,9 @@ scala> :type lazy val f = 5 Int scala> :type protected lazy val f = 5 -<console>:2: error: illegal start of statement (no modifiers allowed here) - protected lazy val f = 5 - ^ <console>:5: error: lazy value f cannot be accessed in object $iw Access to protected value f not permitted because - enclosing object $eval in package $line19 is not a subclass of + enclosing object $eval in package $line13 is not a subclass of object $iw where target is defined lazy val $result = `f` ^ @@ -223,4 +214,14 @@ PolyType( scala> +scala> // SI-7132 - :type doesn't understand Unit + +scala> :type () +Unit + +scala> :type println("side effect!") +Unit + +scala> + scala> diff --git a/test/files/run/repl-colon-type.scala b/test/files/run/repl-colon-type.scala index c055b215c2..8cf81a6afe 100644 --- a/test/files/run/repl-colon-type.scala +++ b/test/files/run/repl-colon-type.scala @@ -26,6 +26,10 @@ object Test extends ReplTest { |:type -v Nil.combinations _ |:type -v def f[T <: AnyVal] = List[T]().combinations _ |:type -v def f[T, U >: T](x: T, y: List[U]) = x :: y + | + |// SI-7132 - :type doesn't understand Unit + |:type () + |:type println("side effect!") """.stripMargin } diff --git a/test/files/run/t5710-1.check b/test/files/run/t5710-1.check new file mode 100644 index 0000000000..eac2025aeb --- /dev/null +++ b/test/files/run/t5710-1.check @@ -0,0 +1 @@ +evaluated = (abc,abc) diff --git a/test/files/run/t5710-1.scala b/test/files/run/t5710-1.scala new file mode 100644 index 0000000000..12bd858e06 --- /dev/null +++ b/test/files/run/t5710-1.scala @@ -0,0 +1,15 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + val code = reify { + val (x, y) = ("abc": Any) match { case x => (x, x) } + (x, y) + }; + + val toolbox = cm.mkToolBox() + val evaluated = toolbox.eval(code.tree) + println("evaluated = " + evaluated) +}
\ No newline at end of file diff --git a/test/files/run/t5710-2.check b/test/files/run/t5710-2.check new file mode 100644 index 0000000000..eac2025aeb --- /dev/null +++ b/test/files/run/t5710-2.check @@ -0,0 +1 @@ +evaluated = (abc,abc) diff --git a/test/files/run/t5710-2.scala b/test/files/run/t5710-2.scala new file mode 100644 index 0000000000..6d2129cca2 --- /dev/null +++ b/test/files/run/t5710-2.scala @@ -0,0 +1,15 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + val code = reify { + val (x, y) = "abc" match { case x => (x, x) } + (x, y) + }; + + val toolbox = cm.mkToolBox() + val evaluated = toolbox.eval(code.tree) + println("evaluated = " + evaluated) +}
\ No newline at end of file diff --git a/test/files/run/t6725-1.check b/test/files/run/t6725-1.check new file mode 100644 index 0000000000..6ed281c757 --- /dev/null +++ b/test/files/run/t6725-1.check @@ -0,0 +1,2 @@ +1 +1 diff --git a/test/files/run/t6725-1.scala b/test/files/run/t6725-1.scala new file mode 100644 index 0000000000..a167ef8aa3 --- /dev/null +++ b/test/files/run/t6725-1.scala @@ -0,0 +1,5 @@ +object Test extends App { + val a = 1 + val s = f"$a%s%n$a%s" + println(s) +}
\ No newline at end of file diff --git a/test/files/run/t6725-2.check b/test/files/run/t6725-2.check new file mode 100644 index 0000000000..3496917ad5 --- /dev/null +++ b/test/files/run/t6725-2.check @@ -0,0 +1,8 @@ + + +aaaa + + +aaaa +aaaa +aaaa diff --git a/test/files/run/t6725-2.scala b/test/files/run/t6725-2.scala new file mode 100644 index 0000000000..e033cf5ea8 --- /dev/null +++ b/test/files/run/t6725-2.scala @@ -0,0 +1,6 @@ +object Test extends App { + println(f"%n") + println(f"aaaa%n") + println(f"%naaaa") + println(f"aaaa%naaaa") +}
\ No newline at end of file diff --git a/test/files/run/t7235.check b/test/files/run/t7235.check new file mode 100644 index 0000000000..9cb9c55a0c --- /dev/null +++ b/test/files/run/t7235.check @@ -0,0 +1,4 @@ +C +List(C) +private val _ = _ +List() diff --git a/test/files/run/t7235.scala b/test/files/run/t7235.scala new file mode 100644 index 0000000000..6039189716 --- /dev/null +++ b/test/files/run/t7235.scala @@ -0,0 +1,14 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +class C + +object Test extends App { + val Block(List(ValDef(_, _, tpt: CompoundTypeTree, _)), _) = reify{ val x: C{} = ??? }.tree + println(tpt) + println(tpt.templ.parents) + println(tpt.templ.self) + println(tpt.templ.body) +} diff --git a/test/files/run/t7240.check b/test/files/run/t7240.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t7240.check diff --git a/test/files/run/t7240/Macros_1.scala b/test/files/run/t7240/Macros_1.scala new file mode 100644 index 0000000000..6465e18760 --- /dev/null +++ b/test/files/run/t7240/Macros_1.scala @@ -0,0 +1,48 @@ +package bakery + +import scala.language.experimental.macros +import scala.reflect.macros.Context + +trait FailureCake { + implicit def liftAnyFails[T: Manifest]: Any = ??? + + // This works + // implicit def liftAny[T]: Any = ??? +} + +object Bakery { + + def failure: Any = macro failureImpl + def failureImpl(c: Context): c.Expr[Any] = { + import c.universe._ + + def dslTrait(dslName: String) = { + val names = dslName.split("\\.").toList.reverse + assert(names.length >= 1, "DSL trait name must be in the valid format. DSL trait name is " + dslName) + + val tpeName = newTypeName(names.head) + names.tail.reverse match { + case head :: tail ⇒ + Select(tail.foldLeft[Tree](Ident(newTermName(head)))((tree, name) ⇒ Select(tree, newTermName(name))), tpeName) + case Nil ⇒ + Ident(tpeName) + } + } + + def composeDSL(transformedBody: Tree) = + ClassDef(Modifiers(), newTypeName("eval"), List(), Template( + List(dslTrait("bakery.FailureCake")), + emptyValDef, + List( + DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), + Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))), + DefDef(Modifiers(), newTermName("main"), List(), List(List()), Ident(newTypeName("Any")), transformedBody)))) + + def constructor = Apply(Select(New(Ident(newTypeName("eval"))), nme.CONSTRUCTOR), List()) + + c.eval(c.Expr[Any]( + c.resetAllAttrs(Block(composeDSL(Literal(Constant(1))), constructor)))) + + c.Expr[Any](Literal(Constant(1))) + } +}
\ No newline at end of file diff --git a/test/files/run/t7240/Test_2.scala b/test/files/run/t7240/Test_2.scala new file mode 100644 index 0000000000..2450bdabf9 --- /dev/null +++ b/test/files/run/t7240/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + bakery.Bakery.failure +}
\ No newline at end of file |