diff options
Diffstat (limited to 'test/files')
310 files changed, 1816 insertions, 2121 deletions
diff --git a/test/files/continuations-neg/function0.check b/test/files/continuations-neg/function0.check deleted file mode 100644 index 0a66763a0f..0000000000 --- a/test/files/continuations-neg/function0.check +++ /dev/null @@ -1,6 +0,0 @@ -function0.scala:11: error: type mismatch; - found : () => Int @scala.util.continuations.cpsParam[Int,Int] - required: () => Int - val g: () => Int = f - ^ -one error found diff --git a/test/files/continuations-neg/function0.scala b/test/files/continuations-neg/function0.scala deleted file mode 100644 index 4112ee3835..0000000000 --- a/test/files/continuations-neg/function0.scala +++ /dev/null @@ -1,16 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def main(args: Array[String]): Any = { - - val f = () => shift { k: (Int=>Int) => k(7) } - val g: () => Int = f - - println(reset(g())) - } - -}
\ No newline at end of file diff --git a/test/files/continuations-neg/function2.check b/test/files/continuations-neg/function2.check deleted file mode 100644 index 4b1a6227bc..0000000000 --- a/test/files/continuations-neg/function2.check +++ /dev/null @@ -1,6 +0,0 @@ -function2.scala:11: error: type mismatch; - found : () => Int - required: () => Int @scala.util.continuations.cpsParam[Int,Int] - val g: () => Int @cps[Int] = f - ^ -one error found diff --git a/test/files/continuations-neg/function2.scala b/test/files/continuations-neg/function2.scala deleted file mode 100644 index ae0fda509d..0000000000 --- a/test/files/continuations-neg/function2.scala +++ /dev/null @@ -1,16 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def main(args: Array[String]): Any = { - - val f = () => 7 - val g: () => Int @cps[Int] = f - - println(reset(g())) - } - -}
\ No newline at end of file diff --git a/test/files/continuations-neg/function3.check b/test/files/continuations-neg/function3.check deleted file mode 100644 index 4705ad9ed9..0000000000 --- a/test/files/continuations-neg/function3.check +++ /dev/null @@ -1,6 +0,0 @@ -function3.scala:10: error: type mismatch; - found : Int @scala.util.continuations.cpsParam[Int,Int] - required: Int - val g: () => Int = () => shift { k: (Int=>Int) => k(7) } - ^ -one error found diff --git a/test/files/continuations-neg/function3.scala b/test/files/continuations-neg/function3.scala deleted file mode 100644 index 0c3f1667e5..0000000000 --- a/test/files/continuations-neg/function3.scala +++ /dev/null @@ -1,15 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def main(args: Array[String]): Any = { - - val g: () => Int = () => shift { k: (Int=>Int) => k(7) } - - println(reset(g())) - } - -}
\ No newline at end of file diff --git a/test/files/continuations-neg/infer2.check b/test/files/continuations-neg/infer2.check deleted file mode 100644 index d92bc9c572..0000000000 --- a/test/files/continuations-neg/infer2.check +++ /dev/null @@ -1,4 +0,0 @@ -infer2.scala:14: error: illegal answer type modification: scala.util.continuations.cpsParam[String,Int] andThen scala.util.continuations.cpsParam[String,Int] - test { sym(); sym() } - ^ -one error found diff --git a/test/files/continuations-neg/infer2.scala b/test/files/continuations-neg/infer2.scala deleted file mode 100644 index a890ac1fc4..0000000000 --- a/test/files/continuations-neg/infer2.scala +++ /dev/null @@ -1,19 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def test(x: => Int @cpsParam[String,Int]) = 7 - - def sym() = shift { k: (Int => String) => 9 } - - - def main(args: Array[String]): Any = { - test { sym(); sym() } - } - -} - - diff --git a/test/files/continuations-neg/lazy.check b/test/files/continuations-neg/lazy.check deleted file mode 100644 index 3c460546be..0000000000 --- a/test/files/continuations-neg/lazy.check +++ /dev/null @@ -1,4 +0,0 @@ -lazy.scala:6: error: implementation restriction: cps annotations not allowed on lazy value definitions - lazy val x = shift((k:Unit=>Unit)=>k()) - ^ -one error found diff --git a/test/files/continuations-neg/lazy.scala b/test/files/continuations-neg/lazy.scala deleted file mode 100644 index 3c8169dd46..0000000000 --- a/test/files/continuations-neg/lazy.scala +++ /dev/null @@ -1,16 +0,0 @@ -import scala.util.continuations._ - -object Test { - - def foo() = { - lazy val x = shift((k:Unit=>Unit)=>k()) - println(x) - } - - def main(args: Array[String]) { - reset { - foo() - } - } - -}
\ No newline at end of file diff --git a/test/files/continuations-neg/t1929.check b/test/files/continuations-neg/t1929.check deleted file mode 100644 index b04a5b977d..0000000000 --- a/test/files/continuations-neg/t1929.check +++ /dev/null @@ -1,6 +0,0 @@ -t1929.scala:8: error: type mismatch; - found : Int @scala.util.continuations.cpsParam[String,String] @scala.util.continuations.cpsSynth - required: Int @scala.util.continuations.cpsParam[Int,String] - reset { - ^ -one error found diff --git a/test/files/continuations-neg/t1929.scala b/test/files/continuations-neg/t1929.scala deleted file mode 100644 index 02eda9170d..0000000000 --- a/test/files/continuations-neg/t1929.scala +++ /dev/null @@ -1,17 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - def main(args : Array[String]) { - reset { - println("up") - val x = shift((k:Int=>String) => k(8) + k(2)) - println("down " + x) - val y = shift((k:Int=>String) => k(3)) - println("down2 " + y) - y + x - } - } -}
\ No newline at end of file diff --git a/test/files/continuations-neg/t2285.check b/test/files/continuations-neg/t2285.check deleted file mode 100644 index d5dff6a4f2..0000000000 --- a/test/files/continuations-neg/t2285.check +++ /dev/null @@ -1,6 +0,0 @@ -t2285.scala:9: error: type mismatch; - found : Int @scala.util.continuations.cpsParam[String,String] @scala.util.continuations.cpsSynth - required: Int @scala.util.continuations.cpsParam[Int,String] - def foo() = reset { bar(); 7 } - ^ -one error found diff --git a/test/files/continuations-neg/t2285.scala b/test/files/continuations-neg/t2285.scala deleted file mode 100644 index f3c7f4c89c..0000000000 --- a/test/files/continuations-neg/t2285.scala +++ /dev/null @@ -1,11 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - -object Test { - - def bar() = shift { k: (String => String) => k("1") } - - def foo() = reset { bar(); 7 } - -} diff --git a/test/files/continuations-neg/t2949.check b/test/files/continuations-neg/t2949.check deleted file mode 100644 index dd9768807c..0000000000 --- a/test/files/continuations-neg/t2949.check +++ /dev/null @@ -1,6 +0,0 @@ -t2949.scala:13: error: type mismatch; - found : Int - required: ? @scala.util.continuations.cpsParam[List[?],Any] - x * y - ^ -one error found diff --git a/test/files/continuations-neg/t2949.scala b/test/files/continuations-neg/t2949.scala deleted file mode 100644 index ce27c7c0e8..0000000000 --- a/test/files/continuations-neg/t2949.scala +++ /dev/null @@ -1,15 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - -object Test { - - def reflect[A,B](xs : List[A]) = shift{ xs.flatMap[B, List[B]] } - def reify[A, B](x : A @cpsParam[List[A], B]) = reset{ List(x) } - - def main(args: Array[String]): Unit = println(reify { - val x = reflect[Int, Int](List(1,2,3)) - val y = reflect[Int, Int](List(2,4,8)) - x * y - }) -} diff --git a/test/files/continuations-neg/t3628.check b/test/files/continuations-neg/t3628.check deleted file mode 100644 index 6e390558ef..0000000000 --- a/test/files/continuations-neg/t3628.check +++ /dev/null @@ -1,4 +0,0 @@ -t3628.scala:4: error: not found: type Actor - val impl: Actor = actor { - ^ -one error found diff --git a/test/files/continuations-neg/t3628.scala b/test/files/continuations-neg/t3628.scala deleted file mode 100644 index c56e7752c4..0000000000 --- a/test/files/continuations-neg/t3628.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.actors.Actor._ - -object Test { - val impl: Actor = actor { - loop { - react { - case 1 => impl ! 2 - } - } - } -} diff --git a/test/files/continuations-neg/t3718.check b/test/files/continuations-neg/t3718.check deleted file mode 100644 index 659104c1c6..0000000000 --- a/test/files/continuations-neg/t3718.check +++ /dev/null @@ -1,4 +0,0 @@ -t3718.scala:2: error: cannot cps-transform malformed (possibly in shift/reset placement) expression - scala.util.continuations.reset((_: Any).##) - ^ -one error found diff --git a/test/files/continuations-neg/t3718.scala b/test/files/continuations-neg/t3718.scala deleted file mode 100644 index a0fcb9d869..0000000000 --- a/test/files/continuations-neg/t3718.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test { - scala.util.continuations.reset((_: Any).##) -} diff --git a/test/files/continuations-neg/t5314-missing-result-type.check b/test/files/continuations-neg/t5314-missing-result-type.check deleted file mode 100644 index 341e580cf3..0000000000 --- a/test/files/continuations-neg/t5314-missing-result-type.check +++ /dev/null @@ -1,4 +0,0 @@ -t5314-missing-result-type.scala:6: error: method bar has return statement; needs result type - def bar(x:Int) = return foo(x) - ^ -one error found diff --git a/test/files/continuations-neg/t5314-missing-result-type.scala b/test/files/continuations-neg/t5314-missing-result-type.scala deleted file mode 100644 index d7c5043a86..0000000000 --- a/test/files/continuations-neg/t5314-missing-result-type.scala +++ /dev/null @@ -1,13 +0,0 @@ -import scala.util.continuations._ - -object Test extends App { - def foo(x:Int): Int @cps[Int] = x - - def bar(x:Int) = return foo(x) - - reset { - val res = bar(8) - println(res) - res - } -} diff --git a/test/files/continuations-neg/t5314-npe.check b/test/files/continuations-neg/t5314-npe.check deleted file mode 100644 index b5f024aa89..0000000000 --- a/test/files/continuations-neg/t5314-npe.check +++ /dev/null @@ -1,4 +0,0 @@ -t5314-npe.scala:2: error: method bar has return statement; needs result type - def bar(x:Int) = { return x; x } // NPE - ^ -one error found diff --git a/test/files/continuations-neg/t5314-npe.scala b/test/files/continuations-neg/t5314-npe.scala deleted file mode 100644 index 2b5966e07c..0000000000 --- a/test/files/continuations-neg/t5314-npe.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test extends App { - def bar(x:Int) = { return x; x } // NPE -} diff --git a/test/files/continuations-neg/t5314-return-reset.check b/test/files/continuations-neg/t5314-return-reset.check deleted file mode 100644 index 4c817ae14d..0000000000 --- a/test/files/continuations-neg/t5314-return-reset.check +++ /dev/null @@ -1,4 +0,0 @@ -t5314-return-reset.scala:14: error: return expression not allowed, since method calls CPS method - if (rnd.nextInt(100) > 50) return 5 // not allowed, since method is calling `reset` - ^ -one error found diff --git a/test/files/continuations-neg/t5314-return-reset.scala b/test/files/continuations-neg/t5314-return-reset.scala deleted file mode 100644 index df9d58e4cb..0000000000 --- a/test/files/continuations-neg/t5314-return-reset.scala +++ /dev/null @@ -1,21 +0,0 @@ -import scala.util.continuations._ -import scala.util.Random - -object Test extends App { - val rnd = new Random - - def foo(x: Int): Int @cps[Int] = shift { k => k(x) } - - def bar(x: Int): Int @cps[Int] = return foo(x) - - def caller(): Int = { - val v: Int = reset { - val res: Int = bar(8) - if (rnd.nextInt(100) > 50) return 5 // not allowed, since method is calling `reset` - 42 - } - v - } - - caller() -} diff --git a/test/files/continuations-neg/t5314-type-error.check b/test/files/continuations-neg/t5314-type-error.check deleted file mode 100644 index e66c9d833f..0000000000 --- a/test/files/continuations-neg/t5314-type-error.check +++ /dev/null @@ -1,6 +0,0 @@ -t5314-type-error.scala:7: error: type mismatch; - found : Int @scala.util.continuations.cpsParam[Int,Int] - required: Int @scala.util.continuations.cpsParam[String,String] - def bar(x:Int): Int @cps[String] = return foo(x) - ^ -one error found diff --git a/test/files/continuations-neg/t5314-type-error.scala b/test/files/continuations-neg/t5314-type-error.scala deleted file mode 100644 index e36ce6c203..0000000000 --- a/test/files/continuations-neg/t5314-type-error.scala +++ /dev/null @@ -1,17 +0,0 @@ -import scala.util.continuations._ - -object Test extends App { - def foo(x:Int): Int @cps[Int] = shift { k => k(x) } - - // should be a type error - def bar(x:Int): Int @cps[String] = return foo(x) - - def caller(): Unit = { - val v: String = reset { - val res: Int = bar(8) - "hello" - } - } - - caller() -} diff --git a/test/files/continuations-neg/t5445.check b/test/files/continuations-neg/t5445.check deleted file mode 100644 index eb2943b6a6..0000000000 --- a/test/files/continuations-neg/t5445.check +++ /dev/null @@ -1,4 +0,0 @@ -t5445.scala:4: error: cps annotations not allowed on by-value parameters or value definitions - def foo(block: Unit @suspendable ): Unit @suspendable = {} - ^ -one error found diff --git a/test/files/continuations-neg/t5445.scala b/test/files/continuations-neg/t5445.scala deleted file mode 100644 index cb6f8f686d..0000000000 --- a/test/files/continuations-neg/t5445.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala.util.continuations._ - -object Test { - def foo(block: Unit @suspendable ): Unit @suspendable = {} -} diff --git a/test/files/continuations-neg/trycatch2.check b/test/files/continuations-neg/trycatch2.check deleted file mode 100644 index 5ff2838bad..0000000000 --- a/test/files/continuations-neg/trycatch2.check +++ /dev/null @@ -1,7 +0,0 @@ -trycatch2.scala:11: error: only simple cps types allowed in try/catch blocks (found: Int @scala.util.continuations.cpsParam[String,Int]) - def foo1 = try { - ^ -trycatch2.scala:19: error: only simple cps types allowed in try/catch blocks (found: Int @scala.util.continuations.cpsParam[String,Int]) - def foo2 = try { - ^ -two errors found diff --git a/test/files/continuations-neg/trycatch2.scala b/test/files/continuations-neg/trycatch2.scala deleted file mode 100644 index ee0a180ed6..0000000000 --- a/test/files/continuations-neg/trycatch2.scala +++ /dev/null @@ -1,33 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - -object Test { - - def fatal[T]: T = throw new Exception - def cpsIntStringInt = shift { k:(Int=>String) => k(3); 7 } - def cpsIntIntString = shift { k:(Int=>Int) => k(3); "7" } - - def foo1 = try { - fatal[Int] - cpsIntStringInt - } catch { - case ex: Throwable => - cpsIntStringInt - } - - def foo2 = try { - fatal[Int] - cpsIntStringInt - } catch { - case ex: Throwable => - cpsIntStringInt - } - - - def main(args: Array[String]): Unit = { - println(reset { foo1; "3" }) - println(reset { foo2; "3" }) - } - -} diff --git a/test/files/continuations-run/basics.check b/test/files/continuations-run/basics.check deleted file mode 100755 index 54c059fdcb..0000000000 --- a/test/files/continuations-run/basics.check +++ /dev/null @@ -1,2 +0,0 @@ -28 -28
\ No newline at end of file diff --git a/test/files/continuations-run/basics.scala b/test/files/continuations-run/basics.scala deleted file mode 100755 index 07b3de5194..0000000000 --- a/test/files/continuations-run/basics.scala +++ /dev/null @@ -1,23 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def m0() = { - shift((k:Int => Int) => k(k(7))) * 2 - } - - def m1() = { - 2 * shift((k:Int => Int) => k(k(7))) - } - - def main(args: Array[String]) { - - println(reset(m0())) - println(reset(m1())) - - } - -} diff --git a/test/files/continuations-run/function1.check b/test/files/continuations-run/function1.check deleted file mode 100644 index 7f8f011eb7..0000000000 --- a/test/files/continuations-run/function1.check +++ /dev/null @@ -1 +0,0 @@ -7 diff --git a/test/files/continuations-run/function1.scala b/test/files/continuations-run/function1.scala deleted file mode 100644 index 82dfe46c08..0000000000 --- a/test/files/continuations-run/function1.scala +++ /dev/null @@ -1,16 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def main(args: Array[String]): Unit = { - - val f = () => shift { k: (Int=>Int) => k(7) } - val g: () => Int @cps[Int] = f - - println(reset(g())) - } - -} diff --git a/test/files/continuations-run/function4.check b/test/files/continuations-run/function4.check deleted file mode 100644 index c7930257df..0000000000 --- a/test/files/continuations-run/function4.check +++ /dev/null @@ -1 +0,0 @@ -7
\ No newline at end of file diff --git a/test/files/continuations-run/function4.scala b/test/files/continuations-run/function4.scala deleted file mode 100644 index ccb432fe93..0000000000 --- a/test/files/continuations-run/function4.scala +++ /dev/null @@ -1,15 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def main(args: Array[String]): Unit = { - - val g: () => Int @cps[Int] = () => shift { k: (Int=>Int) => k(7) } - - println(reset(g())) - } - -} diff --git a/test/files/continuations-run/function5.check b/test/files/continuations-run/function5.check deleted file mode 100644 index c7930257df..0000000000 --- a/test/files/continuations-run/function5.check +++ /dev/null @@ -1 +0,0 @@ -7
\ No newline at end of file diff --git a/test/files/continuations-run/function5.scala b/test/files/continuations-run/function5.scala deleted file mode 100644 index a83eb80d08..0000000000 --- a/test/files/continuations-run/function5.scala +++ /dev/null @@ -1,15 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def main(args: Array[String]): Unit = { - - val g: () => Int @cps[Int] = () => 7 - - println(reset(g())) - } - -} diff --git a/test/files/continuations-run/function6.check b/test/files/continuations-run/function6.check deleted file mode 100644 index c7930257df..0000000000 --- a/test/files/continuations-run/function6.check +++ /dev/null @@ -1 +0,0 @@ -7
\ No newline at end of file diff --git a/test/files/continuations-run/function6.scala b/test/files/continuations-run/function6.scala deleted file mode 100644 index 13ef88bd9f..0000000000 --- a/test/files/continuations-run/function6.scala +++ /dev/null @@ -1,16 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def main(args: Array[String]): Unit = { - - val g: PartialFunction[Int, Int @cps[Int]] = { case x => 7 } - - println(reset(g(2))) - - } - -} diff --git a/test/files/continuations-run/ifelse0.check b/test/files/continuations-run/ifelse0.check deleted file mode 100644 index f8bc79860d..0000000000 --- a/test/files/continuations-run/ifelse0.check +++ /dev/null @@ -1,2 +0,0 @@ -10 -9
\ No newline at end of file diff --git a/test/files/continuations-run/ifelse0.scala b/test/files/continuations-run/ifelse0.scala deleted file mode 100644 index cbff72c77c..0000000000 --- a/test/files/continuations-run/ifelse0.scala +++ /dev/null @@ -1,18 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def test(x:Int) = if (x <= 7) - shift { k: (Int=>Int) => k(k(k(x))) } - else - shift { k: (Int=>Int) => k(x) } - - def main(args: Array[String]): Unit = { - println(reset(1 + test(7))) - println(reset(1 + test(8))) - } - -} diff --git a/test/files/continuations-run/ifelse1.check b/test/files/continuations-run/ifelse1.check deleted file mode 100644 index 86a3fbc0c1..0000000000 --- a/test/files/continuations-run/ifelse1.check +++ /dev/null @@ -1,4 +0,0 @@ -10 -9 -8 -11
\ No newline at end of file diff --git a/test/files/continuations-run/ifelse1.scala b/test/files/continuations-run/ifelse1.scala deleted file mode 100644 index f8e3cf2ca3..0000000000 --- a/test/files/continuations-run/ifelse1.scala +++ /dev/null @@ -1,25 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def test1(x:Int) = if (x <= 7) - shift { k: (Int=>Int) => k(k(k(x))) } - else - x - - def test2(x:Int) = if (x <= 7) - x - else - shift { k: (Int=>Int) => k(k(k(x))) } - - def main(args: Array[String]): Unit = { - println(reset(1 + test1(7))) - println(reset(1 + test1(8))) - println(reset(1 + test2(7))) - println(reset(1 + test2(8))) - } - -} diff --git a/test/files/continuations-run/ifelse2.check b/test/files/continuations-run/ifelse2.check deleted file mode 100644 index f97a95b08d..0000000000 --- a/test/files/continuations-run/ifelse2.check +++ /dev/null @@ -1,4 +0,0 @@ -abort -() -alive -() diff --git a/test/files/continuations-run/ifelse2.scala b/test/files/continuations-run/ifelse2.scala deleted file mode 100644 index f5ec864a06..0000000000 --- a/test/files/continuations-run/ifelse2.scala +++ /dev/null @@ -1,16 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def test(x:Int) = if (x <= 7) - shift { k: (Unit=>Unit) => println("abort") } - - def main(args: Array[String]): Unit = { - println(reset{ test(7); println("alive") }) - println(reset{ test(8); println("alive") }) - } - -} diff --git a/test/files/continuations-run/ifelse3.check b/test/files/continuations-run/ifelse3.check deleted file mode 100644 index 95b562c8e6..0000000000 --- a/test/files/continuations-run/ifelse3.check +++ /dev/null @@ -1,2 +0,0 @@ -6 -9 diff --git a/test/files/continuations-run/ifelse3.scala b/test/files/continuations-run/ifelse3.scala deleted file mode 100644 index 2c5b5765db..0000000000 --- a/test/files/continuations-run/ifelse3.scala +++ /dev/null @@ -1,21 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def util(x: Boolean) = shift { k: (Boolean=>Int) => k(x) } - - def test(x:Int) = if (util(x <= 7)) - x - 1 - else - x + 1 - - - def main(args: Array[String]): Unit = { - println(reset(test(7))) - println(reset(test(8))) - } - -} diff --git a/test/files/continuations-run/ifelse4.check b/test/files/continuations-run/ifelse4.check deleted file mode 100644 index 2545dd49a0..0000000000 --- a/test/files/continuations-run/ifelse4.check +++ /dev/null @@ -1,4 +0,0 @@ -10 -10 -10 -10 diff --git a/test/files/continuations-run/ifelse4.scala b/test/files/continuations-run/ifelse4.scala deleted file mode 100644 index 46ec15365e..0000000000 --- a/test/files/continuations-run/ifelse4.scala +++ /dev/null @@ -1,31 +0,0 @@ -import scala.util.continuations._ - -object Test { - def sh(x1:Int) = shift( (k: Int => Int) => k(k(k(x1)))) - - def testA(x1: Int): Int @cps[Int] = { - sh(x1) - if (x1==42) x1 else sh(x1) - } - - def testB(x1: Int): Int @cps[Int] = { - if (sh(x1)==43) x1 else x1 - } - - def testC(x1: Int): Int @cps[Int] = { - sh(x1) - if (sh(x1)==44) x1 else x1 - } - - def testD(x1: Int): Int @cps[Int] = { - sh(x1) - if (sh(x1)==45) x1 else sh(x1) - } - - def main(args: Array[String]): Unit = { - println(reset(1 + testA(7))) - println(reset(1 + testB(9))) - println(reset(1 + testC(9))) - println(reset(1 + testD(7))) - } -} diff --git a/test/files/continuations-run/implicit-infer-annotations.check b/test/files/continuations-run/implicit-infer-annotations.check deleted file mode 100644 index e8206c4319..0000000000 --- a/test/files/continuations-run/implicit-infer-annotations.check +++ /dev/null @@ -1,5 +0,0 @@ -Range(5, 6, 7, 8, 9, 10) -Range(5, 6, 7, 8, 9, 10) -15 -List(10, 1, 2, 3) -Range(5, 6, 7, 8, 9, 10) diff --git a/test/files/continuations-run/implicit-infer-annotations.scala b/test/files/continuations-run/implicit-infer-annotations.scala deleted file mode 100644 index 3f0e959f60..0000000000 --- a/test/files/continuations-run/implicit-infer-annotations.scala +++ /dev/null @@ -1,59 +0,0 @@ -import annotation._ - -object A { - class foo[-B,+C] extends StaticAnnotation with TypeConstraint - - def shift[A, B, C](fun: (A => B) => C): A @foo[B, C] = ??? - def reset[A, C](ctx: => (A @foo[A, C])): C = ??? - - def m1 = reset { shift { f: (Int => Range) => f(5) }.to(10) } -} - -object B { - import scala.util.continuations._ - - def m1 = reset { shift { f: (Int => Range) => f(5) }.to(10) } - def m2 = reset { val a = shift { f: (Int => Range) => f(5) } ; a.to(10) } - - val x1 = reset{ - shift{ cont: (Int => Range) => - cont(5) - }.to(10) - } - - val x2 = reset{ - val a = shift{ cont: (Int => Range) => - cont(5) - } - a.to(10) - } // x is now Range(5, 6, 7, 8, 9, 10) - - val x3 = reset{ - shift{ cont: (Int => Int) => - cont(5) - } + 10 - } // x is now 15 - - val x4 = reset{ - 10 :: shift{ cont: (List[Int] => List[Int]) => - cont(List(1, 2, 3)) - } - } // x is List(10, 1, 2, 3) - - val x5 = reset{ - new scala.runtime.RichInt(shift{ cont: (Int => Range) => - cont(5) - }) to 10 - } -} - -object Test { - def main(args: Array[String]): Unit = { - import B._ - println(x1) - println(x2) - println(x3) - println(x4) - println(x5) - } -} diff --git a/test/files/continuations-run/infer1.scala b/test/files/continuations-run/infer1.scala deleted file mode 100644 index 76f746da57..0000000000 --- a/test/files/continuations-run/infer1.scala +++ /dev/null @@ -1,33 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def test(x: => Int @cpsParam[String,Int]) = 7 - - def test2() = { - val x = shift { k: (Int => String) => 9 } - x - } - - def test3(x: => Int @cpsParam[Int,Int]) = 7 - - - def util() = shift { k: (String => String) => "7" } - - def main(args: Array[String]): Unit = { - test { shift { k: (Int => String) => 9 } } - test { shift { k: (Int => String) => 9 }; 2 } -// test { shift { k: (Int => String) => 9 }; util() } <-- doesn't work - test { shift { k: (Int => String) => 9 }; util(); 2 } - - - test { shift { k: (Int => String) => 9 }; { test3(0); 2 } } - - test3 { { test3(0); 2 } } - - } - -} diff --git a/test/files/continuations-run/match0.check b/test/files/continuations-run/match0.check deleted file mode 100644 index f8bc79860d..0000000000 --- a/test/files/continuations-run/match0.check +++ /dev/null @@ -1,2 +0,0 @@ -10 -9
\ No newline at end of file diff --git a/test/files/continuations-run/match0.scala b/test/files/continuations-run/match0.scala deleted file mode 100644 index 8769ed9fcb..0000000000 --- a/test/files/continuations-run/match0.scala +++ /dev/null @@ -1,18 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def test(x:Int) = x match { - case 7 => shift { k: (Int=>Int) => k(k(k(x))) } - case 8 => shift { k: (Int=>Int) => k(x) } - } - - def main(args: Array[String]): Unit = { - println(reset(1 + test(7))) - println(reset(1 + test(8))) - } - -} diff --git a/test/files/continuations-run/match1.check b/test/files/continuations-run/match1.check deleted file mode 100644 index 73053d3f4f..0000000000 --- a/test/files/continuations-run/match1.check +++ /dev/null @@ -1,2 +0,0 @@ -10 -9 diff --git a/test/files/continuations-run/match1.scala b/test/files/continuations-run/match1.scala deleted file mode 100644 index b89fb706b0..0000000000 --- a/test/files/continuations-run/match1.scala +++ /dev/null @@ -1,18 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def test(x:Int) = x match { - case 7 => shift { k: (Int=>Int) => k(k(k(x))) } - case _ => x - } - - def main(args: Array[String]): Unit = { - println(reset(1 + test(7))) - println(reset(1 + test(8))) - } - -} diff --git a/test/files/continuations-run/match2.check b/test/files/continuations-run/match2.check deleted file mode 100644 index cbf91349cc..0000000000 --- a/test/files/continuations-run/match2.check +++ /dev/null @@ -1,2 +0,0 @@ -B -B diff --git a/test/files/continuations-run/match2.scala b/test/files/continuations-run/match2.scala deleted file mode 100644 index 002d9b52dd..0000000000 --- a/test/files/continuations-run/match2.scala +++ /dev/null @@ -1,26 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def test1() = { - val (a, b) = shift { k: (((String,String)) => String) => k("A","B") } - b - } - - case class Elem[T,U](a: T, b: U) - - def test2() = { - val Elem(a,b) = shift { k: (Elem[String,String] => String) => k(Elem("A","B")) } - b - } - - - def main(args: Array[String]): Unit = { - println(reset(test1())) - println(reset(test2())) - } - -}
\ No newline at end of file diff --git a/test/files/continuations-run/patvirt.check b/test/files/continuations-run/patvirt.check deleted file mode 100644 index b5fa014ad3..0000000000 --- a/test/files/continuations-run/patvirt.check +++ /dev/null @@ -1,2 +0,0 @@ -10 -11 diff --git a/test/files/continuations-run/patvirt.scala b/test/files/continuations-run/patvirt.scala deleted file mode 100644 index cfbdda538d..0000000000 --- a/test/files/continuations-run/patvirt.scala +++ /dev/null @@ -1,32 +0,0 @@ -import scala.util.continuations._ - -object Test { - def sh(x1:Int) = shift( (k: Int => Int) => k(k(k(x1)))) - - def test(x1: Int) = { - val o7 = { - val o6 = { - val o3 = - if (7 == x1) Some(x1) - else None - - if (o3.isEmpty) None - else Some(sh(x1)) - } - if (o6.isEmpty) { - val o5 = - if (8 == x1) Some(x1) - else None - - if (o5.isEmpty) None - else Some(sh(x1)) - } else o6 - } - o7.get - } - - def main(args: Array[String]): Unit = { - println(reset(1 + test(7))) - println(reset(1 + test(8))) - } -} diff --git a/test/files/continuations-run/shift-pct.check b/test/files/continuations-run/shift-pct.check deleted file mode 100644 index fb190e770a..0000000000 --- a/test/files/continuations-run/shift-pct.check +++ /dev/null @@ -1,25 +0,0 @@ -d = 1, d2 = 1.0, pct = 1.000 -d = 2, d2 = 4.0, pct = 0.500 -d = 3, d2 = 9.0, pct = 0.333 -d = 4, d2 = 16.0, pct = 0.250 -d = 5, d2 = 25.0, pct = 0.200 -d = 6, d2 = 36.0, pct = 0.167 -d = 7, d2 = 49.0, pct = 0.143 -d = 8, d2 = 64.0, pct = 0.125 -d = 9, d2 = 81.0, pct = 0.111 -d = 10, d2 = 100.0, pct = 0.100 -d = 11, d2 = 121.0, pct = 0.091 -d = 12, d2 = 144.0, pct = 0.083 -d = 13, d2 = 169.0, pct = 0.077 -d = 14, d2 = 196.0, pct = 0.071 -d = 15, d2 = 225.0, pct = 0.067 -d = 16, d2 = 256.0, pct = 0.063 -d = 17, d2 = 289.0, pct = 0.059 -d = 18, d2 = 324.0, pct = 0.056 -d = 19, d2 = 361.0, pct = 0.053 -d = 20, d2 = 400.0, pct = 0.050 -d = 21, d2 = 441.0, pct = 0.048 -d = 22, d2 = 484.0, pct = 0.045 -d = 23, d2 = 529.0, pct = 0.043 -d = 24, d2 = 576.0, pct = 0.042 -d = 25, d2 = 625.0, pct = 0.040 diff --git a/test/files/continuations-run/shift-pct.scala b/test/files/continuations-run/shift-pct.scala deleted file mode 100644 index 7ef9922168..0000000000 --- a/test/files/continuations-run/shift-pct.scala +++ /dev/null @@ -1,30 +0,0 @@ -import scala.util.continuations._ - -object Test { - abstract class IfReturnRepro { - def s1: Double @cpsParam[Any, Unit] - def s2: Double @cpsParam[Any, Unit] - - def p(i: Int): Double @cpsParam[Unit, Any] = { - val px = s1 - val pct = if (px > 100) px else px / s2 - println("pct = %.3f".format(pct)) - pct - } - } - - def main(args: Array[String]) : Unit = { - var d: Double = 0d - def d2 = d * d - - val irr = new IfReturnRepro { - def s1 = shift(f => f(d)) - def s2 = shift(f => f(d2)) - } - 1 to 25 foreach { i => - d = i - print("d = " + i + ", d2 = " + d2 + ", ") - run(irr p i) - } - } -} diff --git a/test/files/continuations-run/t1807.check b/test/files/continuations-run/t1807.check deleted file mode 100644 index 56a6051ca2..0000000000 --- a/test/files/continuations-run/t1807.check +++ /dev/null @@ -1 +0,0 @@ -1
\ No newline at end of file diff --git a/test/files/continuations-run/t1807.scala b/test/files/continuations-run/t1807.scala deleted file mode 100644 index 278b3a9936..0000000000 --- a/test/files/continuations-run/t1807.scala +++ /dev/null @@ -1,14 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - def main(args: Array[String]): Unit = { - val z = reset { - val f: (() => Int @cps[Int]) = () => 1 - f() - } - println(z) - } -}
\ No newline at end of file diff --git a/test/files/continuations-run/t1808.scala b/test/files/continuations-run/t1808.scala deleted file mode 100644 index 125c7c1cdf..0000000000 --- a/test/files/continuations-run/t1808.scala +++ /dev/null @@ -1,10 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - def main(args: Array[String]): Unit = { - reset0 { 0 } - } -}
\ No newline at end of file diff --git a/test/files/continuations-run/t1820.scala b/test/files/continuations-run/t1820.scala deleted file mode 100644 index 7de6ccabef..0000000000 --- a/test/files/continuations-run/t1820.scala +++ /dev/null @@ -1,14 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - def shifted: Unit @suspendable = shift { (k: Unit => Unit) => () } - def test1(b: => Boolean) = { - reset { - if (b) shifted - } - } - def main(args: Array[String]): Unit = test1(true) -} diff --git a/test/files/continuations-run/t1821.check b/test/files/continuations-run/t1821.check deleted file mode 100644 index f7b76115db..0000000000 --- a/test/files/continuations-run/t1821.check +++ /dev/null @@ -1,4 +0,0 @@ -() -() -() -()
\ No newline at end of file diff --git a/test/files/continuations-run/t1821.scala b/test/files/continuations-run/t1821.scala deleted file mode 100644 index 55bf7b6f12..0000000000 --- a/test/files/continuations-run/t1821.scala +++ /dev/null @@ -1,20 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - def suspended[A](x: A): A @suspendable = x - def test1[A](x: A): A @suspendable = suspended(x) match { case x => x } - def test2[A](x: List[A]): A @suspendable = suspended(x) match { case List(x) => x } - - def test3[A](x: A): A @suspendable = x match { case x => x } - def test4[A](x: List[A]): A @suspendable = x match { case List(x) => x } - - def main(args: Array[String]) { - println(reset(test1())) - println(reset(test2(List(())))) - println(reset(test3())) - println(reset(test4(List(())))) - } -} diff --git a/test/files/continuations-run/t2864.check b/test/files/continuations-run/t2864.check deleted file mode 100644 index d411bb7c1a..0000000000 --- a/test/files/continuations-run/t2864.check +++ /dev/null @@ -1 +0,0 @@ -400 diff --git a/test/files/continuations-run/t2864.scala b/test/files/continuations-run/t2864.scala deleted file mode 100644 index 7a2579e45c..0000000000 --- a/test/files/continuations-run/t2864.scala +++ /dev/null @@ -1,30 +0,0 @@ -import scala.util.continuations._ -object Test { - - def double[B](n : Int)(k : Int => B) : B = k(n * 2) - - def main(args : Array[String]) { - reset { - val result1 = shift(double[Unit](100)) - val result2 = shift(double[Unit](result1)) - println(result2) - } - } - - def foo: Int @cps[Int] = { - val a0 = shift((k:Int=>Int) => k(0)) - val x0 = 2 - val a1 = shift((k:Int=>Int) => x0) - 0 - } - -/* - def bar: ControlContext[Int,Int,Int] = { - shiftR((k:Int=>Int) => k(0)).flatMap { a0 => - val x0 = 2 - shiftR((k:Int=>Int) => x0).map { a1 => - 0 - }} - } -*/ -}
\ No newline at end of file diff --git a/test/files/continuations-run/t2934.check b/test/files/continuations-run/t2934.check deleted file mode 100644 index a92586538e..0000000000 --- a/test/files/continuations-run/t2934.check +++ /dev/null @@ -1 +0,0 @@ -List(3, 4, 5) diff --git a/test/files/continuations-run/t2934.scala b/test/files/continuations-run/t2934.scala deleted file mode 100644 index a1b8ca9e04..0000000000 --- a/test/files/continuations-run/t2934.scala +++ /dev/null @@ -1,10 +0,0 @@ -import scala.util.continuations._ - -object Test { - def main(args : Array[String]) { - println(reset { - val x = shift(List(1,2,3).flatMap[Int, List[Int]]) - List(x + 2) - }) - } -} diff --git a/test/files/continuations-run/t3199.check b/test/files/continuations-run/t3199.check deleted file mode 100644 index a065247b8c..0000000000 --- a/test/files/continuations-run/t3199.check +++ /dev/null @@ -1 +0,0 @@ -Right(7) diff --git a/test/files/continuations-run/t3199.scala b/test/files/continuations-run/t3199.scala deleted file mode 100644 index 2cb73c005a..0000000000 --- a/test/files/continuations-run/t3199.scala +++ /dev/null @@ -1,20 +0,0 @@ -import _root_.scala.collection.Seq -import _root_.scala.util.control.Exception -import _root_.scala.util.continuations._ - -object Test { - - trait AbstractResource[+R <: AnyRef] { - def reflect[B] : R @cpsParam[B,Either[Throwable, B]] = shift(acquireFor) - def acquireFor[B](f : R => B) : Either[Throwable, B] = { - import Exception._ - catching(List(classOf[Throwable]) : _*) either (f(null.asInstanceOf[R])) - } - } - - def main(args: Array[String]) : Unit = { - val x = new AbstractResource[String] { } - val result = x.acquireFor( x => 7 ) - println(result) - } - } diff --git a/test/files/continuations-run/t3223.check b/test/files/continuations-run/t3223.check deleted file mode 100644 index ec635144f6..0000000000 --- a/test/files/continuations-run/t3223.check +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/test/files/continuations-run/t3223.scala b/test/files/continuations-run/t3223.scala deleted file mode 100644 index 75613fe5c7..0000000000 --- a/test/files/continuations-run/t3223.scala +++ /dev/null @@ -1,19 +0,0 @@ -import scala.util.continuations._ -object Test { - - def foo(x:Int) = { - try { - throw new Exception - shiftUnit0[Int,Int](7) - } catch { - case ex: Throwable => - val g = (a:Int)=>a - 9 - } - } - - def main(args: Array[String]) { - println(reset(foo(0))) - } - -} diff --git a/test/files/continuations-run/t3225.check b/test/files/continuations-run/t3225.check deleted file mode 100644 index df1a8a9ce4..0000000000 --- a/test/files/continuations-run/t3225.check +++ /dev/null @@ -1,12 +0,0 @@ -8 -8 -9 -9 -8 -9 -8 -8 -9 -9 -8 -9 diff --git a/test/files/continuations-run/t3225.scala b/test/files/continuations-run/t3225.scala deleted file mode 100644 index a0c9c91985..0000000000 --- a/test/files/continuations-run/t3225.scala +++ /dev/null @@ -1,56 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - class Bla { - val x = 8 - def y[T] = 9 - } - -/* - def bla[A] = shift { k:(Bla=>A) => k(new Bla) } -*/ - - def bla1 = shift { k:(Bla=>Bla) => k(new Bla) } - def bla2 = shift { k:(Bla=>Int) => k(new Bla) } - - def fooA = bla2.x - def fooB[T] = bla2.y[T] - - def testMono() = { - println(reset(bla1).x) - println(reset(bla2.x)) - println(reset(bla2.y[Int])) - println(reset(bla2.y)) - println(reset(fooA)) - println(reset(fooB)) - 0 - } - - def blaX[A] = shift { k:(Bla=>A) => k(new Bla) } - - def fooX[A] = blaX[A].x - def fooY[A] = blaX[A].y[A] - - def testPoly() = { - println(reset(blaX[Bla]).x) - println(reset(blaX[Int].x)) - println(reset(blaX[Int].y[Int])) - println(reset(blaX[Int].y)) - println(reset(fooX[Int])) - println(reset(fooY[Int])) - 0 - } - - - // TODO: check whether this also applies to a::shift { k => ... } - - def main(args: Array[String]) { - testMono() - testPoly() - } - -} diff --git a/test/files/continuations-run/t3501.check b/test/files/continuations-run/t3501.check deleted file mode 100644 index 08adcfe27a..0000000000 --- a/test/files/continuations-run/t3501.check +++ /dev/null @@ -1,5 +0,0 @@ -42 -42 -42 -42 -42 diff --git a/test/files/continuations-run/t3501.scala b/test/files/continuations-run/t3501.scala deleted file mode 100644 index c43b3322be..0000000000 --- a/test/files/continuations-run/t3501.scala +++ /dev/null @@ -1,15 +0,0 @@ -import scala.util.continuations._ - -object Test { - def capture(): Int @suspendable = 42 - - def main(args: Array[String]): Unit = reset { - var i = 0 - while (i < 5) { - i += 1 - val y = capture() - val s = y - println(s) - } - } -} diff --git a/test/files/continuations-run/t5314-2.check b/test/files/continuations-run/t5314-2.check deleted file mode 100644 index 35b3c93780..0000000000 --- a/test/files/continuations-run/t5314-2.check +++ /dev/null @@ -1,5 +0,0 @@ -8 -hi -8 -from try -8 diff --git a/test/files/continuations-run/t5314-2.scala b/test/files/continuations-run/t5314-2.scala deleted file mode 100644 index e7e5d46f03..0000000000 --- a/test/files/continuations-run/t5314-2.scala +++ /dev/null @@ -1,44 +0,0 @@ -import scala.util.continuations._ - -class ReturnRepro { - def s1: Int @cps[Any] = shift { k => k(5) } - def caller = reset { println(p(3)) } - def caller2 = reset { println(p2(3)) } - def caller3 = reset { println(p3(3)) } - - def p(i: Int): Int @cps[Any] = { - val v= s1 + 3 - return v - } - - def p2(i: Int): Int @cps[Any] = { - val v = s1 + 3 - if (v > 0) { - println("hi") - return v - } else { - println("hi") - return 8 - } - } - - def p3(i: Int): Int @cps[Any] = { - val v = s1 + 3 - try { - println("from try") - return v - } catch { - case e: Exception => - println("from catch") - return 7 - } - } - -} - -object Test extends App { - val repro = new ReturnRepro - repro.caller - repro.caller2 - repro.caller3 -} diff --git a/test/files/continuations-run/t5314-3.check b/test/files/continuations-run/t5314-3.check deleted file mode 100644 index 71489f097c..0000000000 --- a/test/files/continuations-run/t5314-3.check +++ /dev/null @@ -1,4 +0,0 @@ -enter return expr -8 -hi -8 diff --git a/test/files/continuations-run/t5314-3.scala b/test/files/continuations-run/t5314-3.scala deleted file mode 100644 index c2fe8f6f87..0000000000 --- a/test/files/continuations-run/t5314-3.scala +++ /dev/null @@ -1,27 +0,0 @@ -import scala.util.continuations._ - -class ReturnRepro { - def s1: Int @cpsParam[Any, Unit] = shift { k => k(5) } - def caller = reset { println(p(3)) } - def caller2 = reset { println(p2(3)) } - - def p(i: Int): Int @cpsParam[Unit, Any] = { - val v= s1 + 3 - return { println("enter return expr"); v } - } - - def p2(i: Int): Int @cpsParam[Unit, Any] = { - val v = s1 + 3 - if (v > 0) { - return { println("hi"); v } - } else { - return { println("hi"); 8 } - } - } -} - -object Test extends App { - val repro = new ReturnRepro - repro.caller - repro.caller2 -} diff --git a/test/files/continuations-run/t5314-with-if.check b/test/files/continuations-run/t5314-with-if.check deleted file mode 100644 index 7f8f011eb7..0000000000 --- a/test/files/continuations-run/t5314-with-if.check +++ /dev/null @@ -1 +0,0 @@ -7 diff --git a/test/files/continuations-run/t5314-with-if.scala b/test/files/continuations-run/t5314-with-if.scala deleted file mode 100644 index 5840199a3c..0000000000 --- a/test/files/continuations-run/t5314-with-if.scala +++ /dev/null @@ -1,17 +0,0 @@ -import scala.util.continuations._ - -object Test extends App { - - def foo(x:Int): Int @cps[Int] = 7 - - def bar(x:Int): Int @cps[Int] = { - val v = foo(x) - if (v > 0) - return v - else - return 10 - } - - println(reset { bar(10) }) - -} diff --git a/test/files/continuations-run/t5314.check b/test/files/continuations-run/t5314.check deleted file mode 100644 index 61f5b25dc7..0000000000 --- a/test/files/continuations-run/t5314.check +++ /dev/null @@ -1,14 +0,0 @@ -t5314.scala:34: warning: expression 7 is cps-transformed unexpectedly - def bar3(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else return foo2(x) } - ^ -t5314.scala:35: warning: expression 7 is cps-transformed unexpectedly - def bar4(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else foo2(x) } - ^ -7 -7 -7 -8 -8 -hi -8 -8 diff --git a/test/files/continuations-run/t5314.scala b/test/files/continuations-run/t5314.scala deleted file mode 100644 index e448d8558d..0000000000 --- a/test/files/continuations-run/t5314.scala +++ /dev/null @@ -1,52 +0,0 @@ -import scala.util.continuations._ - -class ReturnRepro { - def s1: Int @cpsParam[Any, Unit] = shift { k => k(5) } - def caller = reset { println(p(3)) } - def caller2 = reset { println(p2(3)) } - - def p(i: Int): Int @cpsParam[Unit, Any] = { - val v= s1 + 3 - return v - } - - def p2(i: Int): Int @cpsParam[Unit, Any] = { - val v = s1 + 3 - if (v > 0) { - println("hi") - return v - } else { - println("hi") - return 8 - } - } -} - -object Test extends App { - def foo(x:Int): Int @cps[Int] = shift { k => k(x) } - - def bar(x:Int): Int @cps[Int] = return foo(x) - - def nocps(x: Int): Int = { return x; x } - - def foo2(x:Int): Int @cps[Int] = 7 - def bar2(x:Int): Int @cps[Int] = { foo2(x); return 7 } - def bar3(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else return foo2(x) } - def bar4(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else foo2(x) } - def bar5(x:Int): Int @cps[Int] = { foo2(x); if (x == 7) return 7 else 8 } - println(reset { bar2(10) }) - println(reset { bar3(10) }) - println(reset { bar4(10) }) - println(reset { bar5(10) }) - - /* original test case */ - val repro = new ReturnRepro - repro.caller - repro.caller2 - - reset { - val res = bar(8) - println(res) - res - } -} diff --git a/test/files/continuations-run/t5472.check b/test/files/continuations-run/t5472.check deleted file mode 100644 index 2468b6b27d..0000000000 --- a/test/files/continuations-run/t5472.check +++ /dev/null @@ -1,25 +0,0 @@ -t5472.scala:12: warning: expression case4(){ - if (x1.ne(null)) - matchEnd3(true) - else - case5() -} is cps-transformed unexpectedly - (location, accessors) <- new ContinuationizedParallelIterable(map) - ^ -t5472.scala:12: warning: expression case5(){ - matchEnd3(false) -} is cps-transformed unexpectedly - (location, accessors) <- new ContinuationizedParallelIterable(map) - ^ -t5472.scala:12: warning: expression matchEnd3(x: Boolean){ - x -} is cps-transformed unexpectedly - (location, accessors) <- new ContinuationizedParallelIterable(map) - ^ -t5472.scala:12: warning: expression matchEnd3(x: Int){ - x -} is cps-transformed unexpectedly - (location, accessors) <- new ContinuationizedParallelIterable(map) - ^ -warning: there were 1 deprecation warning(s); re-run with -deprecation for details -List(23, 23) diff --git a/test/files/continuations-run/t5472.scala b/test/files/continuations-run/t5472.scala deleted file mode 100644 index 060d267544..0000000000 --- a/test/files/continuations-run/t5472.scala +++ /dev/null @@ -1,91 +0,0 @@ -import scala.annotation._ -import scala.util.continuations._ -import java.util.concurrent.atomic._ - -@deprecated("Suppress warnings", since="2.11") -object Test { - def main(args: Array[String]) { - val map = Map("foo" -> 1, "bar" -> 2) - reset { - val mapped = - for { - (location, accessors) <- new ContinuationizedParallelIterable(map) - } yield { - shiftUnit0[Int, Unit](23) - } - println(mapped.toList) - } - } - -final class ContinuationizedParallelIterable[+A](protected val underline: Iterable[A]) { - def toList = underline.toList.sortBy(_.toString) - - final def filter(p: A => Boolean @suspendable): ContinuationizedParallelIterable[A] @suspendable = - shift( - new AtomicInteger(1) with ((ContinuationizedParallelIterable[A] => Unit) => Unit) { - private val results = new AtomicReference[List[A]](Nil) - - @tailrec - private def add(element: A) { - val old = results.get - if (!results.compareAndSet(old, element :: old)) { - add(element) - } - } - - override final def apply(continue: ContinuationizedParallelIterable[A] => Unit) { - for (element <- underline) { - super.incrementAndGet() - reset { - val pass = p(element) - if (pass) { - add(element) - } - if (super.decrementAndGet() == 0) { - continue(new ContinuationizedParallelIterable(results.get)) - } - } - } - if (super.decrementAndGet() == 0) { - continue(new ContinuationizedParallelIterable(results.get)) - } - } - }) - - final def foreach[U](f: A => U @suspendable): Unit @suspendable = - shift( - new AtomicInteger(1) with ((Unit => Unit) => Unit) { - override final def apply(continue: Unit => Unit) { - for (element <- underline) { - super.incrementAndGet() - reset { - f(element) - if (super.decrementAndGet() == 0) { - continue() - } - } - } - if (super.decrementAndGet() == 0) { - continue() - } - } - }) - - final def map[B: Manifest](f: A => B @suspendable): ContinuationizedParallelIterable[B] @suspendable = - shift( - new AtomicInteger(underline.size) with ((ContinuationizedParallelIterable[B] => Unit) => Unit) { - override final def apply(continue: ContinuationizedParallelIterable[B] => Unit) { - val results = new Array[B](super.get) - for ((element, i) <- underline.view.zipWithIndex) { - reset { - val result = f(element) - results(i) = result - if (super.decrementAndGet() == 0) { - continue(new ContinuationizedParallelIterable(results)) - } - } - } - } - }) -} -} diff --git a/test/files/continuations-run/t5506.check b/test/files/continuations-run/t5506.check deleted file mode 100644 index 38b76c63f1..0000000000 --- a/test/files/continuations-run/t5506.check +++ /dev/null @@ -1,7 +0,0 @@ -List(1, 2, 3) -List(1, 2, 3) -List(1, 2, 3) -List(1, 2, 3) -List(1, 2, 3) -List(1, 2, 3) -List(1, 2, 3) diff --git a/test/files/continuations-run/t5506.scala b/test/files/continuations-run/t5506.scala deleted file mode 100644 index 08f64c9db1..0000000000 --- a/test/files/continuations-run/t5506.scala +++ /dev/null @@ -1,58 +0,0 @@ -import scala.util.continuations._ - -object Test { - -def g: List[Int] @suspendable = List(1,2,3) - -def fp10: List[Int] @suspendable = { -g.map(x => x) -} - -def fp11: List[Int] @suspendable = { -val z = g.map(x => x) -z -} - - -def fp12: List[Int] @suspendable = { -val z = List(1,2,3) -z.map(x => x) -} - - - -def fp20: List[Int] @suspendable = { -g.map[Int,List[Int]](x => x) -} - - -def fp21: List[Int] @suspendable = { -val z = g.map[Int,List[Int]](x => x) -z -} - -def fp22: List[Int] @suspendable = { -val z = g.map[Int,List[Int]](x => x)(List.canBuildFrom[Int]) -z -} - -def fp23: List[Int] @suspendable = { -val z = g.map(x => x)(List.canBuildFrom[Int]) -z -} - - -def main(args: Array[String]) { - reset { - println(fp10) - println(fp11) - println(fp12) - - println(fp20) - println(fp21) - println(fp22) - println(fp23) - } -} - -} diff --git a/test/files/continuations-run/t5538.check b/test/files/continuations-run/t5538.check deleted file mode 100644 index d9d873663d..0000000000 --- a/test/files/continuations-run/t5538.check +++ /dev/null @@ -1,2 +0,0 @@ -warning: there were 1 feature warning(s); re-run with -feature for details -Future(Future(Future(Future(Future(List(1, 2, 3, 4, 5)))))) diff --git a/test/files/continuations-run/t5538.scala b/test/files/continuations-run/t5538.scala deleted file mode 100644 index 9f01624da1..0000000000 --- a/test/files/continuations-run/t5538.scala +++ /dev/null @@ -1,52 +0,0 @@ -import scala.util.continuations._ -import scala.collection.generic.CanBuildFrom - -import scala.language.{ implicitConversions } - -object Test { - - class ExecutionContext - - implicit def defaultExecutionContext = new ExecutionContext - - case class Future[+T](x:T) { - final def map[A](f: T => A): Future[A] = new Future[A](f(x)) - final def flatMap[A](f: T => Future[A]): Future[A] = f(x) - } - - class PromiseStream[A] { - override def toString = xs.toString - - var xs: List[A] = Nil - - final def +=(elem: A): this.type = { xs :+= elem; this } - - final def ++=(elem: Traversable[A]): this.type = { xs ++= elem; this } - - final def <<(elem: Future[A]): PromiseStream[A] @cps[Future[Any]] = - shift { cont: (PromiseStream[A] => Future[Any]) => elem map (a => cont(this += a)) } - - final def <<(elem1: Future[A], elem2: Future[A], elems: Future[A]*): PromiseStream[A] @cps[Future[Any]] = - shift { cont: (PromiseStream[A] => Future[Any]) => Future.flow(this << elem1 << elem2 <<< Future.sequence(elems.toSeq)) map cont } - - final def <<<(elems: Traversable[A]): PromiseStream[A] @cps[Future[Any]] = - shift { cont: (PromiseStream[A] => Future[Any]) => cont(this ++= elems) } - - final def <<<(elems: Future[Traversable[A]]): PromiseStream[A] @cps[Future[Any]] = - shift { cont: (PromiseStream[A] => Future[Any]) => elems map (as => cont(this ++= as)) } - } - - object Future { - - def sequence[A, M[_] <: Traversable[_]](in: M[Future[A]])(implicit cbf: CanBuildFrom[M[Future[A]], A, M[A]], executor: ExecutionContext): Future[M[A]] = - new Future(in.asInstanceOf[Traversable[Future[A]]].map((f:Future[A])=>f.x)(cbf.asInstanceOf[CanBuildFrom[Traversable[Future[A]], A, M[A]]])) - - def flow[A](body: => A @cps[Future[Any]])(implicit executor: ExecutionContext): Future[A] = reset(Future(body)).asInstanceOf[Future[A]] - - } - - def main(args: Array[String]) { - val p = new PromiseStream[Int] - println(Future.flow(p << (Future(1), Future(2), Future(3), Future(4), Future(5)))) - } -} diff --git a/test/files/continuations-run/trycatch0.check b/test/files/continuations-run/trycatch0.check deleted file mode 100644 index 36806909d0..0000000000 --- a/test/files/continuations-run/trycatch0.check +++ /dev/null @@ -1,2 +0,0 @@ -10 -10
\ No newline at end of file diff --git a/test/files/continuations-run/trycatch0.scala b/test/files/continuations-run/trycatch0.scala deleted file mode 100644 index d0b4a52a30..0000000000 --- a/test/files/continuations-run/trycatch0.scala +++ /dev/null @@ -1,25 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - -object Test { - - def foo = try { - shift((k: Int=>Int) => k(7)) - } catch { - case ex: Throwable => - 9 - } - - def bar = try { - 7 - } catch { - case ex: Throwable => - shiftUnit0[Int,Int](9) - } - - def main(args: Array[String]): Unit = { - println(reset { foo + 3 }) - println(reset { bar + 3 }) - } -} diff --git a/test/files/continuations-run/trycatch1.check b/test/files/continuations-run/trycatch1.check deleted file mode 100644 index 061ecdcd54..0000000000 --- a/test/files/continuations-run/trycatch1.check +++ /dev/null @@ -1,10 +0,0 @@ -trycatch1.scala:34: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses - 7 - ^ -trycatch1.scala:18: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses - shift((k: Int=>Int) => k(7)) - ^ -12 -12 -12 -12 diff --git a/test/files/continuations-run/trycatch1.scala b/test/files/continuations-run/trycatch1.scala deleted file mode 100644 index 2a8db72a8b..0000000000 --- a/test/files/continuations-run/trycatch1.scala +++ /dev/null @@ -1,48 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - -object Test { - - def fatal: Int = throw new Exception() - - def foo1 = try { - fatal - shift((k: Int=>Int) => k(7)) - } catch { - case ex: Throwable => - 9 - } - - def foo2 = try { - shift((k: Int=>Int) => k(7)) - fatal - } catch { - case ex: Throwable => - 9 - } - - def bar1 = try { - fatal - 7 - } catch { - case ex: Throwable => - shiftUnit0[Int,Int](9) // regular shift causes no-symbol doesn't have owner - } - - def bar2 = try { - 7 - fatal - } catch { - case ex: Throwable => - shiftUnit0[Int,Int](9) // regular shift causes no-symbol doesn't have owner - } - - def main(args: Array[String]): Unit = { - println(reset { foo1 + 3 }) - println(reset { foo2 + 3 }) - println(reset { bar1 + 3 }) - println(reset { bar2 + 3 }) - } - -} diff --git a/test/files/continuations-run/while0.check b/test/files/continuations-run/while0.check deleted file mode 100644 index d58c55a31d..0000000000 --- a/test/files/continuations-run/while0.check +++ /dev/null @@ -1 +0,0 @@ -9000 diff --git a/test/files/continuations-run/while0.scala b/test/files/continuations-run/while0.scala deleted file mode 100644 index e21745374e..0000000000 --- a/test/files/continuations-run/while0.scala +++ /dev/null @@ -1,22 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def foo(): Int @cps[Unit] = 2 - - def test(): Unit @cps[Unit] = { - var x = 0 - while (x < 9000) { // pick number large enough to require tail-call opt - x += foo() - } - println(x) - } - - def main(args: Array[String]): Unit = { - reset(test()) - } - -} diff --git a/test/files/continuations-run/while1.check b/test/files/continuations-run/while1.check deleted file mode 100644 index 3d5f0b9a46..0000000000 --- a/test/files/continuations-run/while1.check +++ /dev/null @@ -1,11 +0,0 @@ -up -up -up -up -up -10 -down -down -down -down -down diff --git a/test/files/continuations-run/while1.scala b/test/files/continuations-run/while1.scala deleted file mode 100644 index 7ba9f94881..0000000000 --- a/test/files/continuations-run/while1.scala +++ /dev/null @@ -1,22 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def foo(): Int @cps[Unit] = shift { k => println("up"); k(2); println("down") } - - def test(): Unit @cps[Unit] = { - var x = 0 - while (x < 9) { - x += foo() - } - println(x) - } - - def main(args: Array[String]): Unit = { - reset(test()) - } - -} diff --git a/test/files/continuations-run/while2.check b/test/files/continuations-run/while2.check deleted file mode 100644 index 9fe515181b..0000000000 --- a/test/files/continuations-run/while2.check +++ /dev/null @@ -1,19 +0,0 @@ -up -up -up -up -up -up -up -up -up -9000 -down -down -down -down -down -down -down -down -down diff --git a/test/files/continuations-run/while2.scala b/test/files/continuations-run/while2.scala deleted file mode 100644 index 3dbf2ad2fe..0000000000 --- a/test/files/continuations-run/while2.scala +++ /dev/null @@ -1,23 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - -object Test { - - def foo1(): Int @cps[Unit] = 2 - def foo2(): Int @cps[Unit] = shift { k => println("up"); k(2); println("down") } - - def test(): Unit @cps[Unit] = { - var x = 0 - while (x < 9000) { // pick number large enough to require tail-call opt - x += (if (x % 1000 != 0) foo1() else foo2()) - } - println(x) - } - - def main(args: Array[String]): Unit = { - reset(test()) - } - -} diff --git a/test/files/continuations-run/z1673.scala b/test/files/continuations-run/z1673.scala deleted file mode 100644 index 716b374860..0000000000 --- a/test/files/continuations-run/z1673.scala +++ /dev/null @@ -1,31 +0,0 @@ -import scala.util.continuations._ - -class MatchRepro { - def s: String @cps[Any] = shift { k => k("foo") } - - def p = { - val k = s - s match { case lit0 => } - } - - def q = { - val k = s - k match { case lit1 => } - } - - def r = { - s match { case "FOO" => } - } - - def t = { - val k = s - k match { case "FOO" => } - } -} - -object Test { - def main(args: Array[String]): Unit = { - val m = new MatchRepro - () - } -} diff --git a/test/files/instrumented/InstrumentationTest.check b/test/files/instrumented/InstrumentationTest.check index 0c570fa12c..c82d16bd34 100644 --- a/test/files/instrumented/InstrumentationTest.check +++ b/test/files/instrumented/InstrumentationTest.check @@ -1,3 +1,4 @@ +#partest !avian true Method call statistics: 1 Foo1.<init>()V @@ -8,3 +9,6 @@ Method call statistics: 1 scala/Predef$.println(Ljava/lang/Object;)V 1 scala/io/AnsiColor$class.$init$(Lscala/io/AnsiColor;)V 1 scala/runtime/BoxesRunTime.boxToBoolean(Z)Ljava/lang/Boolean; +#partest avian +!!!TEST SKIPPED!!! +Instrumentation is not supported on Avian. diff --git a/test/files/instrumented/InstrumentationTest.scala b/test/files/instrumented/InstrumentationTest.scala index 0e53f80857..458fd4974b 100644 --- a/test/files/instrumented/InstrumentationTest.scala +++ b/test/files/instrumented/InstrumentationTest.scala @@ -15,16 +15,21 @@ package instrumented { /** Tests if instrumentation itself works correctly */ object Test { def main(args: Array[String]) { - // force predef initialization before profiling - Predef - startProfiling() - val foo1 = new Foo1 - foo1.someMethod - val foo2 = new instrumented.Foo2 - foo2.someMethod - // should box the boolean - println(true) - stopProfiling() - printStatistics() + if (scala.tools.partest.utils.Properties.isAvian) { + println("!!!TEST SKIPPED!!!") + println("Instrumentation is not supported on Avian.") + } else { + // force predef initialization before profiling + Predef + startProfiling() + val foo1 = new Foo1 + foo1.someMethod + val foo2 = new instrumented.Foo2 + foo2.someMethod + // should box the boolean + println(true) + stopProfiling() + printStatistics() + } } } diff --git a/test/files/instrumented/inline-in-constructors.check b/test/files/instrumented/inline-in-constructors.check index c6c9ae4e15..b58c1d77d5 100644 --- a/test/files/instrumented/inline-in-constructors.check +++ b/test/files/instrumented/inline-in-constructors.check @@ -1,3 +1,7 @@ +#partest !avian Method call statistics: 1 instrumented/Bar.<init>(Z)V 1 instrumented/Foo.<init>(I)V +#partest avian +!!!TEST SKIPPED!!! +Instrumentation is not supported on Avian. diff --git a/test/files/instrumented/inline-in-constructors/test_3.scala b/test/files/instrumented/inline-in-constructors/test_3.scala index c4d4cc5f37..949e9945e7 100644 --- a/test/files/instrumented/inline-in-constructors/test_3.scala +++ b/test/files/instrumented/inline-in-constructors/test_3.scala @@ -3,13 +3,18 @@ import instrumented._ object Test { def main(args: Array[String]) { - // force predef initialization before profiling - Predef - MyPredef - startProfiling() - val a = new Foo(2) - val b = new Bar(true) - stopProfiling() - printStatistics() + if (scala.tools.partest.utils.Properties.isAvian) { + println("!!!TEST SKIPPED!!!") + println("Instrumentation is not supported on Avian.") + } else { + // force predef initialization before profiling + Predef + MyPredef + startProfiling() + val a = new Foo(2) + val b = new Bar(true) + stopProfiling() + printStatistics() + } } } diff --git a/test/files/jvm/future-spec/PromiseTests.scala b/test/files/jvm/future-spec/PromiseTests.scala index 49350586b8..12b9168c5d 100644 --- a/test/files/jvm/future-spec/PromiseTests.scala +++ b/test/files/jvm/future-spec/PromiseTests.scala @@ -38,10 +38,10 @@ class PromiseTests extends MinimalScalaTest { Await.result(failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout") Await.result(timedOut fallbackTo empty, defaultTimeout) mustBe ("Timedout") - Await.result(failure fallbackTo failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout") + Await.result(otherFailure fallbackTo failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout") intercept[RuntimeException] { Await.result(failure fallbackTo otherFailure, defaultTimeout) - }.getMessage mustBe ("last") + }.getMessage mustBe ("br0ken") } } diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index b431f6b8f8..ce86d4aef0 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -344,8 +344,8 @@ def testTransformFailure(): Unit = once { def testFallbackToFailure(): Unit = once { done => val cause = new Exception - val f = Future { sys.error("failed") } - val g = Future { throw cause } + val f = Future { throw cause } + val g = Future { sys.error("failed") } val h = f fallbackTo g h onSuccess { case _ => done(false) } diff --git a/test/files/neg/compile-time-only-a.check b/test/files/neg/compile-time-only-a.check index 1c4c72171f..9bc96f6b9b 100644 --- a/test/files/neg/compile-time-only-a.check +++ b/test/files/neg/compile-time-only-a.check @@ -1,49 +1,79 @@ -compile-time-only-a.scala:9: error: C3 +compile-time-only-a.scala:10: error: C3 @compileTimeOnly("C3") case class C3(x: Int) ^ -compile-time-only-a.scala:11: error: C4 +compile-time-only-a.scala:12: error: C4 @compileTimeOnly("C4") case class C4(x: Int) ^ -compile-time-only-a.scala:16: error: C5 +compile-time-only-a.scala:17: error: C5 implicit class C5(val x: Int) { ^ -compile-time-only-a.scala:28: error: C1 +compile-time-only-a.scala:32: error: C1 new C1() ^ -compile-time-only-a.scala:32: error: C2 +compile-time-only-a.scala:36: error: C2 C2 ^ -compile-time-only-a.scala:34: error: C3 +compile-time-only-a.scala:38: error: C3 new C3(2) ^ -compile-time-only-a.scala:37: error: C4 +compile-time-only-a.scala:41: error: C4 new C4(2) ^ -compile-time-only-a.scala:41: error: C5 +compile-time-only-a.scala:45: error: C5 2.ext ^ -compile-time-only-a.scala:42: error: C5 +compile-time-only-a.scala:46: error: C5 C5(2) ^ -compile-time-only-a.scala:45: error: C6.x +compile-time-only-a.scala:49: error: C6.x val _ = c6.x ^ -compile-time-only-a.scala:46: error: C6.foo +compile-time-only-a.scala:50: error: C6.foo c6.foo ^ -compile-time-only-a.scala:48: error: C6.y +compile-time-only-a.scala:51: error: C6.Foo + type Foo = c6.Foo + ^ +compile-time-only-a.scala:52: error: C6.y c6.y = c6.y ^ -compile-time-only-a.scala:48: error: C6.y +compile-time-only-a.scala:52: error: C6.y c6.y = c6.y ^ -compile-time-only-a.scala:54: error: placebo -@placebo - ^ -compile-time-only-a.scala:56: error: placebo +compile-time-only-a.scala:54: error: C7 + val c701: (C7, C7) = ??? + ^ +compile-time-only-a.scala:55: error: C7 + val c702: (C7 => C7) = ??? + ^ +compile-time-only-a.scala:56: error: C7 + val c703: { val x: C7 } = ??? + ^ +compile-time-only-a.scala:57: error: C7 + val c704: AnyRef with C7 = ??? + ^ +compile-time-only-a.scala:60: error: C7 + val c706: C7 Either C7 = ??? + ^ +compile-time-only-a.scala:61: error: C7 + val c707a: List[C7] = ??? + ^ +compile-time-only-a.scala:63: error: C7 + val c708a: T forSome { type T <: C7 } = ??? + ^ +compile-time-only-a.scala:66: error: C8 + val c709: (C8[Int], C8[C7]) = ??? + ^ +compile-time-only-a.scala:67: error: C8 + val c710: (C8[_] => C8[_]) = ??? + ^ +compile-time-only-a.scala:74: error: placebo +class Test { + ^ +compile-time-only-a.scala:75: error: placebo @placebo def x = (2: @placebo) - ^ -compile-time-only-a.scala:56: error: placebo + ^ +compile-time-only-a.scala:75: error: placebo @placebo def x = (2: @placebo) ^ -16 errors found +26 errors found diff --git a/test/files/neg/compile-time-only-a.scala b/test/files/neg/compile-time-only-a.scala index 43d36dfab1..533175a699 100644 --- a/test/files/neg/compile-time-only-a.scala +++ b/test/files/neg/compile-time-only-a.scala @@ -1,4 +1,5 @@ import scala.annotation.compileTimeOnly +import scala.language.existentials @compileTimeOnly("C1") class C1 object C1 @@ -24,6 +25,9 @@ class C6(@compileTimeOnly("C6.x") val x: Int) { @compileTimeOnly("C6.y") var y = 3 } +@compileTimeOnly("C7") class C7 +@compileTimeOnly("C8") class C8[T] + object Test extends App { new C1() C1 @@ -46,6 +50,21 @@ object Test extends App { c6.foo type Foo = c6.Foo c6.y = c6.y + + val c701: (C7, C7) = ??? + val c702: (C7 => C7) = ??? + val c703: { val x: C7 } = ??? + val c704: AnyRef with C7 = ??? + // https://groups.google.com/forum/#!topic/scala-internals/5n07TiCnBZU + // val c705: ({ @compileTimeOnly("C7") type C7[T] = List[T] })#C7[_] = ??? + val c706: C7 Either C7 = ??? + val c707a: List[C7] = ??? + val c707b = List[C7]() + val c708a: T forSome { type T <: C7 } = ??? + // https://groups.google.com/forum/#!topic/scala-internals/5n07TiCnBZU + // val c708b: T forSome { @compileTimeOnly("C7") type T } = ??? + val c709: (C8[Int], C8[C7]) = ??? + val c710: (C8[_] => C8[_]) = ??? } @compileTimeOnly("placebo") diff --git a/test/files/neg/macro-blackbox-extractor/Macros_1.scala b/test/files/neg/macro-blackbox-extractor/Macros_1.scala index 5c7748bec9..f0bfe53aa2 100644 --- a/test/files/neg/macro-blackbox-extractor/Macros_1.scala +++ b/test/files/neg/macro-blackbox-extractor/Macros_1.scala @@ -2,7 +2,7 @@ import scala.reflect.macros.BlackboxContext import language.experimental.macros object Extractor { - def unapply(x: Int) = macro Macros.unapplyImpl + def unapply(x: Int): Any = macro Macros.unapplyImpl } object Macros { diff --git a/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala b/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala index 08f1c21e89..f5e85d57ea 100644 --- a/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala +++ b/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala @@ -11,5 +11,5 @@ object Macros { """ } - def foo = macro impl + def foo: Any = macro impl }
\ No newline at end of file diff --git a/test/files/neg/macro-bundle-class.check b/test/files/neg/macro-bundle-class.check index 8fd04f1303..7108c15b8d 100644 --- a/test/files/neg/macro-bundle-class.check +++ b/test/files/neg/macro-bundle-class.check @@ -1,4 +1,4 @@ macro-bundle-class.scala:10: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member def foo = macro Bundle.impl - ^ + ^ one error found diff --git a/test/files/neg/macro-bundle-mixbox.check b/test/files/neg/macro-bundle-mixbox.check index 4f8cedcece..c3136d9369 100644 --- a/test/files/neg/macro-bundle-mixbox.check +++ b/test/files/neg/macro-bundle-mixbox.check @@ -1,4 +1,4 @@ macro-bundle-mixbox.scala:9: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member def foo = macro Bundle.impl - ^ + ^ one error found diff --git a/test/files/neg/macro-bundle-object.check b/test/files/neg/macro-bundle-object.check index e148e86969..78e7119fa7 100644 --- a/test/files/neg/macro-bundle-object.check +++ b/test/files/neg/macro-bundle-object.check @@ -1,8 +1,8 @@ -macro-bundle-object.scala:10: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any] +macro-bundle-object.scala:10: error: macro implementation has incompatible shape: + required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing] or : (c: scala.reflect.macros.BlackboxContext): c.Tree found : : Nothing number of parameter sections differ def foo = macro Bundle.impl - ^ + ^ one error found diff --git a/test/files/neg/macro-bundle-polymorphic.check b/test/files/neg/macro-bundle-polymorphic.check index 07c5f551b1..e024fcde93 100644 --- a/test/files/neg/macro-bundle-polymorphic.check +++ b/test/files/neg/macro-bundle-polymorphic.check @@ -1,10 +1,10 @@ macro-bundle-polymorphic.scala:9: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member def foo = macro Bundle.impl - ^ + ^ macro-bundle-polymorphic.scala:10: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member def foo = macro Bundle[Int].impl - ^ + ^ macro-bundle-polymorphic.scala:11: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member def foo = macro Bundle[Int, Nothing].impl - ^ + ^ three errors found diff --git a/test/files/neg/macro-bundle-trait.check b/test/files/neg/macro-bundle-trait.check index bf906a5310..3cb7985013 100644 --- a/test/files/neg/macro-bundle-trait.check +++ b/test/files/neg/macro-bundle-trait.check @@ -1,4 +1,4 @@ macro-bundle-trait.scala:11: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member def foo = macro Bundle.impl - ^ + ^ one error found diff --git a/test/files/neg/macro-invalidimpl.check b/test/files/neg/macro-invalidimpl.check index 432da4d00b..5eff401bef 100644 --- a/test/files/neg/macro-invalidimpl.check +++ b/test/files/neg/macro-invalidimpl.check @@ -2,22 +2,22 @@ Macros_Test_2.scala:5: error: macro implementation reference has wrong shape. re macro [<static object>].<method name>[[<type args>]] or macro [<macro bundle>].<method name>[[<type args>]] def foo(x: Any) = macro impls.foo - ^ + ^ Macros_Test_2.scala:10: error: macro implementation reference has wrong shape. required: macro [<static object>].<method name>[[<type args>]] or macro [<macro bundle>].<method name>[[<type args>]] def foo(x: Any) = macro impls.foo - ^ + ^ Macros_Test_2.scala:18: error: macro implementation reference has wrong shape. required: macro [<static object>].<method name>[[<type args>]] or macro [<macro bundle>].<method name>[[<type args>]] def foo(x: Any) = macro Impls3.foo - ^ + ^ Macros_Test_2.scala:22: error: macro implementation reference has wrong shape. required: macro [<static object>].<method name>[[<type args>]] or macro [<macro bundle>].<method name>[[<type args>]] def foo(x: Any) = macro Impls4.foo - ^ + ^ Macros_Test_2.scala:26: error: ambiguous reference to overloaded definition, both method foo in object Impls5 of type (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any], y: c.Expr[Any])Nothing and method foo in object Impls5 of type (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any])Nothing @@ -30,24 +30,24 @@ and method foo in object Impls5 of type (c: scala.reflect.macros.BlackboxContex match expected type ? def foo(x: Any, y: Any) = macro Impls5.foo ^ -Macros_Test_2.scala:31: error: macro implementation has wrong shape: +Macros_Test_2.scala:31: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Unit] or : (c: scala.reflect.macros.BlackboxContext): c.Tree found : (c: scala.reflect.macros.BlackboxContext)(): c.Expr[Unit] number of parameter sections differ def foo1 = macro Impls6.fooEmpty - ^ -Macros_Test_2.scala:32: error: macro implementation has wrong shape: + ^ +Macros_Test_2.scala:32: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.BlackboxContext)(): c.Expr[Unit] or : (c: scala.reflect.macros.BlackboxContext)(): c.Tree found : (c: scala.reflect.macros.BlackboxContext): c.Expr[Unit] number of parameter sections differ def bar1() = macro Impls6.fooNullary - ^ + ^ Macros_Test_2.scala:36: error: type arguments [String] do not conform to method foo's type parameter bounds [U <: Int] def foo = macro Impls7.foo[String] ^ Macros_Test_2.scala:53: error: macro implementation must be public def foo = macro Impls8.impl - ^ + ^ 10 errors found diff --git a/test/files/neg/macro-invalidret.check b/test/files/neg/macro-invalidret.check index 19adc70fb3..6c5baf76b4 100644 --- a/test/files/neg/macro-invalidret.check +++ b/test/files/neg/macro-invalidret.check @@ -1,15 +1,35 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: +Macros_Test_2.scala:2: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any] or : (c: scala.reflect.macros.BlackboxContext): c.Tree found : (c: scala.reflect.macros.BlackboxContext): Int type mismatch for return type: Int does not conform to c.Expr[Any] def foo1 = macro Impls.foo1 - ^ -Macros_Test_2.scala:3: error: macro implementation has wrong shape: + ^ +Macros_Test_2.scala:3: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any] or : (c: scala.reflect.macros.BlackboxContext): c.Tree found : (c: scala.reflect.macros.BlackboxContext): reflect.runtime.universe.Literal type mismatch for return type: reflect.runtime.universe.Literal does not conform to c.Expr[Any] def foo2 = macro Impls.foo2 + ^ +Macros_Test_2.scala:6: error: macro defs must have explicitly specified return types + def foo5 = macro Impls.foo5 + ^ +Macros_Test_2.scala:7: warning: macro defs must have explicitly specified return types (inference of Int from macro impl's c.Expr[Int] is deprecated and is going to stop working in 2.12) + def foo6 = macro Impls.foo6 ^ -two errors found +Macros_Test_2.scala:14: error: exception during macro expansion: +scala.NotImplementedError: an implementation is missing + at scala.Predef$.$qmark$qmark$qmark(Predef.scala:227) + at Impls$.foo3(Impls_1.scala:7) + + foo3 + ^ +Macros_Test_2.scala:15: error: macro implementation is missing + foo4 + ^ +Macros_Test_2.scala:17: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses + foo6 + ^ +two warnings found +5 errors found diff --git a/test/files/neg/macro-invalidret.flags b/test/files/neg/macro-invalidret.flags index cd66464f2f..946c53ec0e 100644 --- a/test/files/neg/macro-invalidret.flags +++ b/test/files/neg/macro-invalidret.flags @@ -1 +1,3 @@ --language:experimental.macros
\ No newline at end of file +-language:experimental.macros +-Xfatal-warnings +-deprecation
\ No newline at end of file diff --git a/test/files/neg/macro-invalidret/Impls_1.scala b/test/files/neg/macro-invalidret/Impls_1.scala index d957b74512..b32463899e 100644 --- a/test/files/neg/macro-invalidret/Impls_1.scala +++ b/test/files/neg/macro-invalidret/Impls_1.scala @@ -4,4 +4,7 @@ import scala.reflect.runtime.{universe => ru} object Impls { def foo1(c: BlackboxContext) = 2 def foo2(c: BlackboxContext) = ru.Literal(ru.Constant(42)) + def foo3(c: BlackboxContext) = ??? + def foo5(c: BlackboxContext) = c.universe.Literal(c.universe.Constant(42)) + def foo6(c: BlackboxContext) = c.Expr[Int](c.universe.Literal(c.universe.Constant(42))) } diff --git a/test/files/neg/macro-invalidret/Macros_Test_2.scala b/test/files/neg/macro-invalidret/Macros_Test_2.scala index f8880fa023..8840f492ab 100644 --- a/test/files/neg/macro-invalidret/Macros_Test_2.scala +++ b/test/files/neg/macro-invalidret/Macros_Test_2.scala @@ -1,10 +1,18 @@ object Macros { def foo1 = macro Impls.foo1 def foo2 = macro Impls.foo2 + def foo3 = macro Impls.foo3 + def foo4 = macro ??? + def foo5 = macro Impls.foo5 + def foo6 = macro Impls.foo6 } object Test extends App { import Macros._ foo1 foo2 + foo3 + foo4 + foo5 + foo6 }
\ No newline at end of file diff --git a/test/files/neg/macro-invalidshape.check b/test/files/neg/macro-invalidshape.check index 1938f5ae47..aa694df6d6 100644 --- a/test/files/neg/macro-invalidshape.check +++ b/test/files/neg/macro-invalidshape.check @@ -2,12 +2,12 @@ Macros_Test_2.scala:2: error: macro implementation reference has wrong shape. re macro [<static object>].<method name>[[<type args>]] or macro [<macro bundle>].<method name>[[<type args>]] def foo1(x: Any) = macro 2 - ^ + ^ Macros_Test_2.scala:3: error: macro implementation reference has wrong shape. required: macro [<static object>].<method name>[[<type args>]] or macro [<macro bundle>].<method name>[[<type args>]] def foo2(x: Any) = macro Impls.foo(null)(null) - ^ + ^ Macros_Test_2.scala:4: error: missing arguments for method foo in object Impls; follow this method with `_' if you want to treat it as a partially applied function def foo3(x: Any) = macro {2; Impls.foo} @@ -16,5 +16,5 @@ Macros_Test_2.scala:7: error: macro implementation reference has wrong shape. re macro [<static object>].<method name>[[<type args>]] or macro [<macro bundle>].<method name>[[<type args>]] def foo = macro impl - ^ + ^ four errors found diff --git a/test/files/neg/macro-invalidsig-params-badtype.check b/test/files/neg/macro-invalidsig-params-badtype.check index e0cd63fbe4..d6b5c5521d 100644 --- a/test/files/neg/macro-invalidsig-params-badtype.check +++ b/test/files/neg/macro-invalidsig-params-badtype.check @@ -1,8 +1,8 @@ -Impls_Macros_1.scala:8: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Any] +Impls_Macros_1.scala:8: error: macro implementation has incompatible shape: + required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing] or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree found : (c: scala.reflect.macros.BlackboxContext)(x: Int): Nothing type mismatch for parameter x: c.Expr[Int] does not conform to Int def foo(x: Int) = macro Impls.foo - ^ + ^ one error found diff --git a/test/files/neg/macro-invalidsig.check b/test/files/neg/macro-invalidsig.check index 42b8db5628..5ff4ed18cb 100644 --- a/test/files/neg/macro-invalidsig.check +++ b/test/files/neg/macro-invalidsig.check @@ -1,93 +1,85 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any] - or : (c: scala.reflect.macros.BlackboxContext): c.Tree - found : (c: scala.reflect.macros.BlackboxContext)(implicit evidence$2: Numeric[U]): c.universe.Literal -macro implementations cannot have implicit parameters other than WeakTypeTag evidences - def foo[U] = macro Impls1.foo[U] - ^ -Macros_Test_2.scala:6: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any] +Macros_Test_2.scala:2: error: macro implementations cannot have implicit parameters other than WeakTypeTag evidences + def foo[U]: Int = macro Impls1.foo[U] + ^ +Macros_Test_2.scala:6: error: macro implementation has incompatible shape: + required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing] or : (c: scala.reflect.macros.BlackboxContext): c.Tree found : : Nothing number of parameter sections differ def foo = macro Impls2.foo - ^ -Macros_Test_2.scala:10: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any] + ^ +Macros_Test_2.scala:10: error: macro implementation has incompatible shape: + required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing] or : (c: scala.reflect.macros.BlackboxContext): c.Tree found : (c: scala.reflect.api.Universe): Nothing type mismatch for parameter c: scala.reflect.macros.BlackboxContext does not conform to scala.reflect.api.Universe def foo = macro Impls3.foo - ^ -Macros_Test_2.scala:14: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any] + ^ +Macros_Test_2.scala:14: error: macro implementation has incompatible shape: + required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing] or : (c: scala.reflect.macros.BlackboxContext): c.Tree found : (cs: scala.reflect.macros.BlackboxContext*): Nothing types incompatible for parameter cs: corresponding is not a vararg parameter def foo = macro Impls4.foo - ^ -Macros_Test_2.scala:18: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any]): c.Expr[Any] + ^ +Macros_Test_2.scala:18: error: macro implementation has incompatible shape: + required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any]): c.Expr[Nothing] or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree found : (c: scala.reflect.macros.BlackboxContext): Nothing number of parameter sections differ def foo(x: Any) = macro Impls5.foo - ^ -Macros_Test_2.scala:22: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Unit] - or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree - found : (c: scala.reflect.macros.BlackboxContext)(implicit x: c.Expr[Int]): c.Expr[Unit] -macro implementations cannot have implicit parameters other than WeakTypeTag evidences + ^ +Macros_Test_2.scala:22: error: macro implementations cannot have implicit parameters other than WeakTypeTag evidences def foo[U](x: Int) = macro Impls6.foo[T, U] - ^ -Macros_Test_2.scala:26: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Any] + ^ +Macros_Test_2.scala:26: error: macro implementation has incompatible shape: + required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing] or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree found : (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): Nothing parameter lists have different length, found extra parameter y: c.Expr[Int] def foo(x: Int) = macro Impls7.foo - ^ -Macros_Test_2.scala:30: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Any] + ^ +Macros_Test_2.scala:30: error: macro implementation has incompatible shape: + required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing] or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree found : (c: scala.reflect.macros.BlackboxContext)(x: c.universe.Symbol): Nothing type mismatch for parameter x: c.Expr[Int] does not conform to c.universe.Symbol def foo(x: Int) = macro Impls8.foo - ^ -Macros_Test_2.scala:34: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any] + ^ +Macros_Test_2.scala:34: error: macro implementation has incompatible shape: + required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Nothing] or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree, y: c.Tree): c.Tree found : (c: scala.reflect.macros.BlackboxContext)(xs: c.Expr[Int]*): Nothing parameter lists have different length, required extra parameter y: c.Expr[Int] def foo(x: Int, y: Int) = macro Impls9.foo - ^ -Macros_Test_2.scala:38: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any] + ^ +Macros_Test_2.scala:38: error: macro implementation has incompatible shape: + required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Nothing] or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree, y: c.Tree): c.Tree found : (c: scala.reflect.macros.BlackboxContext)(y: c.Expr[Int], x: c.Expr[Int]): Nothing parameter names differ: x != y def foo(x: Int, y: Int) = macro Impls10.foo - ^ -Macros_Test_2.scala:42: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any] + ^ +Macros_Test_2.scala:42: error: macro implementation has incompatible shape: + required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing] or : (c: scala.reflect.macros.BlackboxContext): c.Tree found : (c: scala.reflect.macros.BlackboxContext)(U: c.universe.Type): Nothing number of parameter sections differ def foo[U] = macro Impls11.foo[U] - ^ + ^ Macros_Test_2.scala:46: error: type arguments [U] do not conform to method foo's type parameter bounds [U <: String] def foo[U] = macro Impls12.foo[U] ^ Macros_Test_2.scala:50: error: type arguments [U] do not conform to method foo's type parameter bounds [U <: String] def foo[U <: Int] = macro Impls13.foo[U] ^ -Macros_Test_2.scala:54: error: wrong number of type parameters for method foo: [U](c: scala.reflect.macros.BlackboxContext)(implicit evidence$4: c.WeakTypeTag[U])Nothing +Macros_Test_2.scala:54: error: macro implementation reference has too few type arguments for method foo: [U](c: scala.reflect.macros.BlackboxContext)(implicit evidence$4: c.WeakTypeTag[U])Nothing def foo = macro Impls14.foo - ^ -Macros_Test_2.scala:59: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.BlackboxContext)(implicit evidence$5: c.WeakTypeTag[T], implicit evidence$6: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] - def foo15[V] = macro Impls15.foo - ^ + ^ +Macros_Test_2.scala:59: error: macro implementation reference has too few type arguments for method foo: [T, U, V](c: scala.reflect.macros.BlackboxContext)(implicit evidence$5: c.WeakTypeTag[T], implicit evidence$6: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] + def foo15[V]: Unit = macro Impls15.foo + ^ Macros_Test_2.scala:60: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.BlackboxContext)(implicit evidence$7: c.WeakTypeTag[T], implicit evidence$8: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] - def foo16[V] = macro Impls16.foo[V] - ^ + def foo16[V]: Unit = macro Impls16.foo[V] + ^ 16 errors found diff --git a/test/files/neg/macro-invalidsig/Macros_Test_2.scala b/test/files/neg/macro-invalidsig/Macros_Test_2.scala index 0a6a321431..89a5302d8a 100644 --- a/test/files/neg/macro-invalidsig/Macros_Test_2.scala +++ b/test/files/neg/macro-invalidsig/Macros_Test_2.scala @@ -1,5 +1,5 @@ object Macros1 { - def foo[U] = macro Impls1.foo[U] + def foo[U]: Int = macro Impls1.foo[U] } object Macros2 { @@ -56,8 +56,8 @@ object Macros14 { class D[T] { class C[U] { - def foo15[V] = macro Impls15.foo - def foo16[V] = macro Impls16.foo[V] + def foo15[V]: Unit = macro Impls15.foo + def foo16[V]: Unit = macro Impls16.foo[V] } } diff --git a/test/files/neg/macro-invalidusage-badargs/Macros_Test_2.scala b/test/files/neg/macro-invalidusage-badargs/Macros_Test_2.scala index 0b3ca0590b..cf8accf94f 100644 --- a/test/files/neg/macro-invalidusage-badargs/Macros_Test_2.scala +++ b/test/files/neg/macro-invalidusage-badargs/Macros_Test_2.scala @@ -1,4 +1,4 @@ -object Macros { def foo(x: Int) = macro Impls.foo } +object Macros { def foo(x: Int): Int = macro Impls.foo } import Macros._ object Test extends App { diff --git a/test/files/neg/macro-invalidusage-badbounds/Macros_Test_2.scala b/test/files/neg/macro-invalidusage-badbounds/Macros_Test_2.scala index 3139599108..76397701f9 100644 --- a/test/files/neg/macro-invalidusage-badbounds/Macros_Test_2.scala +++ b/test/files/neg/macro-invalidusage-badbounds/Macros_Test_2.scala @@ -1,5 +1,5 @@ object Macros { - def foo[U <: String] = macro Impls.foo[U] + def foo[U <: String]: Unit = macro Impls.foo[U] } object Test extends App { diff --git a/test/files/neg/macro-invalidusage-badtargs.check b/test/files/neg/macro-invalidusage-badtargs.check index 6a9e1d6e6b..722ec03765 100644 --- a/test/files/neg/macro-invalidusage-badtargs.check +++ b/test/files/neg/macro-invalidusage-badtargs.check @@ -1,16 +1,16 @@ -Macros_Test_2.scala:11: error: macro method foo1: (x: Int)Int does not take type parameters. +Macros_Test_2.scala:13: error: macro method foo1: (x: Int)Int does not take type parameters. foo1[String](42) ^ -Macros_Test_2.scala:12: error: wrong number of type parameters for macro method foo2: [T](x: Int)Int +Macros_Test_2.scala:14: error: wrong number of type parameters for macro method foo2: [T](x: Int)Int foo2[String, String](42) ^ -Macros_Test_2.scala:13: error: wrong number of type parameters for macro method foo3: [T, U](x: Int)Int +Macros_Test_2.scala:15: error: wrong number of type parameters for macro method foo3: [T, U](x: Int)Int foo3[String](42) ^ -Macros_Test_2.scala:14: error: String takes no type parameters, expected: one +Macros_Test_2.scala:16: error: String takes no type parameters, expected: one foo4[String](42) ^ -Macros_Test_2.scala:15: error: kinds of the type arguments (List) do not conform to the expected kinds of the type parameters (type T). +Macros_Test_2.scala:17: error: kinds of the type arguments (List) do not conform to the expected kinds of the type parameters (type T). List's type parameters do not match type T's expected parameters: type A has no type parameters, but type U has one foo5[List](42) diff --git a/test/files/neg/macro-invalidusage-badtargs/Macros_Test_2.scala b/test/files/neg/macro-invalidusage-badtargs/Macros_Test_2.scala index fd16d163c3..47e51bbf44 100644 --- a/test/files/neg/macro-invalidusage-badtargs/Macros_Test_2.scala +++ b/test/files/neg/macro-invalidusage-badtargs/Macros_Test_2.scala @@ -1,9 +1,11 @@ +import scala.language.higherKinds + object Macros { - def foo1(x: Int) = macro Impls.foo - def foo2[T](x: Int) = macro Impls.foo - def foo3[T, U](x: Int) = macro Impls.foo - def foo4[T[_]](x: Int) = macro Impls.foo - def foo5[T[U[_]]](x: Int) = macro Impls.foo + def foo1(x: Int): Int = macro Impls.foo + def foo2[T](x: Int): Int = macro Impls.foo + def foo3[T, U](x: Int): Int = macro Impls.foo + def foo4[T[_]](x: Int): Int = macro Impls.foo + def foo5[T[U[_]]](x: Int): Int = macro Impls.foo } object Test extends App { diff --git a/test/files/neg/macro-invalidusage-methodvaluesyntax/Macros_Test_2.scala b/test/files/neg/macro-invalidusage-methodvaluesyntax/Macros_Test_2.scala index 343cec99b5..578aa45867 100644 --- a/test/files/neg/macro-invalidusage-methodvaluesyntax/Macros_Test_2.scala +++ b/test/files/neg/macro-invalidusage-methodvaluesyntax/Macros_Test_2.scala @@ -1,5 +1,5 @@ object Macros { - def foo = macro Impls.foo + def foo: Unit = macro Impls.foo } object Test extends App { diff --git a/test/files/neg/macro-override-macro-overrides-abstract-method-a.check b/test/files/neg/macro-override-macro-overrides-abstract-method-a.check index 8c8f039225..6b5d3013ba 100644 --- a/test/files/neg/macro-override-macro-overrides-abstract-method-a.check +++ b/test/files/neg/macro-override-macro-overrides-abstract-method-a.check @@ -1,5 +1,5 @@ Impls_Macros_1.scala:12: error: overriding method foo in trait Foo of type (x: Int)Int; macro method foo cannot be used here - term macros cannot override abstract methods - def foo(x: Int) = macro Impls.impl + def foo(x: Int): Int = macro Impls.impl ^ one error found diff --git a/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala b/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala index 0e8a5f3b01..9c05db83e3 100644 --- a/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala +++ b/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala @@ -9,5 +9,5 @@ trait Foo { } object Macros extends Foo { - def foo(x: Int) = macro Impls.impl + def foo(x: Int): Int = macro Impls.impl } diff --git a/test/files/neg/macro-override-method-overrides-macro.check b/test/files/neg/macro-override-method-overrides-macro.check index e8cba5d029..e396d65ff1 100644 --- a/test/files/neg/macro-override-method-overrides-macro.check +++ b/test/files/neg/macro-override-method-overrides-macro.check @@ -1,5 +1,5 @@ Macros_Test_2.scala:8: error: overriding macro method foo in class B of type (x: String)Unit; method foo cannot be used here - only term macros can override term macros - override def foo(x: String) = println("fooDString") + override def foo(x: String): Unit = println("fooDString") ^ one error found diff --git a/test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala b/test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala index 36821b05d8..d47157766e 100644 --- a/test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala +++ b/test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala @@ -1,15 +1,15 @@ class B { - def foo(x: String) = macro Impls.fooBString - def foo(x: Int) = macro Impls.fooBInt - def foo(x: Boolean) = println("fooBBoolean") + def foo(x: String): Unit = macro Impls.fooBString + def foo(x: Int): Unit = macro Impls.fooBInt + def foo(x: Boolean): Unit = println("fooBBoolean") } class D extends B { - override def foo(x: String) = println("fooDString") - override def foo(x: Int) = macro Impls.fooDInt + override def foo(x: String): Unit = println("fooDString") + override def foo(x: Int): Unit = macro Impls.fooDInt } class Z extends D { - override def foo(x: String) = macro Impls.fooZString - override def foo(x: Boolean) = println("fooZBoolean") + override def foo(x: String): Unit = macro Impls.fooZString + override def foo(x: Boolean): Unit = println("fooZBoolean") } diff --git a/test/files/neg/macro-quasiquotes.check b/test/files/neg/macro-quasiquotes.check index d000bb5316..c690b61fe1 100644 --- a/test/files/neg/macro-quasiquotes.check +++ b/test/files/neg/macro-quasiquotes.check @@ -1,8 +1,8 @@ -Macros_1.scala:14: error: macro implementation has wrong shape: - required: (x: Impls.this.c.Expr[Int]): Impls.this.c.Expr[Any] +Macros_1.scala:14: error: macro implementation has incompatible shape: + required: (x: Impls.this.c.Expr[Int]): Impls.this.c.Expr[Unit] or : (x: Impls.this.c.Tree): Impls.this.c.Tree found : (x: Impls.this.c.universe.Block): Impls.this.c.Tree type mismatch for parameter x: Impls.this.c.Expr[Int] does not conform to Impls.this.c.universe.Block - def m3(x: Int) = macro Impls.impl3 - ^ + def m3(x: Int): Unit = macro Impls.impl3 + ^ one error found diff --git a/test/files/neg/macro-quasiquotes/Macros_1.scala b/test/files/neg/macro-quasiquotes/Macros_1.scala index 7f0219e6ac..098e4b3b92 100644 --- a/test/files/neg/macro-quasiquotes/Macros_1.scala +++ b/test/files/neg/macro-quasiquotes/Macros_1.scala @@ -9,7 +9,7 @@ trait Impls extends BlackboxMacro { } object Macros { - def m1(x: Int) = macro Impls.impl1 - def m2(x: Int) = macro Impls.impl2 - def m3(x: Int) = macro Impls.impl3 + def m1(x: Int): Unit = macro Impls.impl1 + def m2(x: Int): Unit = macro Impls.impl2 + def m3(x: Int): Unit = macro Impls.impl3 }
\ No newline at end of file diff --git a/test/files/neg/missing-param-type-tuple.check b/test/files/neg/missing-param-type-tuple.check new file mode 100644 index 0000000000..bc46ba1023 --- /dev/null +++ b/test/files/neg/missing-param-type-tuple.check @@ -0,0 +1,31 @@ +missing-param-type-tuple.scala:3: error: missing parameter type +Note: The expected type requires a one-argument function accepting a 2-Tuple. + Consider a pattern matching anoynmous function, `{ case (a, b) => ... }` + val x: ((Int, Int)) => Int = (a, b) => 0 + ^ +missing-param-type-tuple.scala:3: error: missing parameter type + val x: ((Int, Int)) => Int = (a, b) => 0 + ^ +missing-param-type-tuple.scala:5: error: missing parameter type +Note: The expected type requires a one-argument function accepting a 3-Tuple. + Consider a pattern matching anoynmous function, `{ case (param1, ..., param3) => ... }` + val y: ((Int, Int, Int)) => Int = (a, b, !!) => 0 + ^ +missing-param-type-tuple.scala:5: error: missing parameter type + val y: ((Int, Int, Int)) => Int = (a, b, !!) => 0 + ^ +missing-param-type-tuple.scala:5: error: missing parameter type + val y: ((Int, Int, Int)) => Int = (a, b, !!) => 0 + ^ +missing-param-type-tuple.scala:7: error: missing parameter type +Note: The expected type requires a one-argument function accepting a 3-Tuple. + Consider a pattern matching anoynmous function, `{ case (param1, ..., param3) => ... }` + val z: ((Int, Int, Int)) => Int = (a, NotAVariablePatternName, c) => 0 + ^ +missing-param-type-tuple.scala:7: error: missing parameter type + val z: ((Int, Int, Int)) => Int = (a, NotAVariablePatternName, c) => 0 + ^ +missing-param-type-tuple.scala:7: error: missing parameter type + val z: ((Int, Int, Int)) => Int = (a, NotAVariablePatternName, c) => 0 + ^ +8 errors found diff --git a/test/files/neg/missing-param-type-tuple.scala b/test/files/neg/missing-param-type-tuple.scala new file mode 100644 index 0000000000..72c0c82034 --- /dev/null +++ b/test/files/neg/missing-param-type-tuple.scala @@ -0,0 +1,8 @@ +class C { + + val x: ((Int, Int)) => Int = (a, b) => 0 + + val y: ((Int, Int, Int)) => Int = (a, b, !!) => 0 + + val z: ((Int, Int, Int)) => Int = (a, NotAVariablePatternName, c) => 0 +} diff --git a/test/files/neg/not-a-legal-formal-parameter-tuple.check b/test/files/neg/not-a-legal-formal-parameter-tuple.check new file mode 100644 index 0000000000..2b906b8ff3 --- /dev/null +++ b/test/files/neg/not-a-legal-formal-parameter-tuple.check @@ -0,0 +1,19 @@ +not-a-legal-formal-parameter-tuple.scala:2: error: not a legal formal parameter. +Note: Tuples cannot be directly destructured in method or function parameters. + Either create a single parameter accepting the Tuple2, + or consider a pattern matching anonymous function: `{ case (a, b) => ... } + val x: ((Int, Int) => Int) = (((a, b)) => a) + ^ +not-a-legal-formal-parameter-tuple.scala:3: error: not a legal formal parameter. +Note: Tuples cannot be directly destructured in method or function parameters. + Either create a single parameter accepting the Tuple2, + or consider a pattern matching anonymous function: `{ case (param1, param2) => ... } + val y: ((Int, Int, Int) => Int) = (((a, !!)) => a) + ^ +not-a-legal-formal-parameter-tuple.scala:4: error: not a legal formal parameter. +Note: Tuples cannot be directly destructured in method or function parameters. + Either create a single parameter accepting the Tuple3, + or consider a pattern matching anonymous function: `{ case (param1, ..., param3) => ... } + val z: ((Int, Int, Int) => Int) = (((a, NotAPatternVariableName, c)) => a) + ^ +three errors found diff --git a/test/files/neg/not-a-legal-formal-parameter-tuple.scala b/test/files/neg/not-a-legal-formal-parameter-tuple.scala new file mode 100644 index 0000000000..c7a13557df --- /dev/null +++ b/test/files/neg/not-a-legal-formal-parameter-tuple.scala @@ -0,0 +1,5 @@ +class C { + val x: ((Int, Int) => Int) = (((a, b)) => a) + val y: ((Int, Int, Int) => Int) = (((a, !!)) => a) + val z: ((Int, Int, Int) => Int) = (((a, NotAPatternVariableName, c)) => a) +} diff --git a/test/files/neg/patmat-classtag-compound.check b/test/files/neg/patmat-classtag-compound.check new file mode 100644 index 0000000000..8a54c935bd --- /dev/null +++ b/test/files/neg/patmat-classtag-compound.check @@ -0,0 +1,6 @@ +patmat-classtag-compound.scala:12: warning: abstract type pattern A is unchecked since it is eliminated by erasure + case b: A with Bar => true + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/patmat-classtag-compound.flags b/test/files/neg/patmat-classtag-compound.flags new file mode 100644 index 0000000000..144ddac9d3 --- /dev/null +++ b/test/files/neg/patmat-classtag-compound.flags @@ -0,0 +1 @@ +-unchecked -Xfatal-warnings diff --git a/test/files/neg/patmat-classtag-compound.scala b/test/files/neg/patmat-classtag-compound.scala new file mode 100644 index 0000000000..e2d0df0a02 --- /dev/null +++ b/test/files/neg/patmat-classtag-compound.scala @@ -0,0 +1,17 @@ +object Test extends App{ + trait Bar + trait Foo + // Failed to give an unchecked warning pre: https://github.com/scala/scala/pull/2848 + // + // Features interacting: + // - implicit class tags to enable type patterns on abstract types + // - type tests on compound types. + // + // We could try make these work together, but an unchecked warning is okay for now. + def x[A: reflect.ClassTag](a: Any): Boolean = a match{ + case b: A with Bar => true + case _ => false + } + println(x[Foo](new Bar{})) + println(x[String]("")) +} diff --git a/test/files/neg/quasiquotes-unliftable-not-found.check b/test/files/neg/quasiquotes-unliftable-not-found.check new file mode 100644 index 0000000000..5594aa1b15 --- /dev/null +++ b/test/files/neg/quasiquotes-unliftable-not-found.check @@ -0,0 +1,4 @@ +quasiquotes-unliftable-not-found.scala:4: error: Can't find reflect.runtime.universe.Unliftable[Test.C], consider providing it + val q"${c: C}" = q"()" + ^ +one error found diff --git a/test/files/neg/quasiquotes-unliftable-not-found.scala b/test/files/neg/quasiquotes-unliftable-not-found.scala new file mode 100644 index 0000000000..6a5efae43b --- /dev/null +++ b/test/files/neg/quasiquotes-unliftable-not-found.scala @@ -0,0 +1,5 @@ +object Test extends App { + import scala.reflect.runtime.universe._ + class C + val q"${c: C}" = q"()" +}
\ No newline at end of file diff --git a/test/files/neg/si7980.check b/test/files/neg/si7980.check new file mode 100644 index 0000000000..b085cabf1d --- /dev/null +++ b/test/files/neg/si7980.check @@ -0,0 +1,4 @@ +si7980.scala:7: error: Can't splice Nothing, bottom type values often indicate programmer mistake + println(q"class ${Name(X)} { }") + ^ +one error found diff --git a/test/files/neg/si7980.scala b/test/files/neg/si7980.scala new file mode 100644 index 0000000000..b21907de54 --- /dev/null +++ b/test/files/neg/si7980.scala @@ -0,0 +1,8 @@ +object Test extends App { + import scala.reflect.runtime.universe._ + def Name[T:TypeTag](name:String): T = implicitly[TypeTag[T]] match { + case t => newTypeName(name).asInstanceOf[T] + } + val X = "ASDF" + println(q"class ${Name(X)} { }") +} diff --git a/test/files/neg/t4928.check b/test/files/neg/t4928.check index 06d4f22522..18a5d57a62 100644 --- a/test/files/neg/t4928.check +++ b/test/files/neg/t4928.check @@ -1,5 +1,5 @@ t4928.scala:3: error: parameter 'a' is already specified at parameter position 1 -Note that that 'z' is not a parameter name of the invoked method. +Note that 'z' is not a parameter name of the invoked method. f(z = 0, a = 1) ^ one error found diff --git a/test/files/neg/t5689.check b/test/files/neg/t5689.check index e74de40280..9271f709ca 100644 --- a/test/files/neg/t5689.check +++ b/test/files/neg/t5689.check @@ -1,8 +1,8 @@ -t5689.scala:4: error: macro implementation has wrong shape: +t5689.scala:4: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.BlackboxContext)(i: c.Expr[Double]): c.Expr[String] or : (c: scala.reflect.macros.BlackboxContext)(i: c.Tree): c.Tree found : (c: scala.reflect.macros.BlackboxContext)(i: c.Expr[Double]): c.Expr[Int] type mismatch for return type: c.Expr[Int] does not conform to c.Expr[String] def returnsString(i: Double): String = macro returnsIntImpl - ^ + ^ one error found diff --git a/test/files/neg/t5753/Impls_Macros_1.scala b/test/files/neg/t5753/Impls_Macros_1.scala index f93d731d40..0e81e21c77 100644 --- a/test/files/neg/t5753/Impls_Macros_1.scala +++ b/test/files/neg/t5753/Impls_Macros_1.scala @@ -1,6 +1,6 @@ import scala.reflect.macros.{BlackboxContext => Ctx} trait Impls { -def impl(c: Ctx)(x: c.Expr[Any]) = x + def impl(c: Ctx)(x: c.Expr[Any]) = x } diff --git a/test/files/neg/t5753/Test_2.scala b/test/files/neg/t5753/Test_2.scala index f1cad67fed..150850a0eb 100644 --- a/test/files/neg/t5753/Test_2.scala +++ b/test/files/neg/t5753/Test_2.scala @@ -1,7 +1,7 @@ import scala.reflect.macros.{BlackboxContext => Ctx} object Macros extends Impls { - def foo(x: Any) = macro impl + def foo(x: Any): Any = macro impl } object Test extends App { diff --git a/test/files/neg/t5903a/Macros_1.scala b/test/files/neg/t5903a/Macros_1.scala index 7888b888e1..ce1b035260 100644 --- a/test/files/neg/t5903a/Macros_1.scala +++ b/test/files/neg/t5903a/Macros_1.scala @@ -7,7 +7,7 @@ case object SomeTree extends Tree object NewQuasiquotes { implicit class QuasiquoteInterpolation(c: StringContext) { object nq { - def unapply(t: Tree) = macro QuasiquoteMacros.unapplyImpl + def unapply(t: Tree): Any = macro QuasiquoteMacros.unapplyImpl } } } diff --git a/test/files/neg/t5903b/Macros_1.scala b/test/files/neg/t5903b/Macros_1.scala index 46f0eee0f1..dfe9d8d489 100644 --- a/test/files/neg/t5903b/Macros_1.scala +++ b/test/files/neg/t5903b/Macros_1.scala @@ -4,7 +4,7 @@ import language.experimental.macros object Interpolation { implicit class TestInterpolation(c: StringContext) { object t { - def unapply[T](x: T) = macro Macros.unapplyImpl[T] + def unapply[T](x: T): Any = macro Macros.unapplyImpl[T] } } } diff --git a/test/files/neg/t5903c/Macros_1.scala b/test/files/neg/t5903c/Macros_1.scala index 281a06e93c..d13c3c2ec2 100644 --- a/test/files/neg/t5903c/Macros_1.scala +++ b/test/files/neg/t5903c/Macros_1.scala @@ -4,7 +4,7 @@ import language.experimental.macros object Interpolation { implicit class TestInterpolation(c: StringContext) { object t { - def unapply[T](x: T) = macro Macros.unapplyImpl[T] + def unapply[T](x: T): Any = macro Macros.unapplyImpl[T] } } } diff --git a/test/files/neg/t5903d/Macros_1.scala b/test/files/neg/t5903d/Macros_1.scala index 5dd6220e1a..2d26e998a1 100644 --- a/test/files/neg/t5903d/Macros_1.scala +++ b/test/files/neg/t5903d/Macros_1.scala @@ -4,7 +4,7 @@ import language.experimental.macros object Interpolation { implicit class TestInterpolation(c: StringContext) { object t { - def unapply(x: Int) = macro Macros.unapplyImpl + def unapply(x: Int): Any = macro Macros.unapplyImpl } } } diff --git a/test/files/neg/t5903e/Macros_1.scala b/test/files/neg/t5903e/Macros_1.scala index 997e6fd073..5bdc25b832 100644 --- a/test/files/neg/t5903e/Macros_1.scala +++ b/test/files/neg/t5903e/Macros_1.scala @@ -4,7 +4,7 @@ import language.experimental.macros object Interpolation { implicit class TestInterpolation(c: StringContext) { object t { - def unapply(x: Int) = macro Macros.unapplyImpl + def unapply(x: Int): Any = macro Macros.unapplyImpl } } } diff --git a/test/files/neg/t6123-explaintypes-macros.check b/test/files/neg/t6123-explaintypes-macros.check index 9a0402039b..ef545fcc32 100644 --- a/test/files/neg/t6123-explaintypes-macros.check +++ b/test/files/neg/t6123-explaintypes-macros.check @@ -1,10 +1,10 @@ c.universe.Expr[Any]* <: c.universe.Expr[String]*? false -BadMac_2.scala:6: error: macro implementation has wrong shape: +BadMac_2.scala:6: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.BlackboxContext)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] or : (c: scala.reflect.macros.BlackboxContext)(format: c.Tree, params: Tree*): c.Tree found : (c: scala.reflect.macros.BlackboxContext)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit] type mismatch for parameter params: c.Expr[Any]* does not conform to c.Expr[String]* def printf(format: String, params: Any*): Unit = macro printf_impl - ^ + ^ one error found diff --git a/test/files/neg/t6231.check b/test/files/neg/t6231.check index 2428bf66d0..6e107c97c7 100644 --- a/test/files/neg/t6231.check +++ b/test/files/neg/t6231.check @@ -1,6 +1,6 @@ t6231.scala:4: error: Implementation restriction: local trait Bug$X$1 is unable to automatically capture the free variable value ev$1 on behalf of <$anon: Function0>. You can manually assign it to a val inside the trait, -and refer that that val in <$anon: Function0>. For more details, see SI-6231. +and refer to that val in <$anon: Function0>. For more details, see SI-6231. def qux = { () => ev } ^ one error found diff --git a/test/files/neg/t6446-missing.check b/test/files/neg/t6446-missing.check index cd867289c3..029c8057c3 100755 --- a/test/files/neg/t6446-missing.check +++ b/test/files/neg/t6446-missing.check @@ -1,4 +1,4 @@ -Warning: class not found: t6446.Ploogin +Error: unable to load class: t6446.Ploogin phase name id description ---------- -- ----------- parser 1 parse source into ASTs, perform simple desugaring diff --git a/test/files/neg/t712.check b/test/files/neg/t712.check index 6819dc0ce9..831e943063 100644 --- a/test/files/neg/t712.check +++ b/test/files/neg/t712.check @@ -1,4 +1,5 @@ t712.scala:10: error: value self is not a member of B.this.ParentImpl + Note: implicit method coerce is not applicable here because it comes after the application point and it lacks an explicit result type implicit def coerce(p : ParentImpl) = p.self; ^ one error found diff --git a/test/files/neg/t7519-b.check b/test/files/neg/t7519-b.check index 08d819eeec..bc8500b2b8 100644 --- a/test/files/neg/t7519-b.check +++ b/test/files/neg/t7519-b.check @@ -1,4 +1,4 @@ -Use_2.scala:6: error: type mismatch; +Use_2.scala:8: error: type mismatch; found : String required: Q val x: Q = ex.Mac.mac("asdf") diff --git a/test/files/neg/t7519-b/Use_2.scala b/test/files/neg/t7519-b/Use_2.scala index 413e40e25e..0d63eeed5b 100644 --- a/test/files/neg/t7519-b/Use_2.scala +++ b/test/files/neg/t7519-b/Use_2.scala @@ -1,3 +1,5 @@ +import scala.language.implicitConversions + trait Q trait K diff --git a/test/files/neg/t8024.check b/test/files/neg/t8024.check new file mode 100644 index 0000000000..bd551aa591 --- /dev/null +++ b/test/files/neg/t8024.check @@ -0,0 +1,6 @@ +t8024.scala:13: error: reference to sqrt is ambiguous; +it is both defined in package object p and imported subsequently by +import java.lang.Math.sqrt + sqrt(0d) + ^ +one error found diff --git a/test/files/neg/t8024.scala b/test/files/neg/t8024.scala new file mode 100644 index 0000000000..b4c2c5ebb9 --- /dev/null +++ b/test/files/neg/t8024.scala @@ -0,0 +1,14 @@ +package p + +trait NRoot[A] + +object `package` { + final def sqrt(x: Double): Double = Math.sqrt(x) + final def sqrt[A](a: A)(implicit ev: NRoot[A]): A = ??? +} + +object FastComplex { + import java.lang.Math.sqrt + + sqrt(0d) +} diff --git a/test/files/neg/t8024b.check b/test/files/neg/t8024b.check new file mode 100644 index 0000000000..9cd89bca53 --- /dev/null +++ b/test/files/neg/t8024b.check @@ -0,0 +1,6 @@ +t8024b.scala:15: error: reference to sqrt is ambiguous; +it is both defined in object FastComplex and imported subsequently by +import java.lang.Math.sqrt + sqrt(0d) + ^ +one error found diff --git a/test/files/neg/t8024b.scala b/test/files/neg/t8024b.scala new file mode 100644 index 0000000000..cf3d496365 --- /dev/null +++ b/test/files/neg/t8024b.scala @@ -0,0 +1,17 @@ +package p + +trait NRoot[A] + +object FastComplex { + final def sqrt(x: Double): Double = Math.sqrt(x) + final def sqrt[A](a: A)(implicit ev: NRoot[A]): A = ??? + + object Inner { + import java.lang.Math.sqrt + + // wrong message: + // error: reference to sqrt is ambiguous; + // it is both defined in object FastComplex and imported subsequently by + sqrt(0d) + } +} diff --git a/test/files/pos/macro-implicit-invalidate-on-error.scala b/test/files/pos/macro-implicit-invalidate-on-error.scala index 22cd2d34b4..f9756d965f 100644 --- a/test/files/pos/macro-implicit-invalidate-on-error.scala +++ b/test/files/pos/macro-implicit-invalidate-on-error.scala @@ -1,23 +1,20 @@ -package scala.reflect -package api - import scala.language.experimental.macros import scala.reflect.macros.Context -trait Liftable[T] { - def apply(universe: api.Universe, value: T): universe.Tree +trait LegacyLiftable[T] { + def apply(universe: scala.reflect.api.Universe, value: T): universe.Tree } -object Liftable { - implicit def liftCaseClass[T <: Product]: Liftable[T] = macro liftCaseClassImpl[T] +object LegacyLiftable { + implicit def liftCaseClass[T <: Product]: LegacyLiftable[T] = macro liftCaseClassImpl[T] - def liftCaseClassImpl[T: c.WeakTypeTag](c: Context): c.Expr[Liftable[T]] = { + def liftCaseClassImpl[T: c.WeakTypeTag](c: Context): c.Expr[LegacyLiftable[T]] = { import c.universe._ val tpe = weakTypeOf[T] if (!tpe.typeSymbol.asClass.isCaseClass) c.abort(c.enclosingPosition, "denied") val p = List(q"Literal(Constant(1))") - c.Expr[Liftable[T]] { q""" - new scala.reflect.api.Liftable[$tpe] { + c.Expr[LegacyLiftable[T]] { q""" + new LegacyLiftable[$tpe] { def apply(universe: scala.reflect.api.Universe, value: $tpe): universe.Tree = { import universe._ Apply(Select(Ident(TermName("C")), TermName("apply")), List(..$p)) diff --git a/test/files/pos/specializes-sym-crash.scala b/test/files/pos/specializes-sym-crash.scala index c46f435ac4..7778ba277b 100644 --- a/test/files/pos/specializes-sym-crash.scala +++ b/test/files/pos/specializes-sym-crash.scala @@ -2,11 +2,11 @@ import scala.collection._ trait Foo[+A, +Coll, - +This <: GenSeqView[A, Coll] with GenSeqViewLike[A, Coll, This]] -extends GenSeq[A] with GenSeqLike[A, This] with GenIterableView[A, Coll] with GenIterableViewLike[A, Coll, This] { + +This <: SeqView[A, Coll] with SeqViewLike[A, Coll, This]] +extends Seq[A] with SeqLike[A, This] with IterableView[A, Coll] with IterableViewLike[A, Coll, This] { self => - trait Transformed[+B] extends GenSeqView[B, Coll] with super.Transformed[B] { + trait Transformed[+B] extends SeqView[B, Coll] with super.Transformed[B] { def length: Int def apply(idx: Int): B override def toString = viewToString diff --git a/test/files/pos/t4365/a_1.scala b/test/files/pos/t4365/a_1.scala index 6f3405b1ff..a24b57772d 100644 --- a/test/files/pos/t4365/a_1.scala +++ b/test/files/pos/t4365/a_1.scala @@ -2,8 +2,8 @@ import scala.collection._ trait SeqViewLike[+A, +Coll, - +This <: SeqView[A, Coll] with SeqViewLike[A, Coll, This]] - extends Seq[A] with GenSeqViewLike[A, Coll, This] + +This <: SeqView[A, Coll] with SeqViewLike[A, Coll, Nothing]] + extends Seq[A] with GenSeqViewLike[A, Coll, Nothing] { trait Transformed[+B] extends super[GenSeqViewLike].Transformed[B] diff --git a/test/files/pos/t4365/b_1.scala b/test/files/pos/t4365/b_1.scala index e5b5687185..e1423813f1 100644 --- a/test/files/pos/t4365/b_1.scala +++ b/test/files/pos/t4365/b_1.scala @@ -1,9 +1,11 @@ import scala.collection._ +trait GenSeqView0[+A, +Coll] + trait GenSeqViewLike[+A, +Coll, - +This <: GenSeqView[A, Coll] with GenSeqViewLike[A, Coll, This]] -extends GenSeq[A] { + +This <: GenSeqView0[A, Coll] with GenSeqViewLike[A, Coll, Nothing]] +extends GenSeq[A] { self => trait Transformed[+B] { diff --git a/test/files/pos/t6780.scala b/test/files/pos/t6780.scala new file mode 100644 index 0000000000..4a358046c6 --- /dev/null +++ b/test/files/pos/t6780.scala @@ -0,0 +1,20 @@ +object O { + implicit def i: Int = 0 +} + +import O._ + +trait Foo { + implicit val v1: Any + implicit def d1: Any + val v2: Any + implicit val v3: Any +} + +trait Bar1 extends Foo { + implicit val v1 = {implicitly[Int]; ()} // failed due to cycle in Context#implicits being broken with Nil. + def d1 = {implicitly[Int]; ()} // okay + implicit val v2 = {implicitly[Int]; ()} // okay + implicit val v3: Any = {implicitly[Int]; ()} // okay + +} diff --git a/test/files/pos/t8001/Macros_1.scala b/test/files/pos/t8001/Macros_1.scala index 1f8dab51c1..fd26016d4b 100644 --- a/test/files/pos/t8001/Macros_1.scala +++ b/test/files/pos/t8001/Macros_1.scala @@ -2,7 +2,7 @@ import scala.language.experimental.macros import scala.reflect.macros.BlackboxContext object Macros { - def foo = macro impl + def foo: Unit = macro impl def impl(c: BlackboxContext) = { import c.universe._ q"()" diff --git a/test/files/pos/t8013.flags b/test/files/pos/t8013.flags new file mode 100644 index 0000000000..954eaba352 --- /dev/null +++ b/test/files/pos/t8013.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Xlint diff --git a/test/files/pos/t8013/inpervolated_2.scala b/test/files/pos/t8013/inpervolated_2.scala new file mode 100644 index 0000000000..90e571b42c --- /dev/null +++ b/test/files/pos/t8013/inpervolated_2.scala @@ -0,0 +1,11 @@ +/* + * scalac: -Xfatal-warnings -Xlint + */ +package t8013 + +// unsuspecting user of perverse macro +trait User { + import Perverse.Impervolator + val foo = "bar" + Console println p"Hello, $foo" +} diff --git a/test/files/pos/t8013/inpervolator_1.scala b/test/files/pos/t8013/inpervolator_1.scala new file mode 100644 index 0000000000..fb71571afc --- /dev/null +++ b/test/files/pos/t8013/inpervolator_1.scala @@ -0,0 +1,33 @@ + +package t8013 + +// perverse macro to confuse Xlint + +import scala.language.experimental.macros +import scala.reflect.macros.{ BlackboxContext => Context } + +object Perverse { + + implicit class Impervolator(sc: StringContext) { + def p(args: Any*): String = macro pImpl + } + + // turn a nice interpolation into something that looks + // nothing like an interpolation or anything we might + // recognize, but which includes a "$id" in an apply. + def pImpl(c: Context)(args: c.Expr[Any]*): c.Expr[String] = { + import c.universe._ + val macroPos = c.macroApplication.pos + val text = macroPos.lineContent substring macroPos.column + val tt = Literal(Constant(text)) + val tree = q"t8013.Perverse.pervert($tt)" + c.Expr[String](tree) + } + + // identity doesn't seem very perverse in this context + //def pervert(text: String): String = text + def pervert(text: String): String = { + Console println s"Perverting [$text]" + text + } +} diff --git a/test/files/pos/t8023.scala b/test/files/pos/t8023.scala new file mode 100644 index 0000000000..86824084ed --- /dev/null +++ b/test/files/pos/t8023.scala @@ -0,0 +1,22 @@ +import language._ + + +object Test { + def foo = (null: Any) match { + case a: A[k] => + // error: kinds of the type arguments (k) do not conform to the + // expected kinds of the type parameters (type K) in class B. + new B[k]() + } +} + +class A[K[L[_]]] + +class B[K[M[_]]] + + +object Test2 { + def foo = (null: Any) match { + case a: A[k] => new B[k]() // this one worked before as the info of `A` was complete + } +} diff --git a/test/files/pos/t8023b.scala b/test/files/pos/t8023b.scala new file mode 100644 index 0000000000..94c9b2f8d2 --- /dev/null +++ b/test/files/pos/t8023b.scala @@ -0,0 +1,2 @@ +// this fails with naive attempts to fix SI-8023 +trait T[A <: T[A]] diff --git a/test/files/pos/t8054.scala b/test/files/pos/t8054.scala new file mode 100644 index 0000000000..a7bb44b1ed --- /dev/null +++ b/test/files/pos/t8054.scala @@ -0,0 +1,31 @@ +trait D { + trait Manifest { + class Entry + } + + val M: Manifest + + def m: M.Entry = ??? +} + +object D1 extends D { + object M extends Manifest +} + +object D2 extends D { + val M: Manifest = ??? +} + +object Hello { + + def main(args: Array[String]) { + // 2.10.3 - ok + // 2.11.0-M7 - type mismatch; found : Seq[DB1.MANIFEST.Entry] + // required: Seq[DB1.MANIFEST.Entry] + val t1: D1.M.Entry = D1.m + + // 2.10.3 - ok + // 2.11.0-M7 - ok + val t2: D2.M.Entry = D2.m + } +} diff --git a/test/files/pos/t8060.scala b/test/files/pos/t8060.scala new file mode 100644 index 0000000000..90e014d74b --- /dev/null +++ b/test/files/pos/t8060.scala @@ -0,0 +1,11 @@ +trait M[F[_]] + +trait P[A] { + type CC[X] = P[X] + def f(p: A => Boolean): M[CC] +} + +trait Other { + // was infinite loop trying to dealias `x$1.CC` + def g[A](p: A => Boolean): P[A] => M[P] = _ f p +} diff --git a/test/files/presentation/ide-t1001326.check b/test/files/presentation/ide-t1001326.check deleted file mode 100644 index 0ac15faed4..0000000000 --- a/test/files/presentation/ide-t1001326.check +++ /dev/null @@ -1,4 +0,0 @@ -Unique OK -Unattributed OK -NeverModify OK -AlwaysParseTree OK
\ No newline at end of file diff --git a/test/files/presentation/ide-t1001326/src/a/A.scala b/test/files/presentation/ide-t1001326/src/a/A.scala deleted file mode 100644 index c82ca02231..0000000000 --- a/test/files/presentation/ide-t1001326/src/a/A.scala +++ /dev/null @@ -1,5 +0,0 @@ -package a - -class A { - def foo(s: String) = s + s -}
\ No newline at end of file diff --git a/test/files/presentation/ide-t1001388.check b/test/files/presentation/ide-t1001388.check new file mode 100644 index 0000000000..d58f86d6c6 --- /dev/null +++ b/test/files/presentation/ide-t1001388.check @@ -0,0 +1 @@ +Test OK
\ No newline at end of file diff --git a/test/files/presentation/ide-t1001388/Test.scala b/test/files/presentation/ide-t1001388/Test.scala new file mode 100644 index 0000000000..f6079cf0b2 --- /dev/null +++ b/test/files/presentation/ide-t1001388/Test.scala @@ -0,0 +1,28 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest +import scala.reflect.internal.util.SourceFile +import scala.tools.nsc.interactive.Response + +object Test extends InteractiveTest { + override def execute(): Unit = { + val sourceA = loadSourceAndWaitUntilTypechecked("A.scala") + checkPresent(sourceA) + } + + private def loadSourceAndWaitUntilTypechecked(sourceName: String): SourceFile = { + val sourceFile = sourceFiles.find(_.file.name == sourceName).head + askLoadedTyped(sourceFile).get + /* The response to `askLoadedType` may return before `interactive.Global.waitLoadedType` + * fully executes. Because this test expects `waitLoadedType` is fully executed before + * calling `checkPresent`, with the below no-op presentation compiler request we make + * sure this requirement is fulfilled. + */ + compiler.askForResponse(() => ()).get + sourceFile + } + + private def checkPresent(source: SourceFile): Unit = compiler.getUnitOf(source) match { + case Some(unit) => reporter.println("Compilation Unit for " + source.file.name + " still loaded after askLoadedTyped") + + case None => reporter.println("Test OK") + } +} diff --git a/test/files/presentation/ide-t1001388/src/a/A.scala b/test/files/presentation/ide-t1001388/src/a/A.scala new file mode 100644 index 0000000000..be09097598 --- /dev/null +++ b/test/files/presentation/ide-t1001388/src/a/A.scala @@ -0,0 +1,6 @@ +package a + +object A { + val tagString = "foo" + Seq.empty[Byte].toArray.toSeq +} diff --git a/test/files/presentation/parse-invariants.check b/test/files/presentation/parse-invariants.check new file mode 100644 index 0000000000..32e9c846ab --- /dev/null +++ b/test/files/presentation/parse-invariants.check @@ -0,0 +1,5 @@ +NoNewSymbolsEntered OK +Unique OK +Unattributed OK +NeverModify OK +AlwaysParseTree OK diff --git a/test/files/presentation/ide-t1001326/Test.scala b/test/files/presentation/parse-invariants/Test.scala index ff63b9770a..128896ccaa 100644 --- a/test/files/presentation/ide-t1001326/Test.scala +++ b/test/files/presentation/parse-invariants/Test.scala @@ -6,16 +6,32 @@ object Test extends InteractiveTest { override def execute(): Unit = { val sf = sourceFiles.find(_.file.name == "A.scala").head - uniqueParseTree_t1001326(sf) - unattributedParseTree_t1001326(sf) - neverModifyParseTree_t1001326(sf) - shouldAlwaysReturnParseTree_t1001326(sf) + noNewSymbols(sf) + uniqueParseTree(sf) + unattributedParseTree(sf) + neverModifyParseTree(sf) + shouldAlwaysReturnParseTree(sf) + } + + /** + * Asking for a parseTree should not enter any new symbols. + */ + private def noNewSymbols(sf: SourceFile) { + def nextId() = compiler.NoSymbol.newTermSymbol(compiler.TermName("dummy"), compiler.NoPosition, compiler.NoFlags).id + val id = nextId() + val tree = compiler.parseTree(sf) + val id2 = nextId() + if (id2 == id + 1) { + reporter.println("NoNewSymbolsEntered OK") + } else { + reporter.println("NoNewSymbolsEntered FAILED") + } } /** * Asking twice for a parseTree on the same source should always return a new tree */ - private def uniqueParseTree_t1001326(sf: SourceFile) { + private def uniqueParseTree(sf: SourceFile) { val parseTree1 = compiler.parseTree(sf) val parseTree2 = compiler.parseTree(sf) if (parseTree1 != parseTree2) { @@ -28,7 +44,7 @@ object Test extends InteractiveTest { /** * A parseTree should never contain any symbols or types */ - private def unattributedParseTree_t1001326(sf: SourceFile) { + private def unattributedParseTree(sf: SourceFile) { if (noSymbolsOrTypes(compiler.parseTree(sf))) { reporter.println("Unattributed OK") } else { @@ -39,7 +55,7 @@ object Test extends InteractiveTest { /** * Once you have obtained a parseTree it should never change */ - private def neverModifyParseTree_t1001326(sf: SourceFile) { + private def neverModifyParseTree(sf: SourceFile) { val parsedTree = compiler.parseTree(sf) loadSourceAndWaitUntilTypechecked(sf) if (noSymbolsOrTypes(parsedTree)) { @@ -52,7 +68,7 @@ object Test extends InteractiveTest { /** * Should always return a parse tree */ - private def shouldAlwaysReturnParseTree_t1001326(sf: SourceFile) { + private def shouldAlwaysReturnParseTree(sf: SourceFile) { loadSourceAndWaitUntilTypechecked(sf) if (noSymbolsOrTypes(compiler.parseTree(sf))) { reporter.println("AlwaysParseTree OK") diff --git a/test/files/presentation/parse-invariants/src/a/A.scala b/test/files/presentation/parse-invariants/src/a/A.scala new file mode 100644 index 0000000000..1ae78cad05 --- /dev/null +++ b/test/files/presentation/parse-invariants/src/a/A.scala @@ -0,0 +1,138 @@ +package syntax + +object Terms { + object Literals { + 0 + 0l + 0f + 0d + 0xb33f + 'c' + "string" + """ + multi-line + string + """ + 'symbol + true + false + null + () + } + + object Patterns { + 0 match { case 0 => } + 1 match { case (0 | 1) => } + 2 match { case _: Int => } + 3 match { case _ => } + Some(0) match { case Some(0) => } + Some(0) match { case name @ Some(_) => } + Some(Some(0)) match { case nested @ Some(deeper @ Some(_)) => } + List(1, 2, 3) match { case unapplySeq @ List(1, 2, _*) => } + 0 match { case i if i > 0 => } + List(1) match { case _: List[t] => List.empty[t] } + } + + object New { + class Foo + trait Bar + new Foo + new Foo { selfie => } + new Foo with Bar + new { val early = 1 } with Bar + new { val name = "anon "} + } + + def tuple = (1, 'two, "three") + def lambda = (x: Int, y: Int) => x + y + def lambda2 = (_: Int) + (_: Int) + def blocks = { { {}; {} }; {} } + def ascription = (1: Int) + def select = Nil.size + def method1 = "s".replace("foo", "bar") + def method2 = "s" + "s" + def method3 = Nil.foreach { e => } + def method4 = 1 :: 2 :: 3 :: Nil + def if1 = if (true) true else false + def if2 = if (true) true + def `return`: Int = { return 0 } + def `throw` = throw new Exception + def `match` = 0 match { case 0 => case _ => } + def `try` = try 0 catch { case _ => } finally 0 + def `while` = while(true) 0 + def `do while` = do 0 while(true) + def `for` = for (i <- 1 to 10; if i % 2 == 0; j = i + 1) j + def `for yield` = for (a <- List(List(1)); b <- a; c = b * 2) yield b + def interpolation = s"$tuple and maybe also $blocks" + def assign = { var x = 1; x = 2 } + def assign2 = { object o { var x = 1 }; o.x = 2 } + def update = { val v = collection.mutable.Seq(1); v(0) = 2 } + def `this` = this +} + +object Types { + type Reference = scala.App + type Tuple = (Int, String, Double) + type Function = (Int, String) => Double + type Refined = Int { val meta: Any } + type Lambda = ({ type F[T] = List[T] })#F[_] + type Infix = Int Either String + type Application = List[Int] + type Existential = List[T] forSome { type T } + object O { type T = Int } + type Dependent = O.T + class O { type T = Int } + type Selection = O#T +} + +object Definitions { + private val x1 = 0 + private[this] val x2 = 0 + private[Definitions] val x3 = 0 + protected val x4 = 0 + protected[AcessManagement] val x5 = 0 + val x1 = 1 + val x2: Int = 1 + val x3, y3 = 1 + lazy val x4 = 1 + implicit val x5 = 1 + final val x6 = 1 + lazy final val x7 = 1 + val Some(x8) = Some(0) + var x9 = 1 + var x10, y10 = 1 + var x11: Int = 1 + + implicit def implicitView: Option[Int] = None + def implicitArg1(implicit i: Int) = i + 2 + def implicitArg2[T: Fooable] = implicitly[Fooable[T]] + def bound1[T <: Int](x: T): T = x + def bound2[T >: Any](x: T): T = x + def bound3[T <% Int](x: T): Int = x + def vararg(args: Int*) = args.toList + def sum(x: Int, y: Int) = x + y + def multipleArgLists(x: Int)(y: Int) = x + y + + type _0 = Int + type _1[T] = List[T] + type _2[A, B] = Either[A, B] + + class Val(value: Int) extends AnyVal + implicit class Impl(value: Int) { def foo = "foo" } + abstract class Abs + sealed class Sealed + class Child extends Sealed + case class Point(x: Int, y: Int) + + trait Fooable[T] + trait Barable with Fooable[Barable] + + object Foo + object Foo with Fooable[Foo] + case object Zero +} + +package Packages { + package object PackageObject + package Nested { package Deeper { } } +} diff --git a/test/files/presentation/scope-completion-2.check b/test/files/presentation/scope-completion-2.check index 3a1dbd7cff..d94f7a4b56 100644 --- a/test/files/presentation/scope-completion-2.check +++ b/test/files/presentation/scope-completion-2.check @@ -1,12 +1,11 @@ reload: Completions.scala -askScopeCompletion at Completions.scala(16,4) +askScopeCompletion at Completions.scala(15,2) ================================================================================ -[response] askScopeCompletion at (16,4) -retrieved 11 members +[response] askScopeCompletion at (15,2) +retrieved 10 members class Completion1 extends AnyRef def <init>(): test.Completion1 -def test: Unit object Completion1 private class Cc1 extends AnyRef private class Co1 extends AnyRef @@ -17,19 +16,18 @@ private[this] val vc1: Int private[this] val vo1: Int ================================================================================ -askScopeCompletion at Completions.scala(32,4) +askScopeCompletion at Completions.scala(29,2) ================================================================================ -[response] askScopeCompletion at (32,4) -retrieved 11 members -[inaccessible] private[this] val vc1: Int +[response] askScopeCompletion at (29,2) +retrieved 10 members class Completion1 extends AnyRef def <init>(): test.Completion1.type -def test: Unit object Completion1 private class Cc1 extends AnyRef private class Co1 extends AnyRef private def fc1: Int private def fo1: Int private[this] val c: test.Completion1 +private[this] val vc1: Int private[this] val vo1: Int ================================================================================ diff --git a/test/files/presentation/scope-completion-2/src/Completions.scala b/test/files/presentation/scope-completion-2/src/Completions.scala index 96d38f1b85..f8d7cd6ba8 100644 --- a/test/files/presentation/scope-completion-2/src/Completions.scala +++ b/test/files/presentation/scope-completion-2/src/Completions.scala @@ -9,12 +9,10 @@ class Completion1 { private val vc1 = 0 private def fc1 = 0 - private class Cc1 - - def test { - // needs to be done in a method, because of SI-7280 - /*_*/ + private class Cc1 { } + + /*_*/ } object Completion1 { @@ -25,11 +23,9 @@ object Completion1 { private val vo1 = 0 private def fo1 = 0 - private class Co1 - - def test { - // needs to be done in a method, because of SI-7280 - /*_*/ + private class Co1 { } + + /*_*/ } diff --git a/test/files/presentation/scope-completion-3.check b/test/files/presentation/scope-completion-3.check index cf73e89a3b..df3007ab4e 100644 --- a/test/files/presentation/scope-completion-3.check +++ b/test/files/presentation/scope-completion-3.check @@ -12,13 +12,9 @@ retrieved 49 members [inaccessible] private object Ot2 [inaccessible] private type tb2 = Completion1.this.tb2 [inaccessible] private type tt2 = Completion1.this.tt2 -[inaccessible] private[this] val vb1: Int [inaccessible] private[this] val vb2: Int -[inaccessible] private[this] val vt1: Int [inaccessible] private[this] val vt2: Int -[inaccessible] private[this] var rb1: Int [inaccessible] private[this] var rb2: Int -[inaccessible] private[this] var rt1: Int [inaccessible] private[this] var rt2: Int abstract class Base1 extends AnyRef abstract trait Trait1 extends AnyRef @@ -42,13 +38,17 @@ private class Cc2 extends AnyRef private def fc2: Int private object Oc2 private type tc2 = Completion1.this.tc2 +private[this] val vb1: Int private[this] val vb3: Int private[this] val vc1: Int private[this] val vc2: Int +private[this] val vt1: Int private[this] val vt3: Int +private[this] var rb1: Int private[this] var rb3: Int private[this] var rc1: Int private[this] var rc2: Int +private[this] var rt1: Int private[this] var rt3: Int type tb1 = Completion1.this.tb1 type tc1 = Completion1.this.tc1 @@ -67,13 +67,9 @@ retrieved 49 members [inaccessible] private object Ot2 [inaccessible] private type tb2 = test.Completion2.tb2 [inaccessible] private type tt2 = test.Completion2.tt2 -[inaccessible] private[this] val vb1: Int [inaccessible] private[this] val vb2: Int -[inaccessible] private[this] val vt1: Int [inaccessible] private[this] val vt2: Int -[inaccessible] private[this] var rb1: Int [inaccessible] private[this] var rb2: Int -[inaccessible] private[this] var rt1: Int [inaccessible] private[this] var rt2: Int abstract class Base1 extends AnyRef abstract trait Trait1 extends AnyRef @@ -97,13 +93,17 @@ private class Co2 extends AnyRef private def fo2: Int private object Oo2 private type to2 = test.Completion2.to2 +private[this] val vb1: Int private[this] val vb3: Int private[this] val vo1: Int private[this] val vo2: Int +private[this] val vt1: Int private[this] val vt3: Int +private[this] var rb1: Int private[this] var rb3: Int private[this] var ro1: Int private[this] var ro2: Int +private[this] var rt1: Int private[this] var rt3: Int type tb1 = test.Completion2.tb1 type to1 = test.Completion2.to1 diff --git a/test/files/presentation/scope-completion-import.check b/test/files/presentation/scope-completion-import.check index d518b0c37a..220ffc399b 100644 --- a/test/files/presentation/scope-completion-import.check +++ b/test/files/presentation/scope-completion-import.check @@ -1,9 +1,13 @@ reload: Completions.scala -askScopeCompletion at Completions.scala(15,4) -================================================================================ -[response] askScopeCompletion at (15,4) -retrieved 10 members +askScopeCompletion at Completions.scala(23,4) +================================================================================ +[response] askScopeCompletion at (23,4) +retrieved 18 members +[inaccessible] private[this] val pVCCC: Int +[inaccessible] private[this] val pVOOO: Int +[inaccessible] private[this] var pRCCC: Int +[inaccessible] private[this] var pROOO: Int class C extends AnyRef class Foo extends AnyRef class Foo_1 extends AnyRef @@ -13,13 +17,21 @@ def <init>(): test.Foo def fCCC: Int def fOOO: Int object O +private[this] val vCCC: Int +private[this] val vOOO: Int +private[this] var rCCC: Int +private[this] var rOOO: Int val o: test.O.type ================================================================================ -askScopeCompletion at Completions.scala(19,4) -================================================================================ -[response] askScopeCompletion at (19,4) -retrieved 9 members +askScopeCompletion at Completions.scala(27,4) +================================================================================ +[response] askScopeCompletion at (27,4) +retrieved 17 members +[inaccessible] private[this] val pVCCC: Int +[inaccessible] private[this] val pVOOO: Int +[inaccessible] private[this] var pRCCC: Int +[inaccessible] private[this] var pROOO: Int class C extends AnyRef class Foo extends AnyRef class Foo_1 extends AnyRef @@ -29,12 +41,18 @@ def <init>(): test.Foo def fCCC: Int def fOOO: Int object O +private[this] val vCCC: Int +private[this] val vOOO: Int +private[this] var rCCC: Int +private[this] var rOOO: Int ================================================================================ -askScopeCompletion at Completions.scala(24,4) +askScopeCompletion at Completions.scala(32,4) ================================================================================ -[response] askScopeCompletion at (24,4) -retrieved 9 members +[response] askScopeCompletion at (32,4) +retrieved 13 members +[inaccessible] private[this] val pVCCC: Int +[inaccessible] private[this] var pRCCC: Int class C extends AnyRef class Foo extends AnyRef class Foo_1 extends AnyRef @@ -43,12 +61,14 @@ class Foo_3 extends AnyRef def <init>(): test.Foo def fCCC: Int object O +private[this] val vCCC: Int +private[this] var rCCC: Int val c: test.C ================================================================================ -askScopeCompletion at Completions.scala(27,5) +askScopeCompletion at Completions.scala(35,5) ================================================================================ -[response] askScopeCompletion at (27,5) +[response] askScopeCompletion at (35,5) retrieved 8 members class C extends AnyRef class Foo extends AnyRef @@ -60,10 +80,12 @@ object O val c: test.C ================================================================================ -askScopeCompletion at Completions.scala(30,5) +askScopeCompletion at Completions.scala(38,5) ================================================================================ -[response] askScopeCompletion at (30,5) -retrieved 9 members +[response] askScopeCompletion at (38,5) +retrieved 13 members +[inaccessible] private[this] val pVCCC: Int +[inaccessible] private[this] var pRCCC: Int class C extends AnyRef class Foo extends AnyRef class Foo_1 extends AnyRef @@ -72,13 +94,19 @@ class Foo_3 extends AnyRef def <init>(): test.Foo def fCCC: Int object O +private[this] val vCCC: Int +private[this] var rCCC: Int val c: test.C ================================================================================ -askScopeCompletion at Completions.scala(32,5) -================================================================================ -[response] askScopeCompletion at (32,5) -retrieved 10 members +askScopeCompletion at Completions.scala(40,5) +================================================================================ +[response] askScopeCompletion at (40,5) +retrieved 18 members +[inaccessible] private[this] val pVCCC: Int +[inaccessible] private[this] val pVOOO: Int +[inaccessible] private[this] var pRCCC: Int +[inaccessible] private[this] var pROOO: Int class C extends AnyRef class Foo extends AnyRef class Foo_1 extends AnyRef @@ -88,13 +116,21 @@ def <init>(): test.Foo def fCCC: Int def fOOO: Int object O +private[this] val vCCC: Int +private[this] val vOOO: Int +private[this] var rCCC: Int +private[this] var rOOO: Int val c: test.C ================================================================================ -askScopeCompletion at Completions.scala(41,4) -================================================================================ -[response] askScopeCompletion at (41,4) -retrieved 10 members +askScopeCompletion at Completions.scala(49,4) +================================================================================ +[response] askScopeCompletion at (49,4) +retrieved 18 members +[inaccessible] private[this] val pVCCC: Int +[inaccessible] private[this] val pVOOO: Int +[inaccessible] private[this] var pRCCC: Int +[inaccessible] private[this] var pROOO: Int class C extends AnyRef class Foo extends AnyRef class Foo_1 extends AnyRef @@ -105,12 +141,20 @@ def bar: Unit def fCCC: Int def fOOO: Int object O +private[this] val vCCC: Int +private[this] val vOOO: Int +private[this] var rCCC: Int +private[this] var rOOO: Int ================================================================================ -askScopeCompletion at Completions.scala(51,4) -================================================================================ -[response] askScopeCompletion at (51,4) -retrieved 11 members +askScopeCompletion at Completions.scala(59,4) +================================================================================ +[response] askScopeCompletion at (59,4) +retrieved 19 members +[inaccessible] private[this] val pVCCC: Int +[inaccessible] private[this] val pVOOO: Int +[inaccessible] private[this] var pRCCC: Int +[inaccessible] private[this] var pROOO: Int class C extends AnyRef class Foo extends AnyRef class Foo_1 extends AnyRef @@ -122,12 +166,18 @@ def fCCC: Int def fOOO: Int object O private[this] val o: test.O.type +private[this] val vCCC: Int +private[this] val vOOO: Int +private[this] var rCCC: Int +private[this] var rOOO: Int ================================================================================ -askScopeCompletion at Completions.scala(61,4) +askScopeCompletion at Completions.scala(69,4) ================================================================================ -[response] askScopeCompletion at (61,4) -retrieved 10 members +[response] askScopeCompletion at (69,4) +retrieved 14 members +[inaccessible] private[this] val pVCCC: Int +[inaccessible] private[this] var pRCCC: Int class C extends AnyRef class Foo extends AnyRef class Foo_1 extends AnyRef @@ -138,4 +188,6 @@ def bar: Unit def fCCC: Int object O private[this] val c: test.C +private[this] val vCCC: Int +private[this] var rCCC: Int ================================================================================ diff --git a/test/files/presentation/scope-completion-import/src/Completions.scala b/test/files/presentation/scope-completion-import/src/Completions.scala index 6e08321283..d30aa0b4e3 100644 --- a/test/files/presentation/scope-completion-import/src/Completions.scala +++ b/test/files/presentation/scope-completion-import/src/Completions.scala @@ -1,10 +1,18 @@ package test class C { + val vCCC : Int = 0 + var rCCC : Int = 0 + private val pVCCC : Int = 0 + private var pRCCC : Int = 0 def fCCC : Int = 0 } object O extends C { + val vOOO : Int = 0 + var rOOO : Int = 0 + private val pVOOO : Int = 0 + private var pROOO : Int = 0 def fOOO : Int = 0 } diff --git a/test/files/presentation/t7548.check b/test/files/presentation/t7548.check new file mode 100644 index 0000000000..5bfb0d27fe --- /dev/null +++ b/test/files/presentation/t7548.check @@ -0,0 +1 @@ +(x: Int)Unit diff --git a/test/files/presentation/t7548/Test.scala b/test/files/presentation/t7548/Test.scala new file mode 100644 index 0000000000..94a6048056 --- /dev/null +++ b/test/files/presentation/t7548/Test.scala @@ -0,0 +1,17 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest { + override protected def loadSources() { /* don't parse or typecheck sources */ } + + import compiler._ + + override def runDefaultTests() { + val res = new Response[Tree] + val pos = compiler.rangePos(sourceFiles.head, 102,102,102) + compiler.askTypeAt(pos, res) + res.get match { + case Left(tree) => compiler.ask(() => reporter.println(tree.tpe)) + case Right(ex) => reporter.println(ex) + } + } +} diff --git a/test/files/presentation/t7548/src/Foo.scala b/test/files/presentation/t7548/src/Foo.scala new file mode 100644 index 0000000000..cc997f6e5f --- /dev/null +++ b/test/files/presentation/t7548/src/Foo.scala @@ -0,0 +1,7 @@ +object Foo { + def foo(x: Int) = {} + def foo(x: String) = {} + def foo(x: Int, y: String) = {} + + foo(2) +}
\ No newline at end of file diff --git a/test/files/presentation/t7548b.check b/test/files/presentation/t7548b.check new file mode 100644 index 0000000000..35445fedf6 --- /dev/null +++ b/test/files/presentation/t7548b.check @@ -0,0 +1 @@ +Foo.this.I2BI(Foo.this.I).+: (other: Foo.BI.type)Unit diff --git a/test/files/presentation/t7548b/Test.scala b/test/files/presentation/t7548b/Test.scala new file mode 100644 index 0000000000..0c022df839 --- /dev/null +++ b/test/files/presentation/t7548b/Test.scala @@ -0,0 +1,17 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest { + override protected def loadSources() { /* don't parse or typecheck sources */ } + + import compiler._ + + override def runDefaultTests() { + val res = new Response[Tree] + val pos = compiler.rangePos(sourceFiles.head, 191, 191, 191) // + + compiler.askTypeAt(pos, res) + res.get match { + case Left(tree) => compiler.ask(() => reporter.println(s"$tree: ${tree.tpe}")) + case Right(ex) => reporter.println(ex) + } + } +} diff --git a/test/files/presentation/t7548b/src/Foo.scala b/test/files/presentation/t7548b/src/Foo.scala new file mode 100644 index 0000000000..5cf0a4ef4e --- /dev/null +++ b/test/files/presentation/t7548b/src/Foo.scala @@ -0,0 +1,12 @@ +import language._ + +object Foo { + object I { + def +(other: I.type) : Unit = () + } + object BI { + def +(other: BI.type): Unit = () + } + implicit def I2BI(i: I.type): BI.type = BI + I.+(BI) +} diff --git a/test/files/run/iq.check b/test/files/run/iq.check index 81114ea181..311bf83ed4 100644 --- a/test/files/run/iq.check +++ b/test/files/run/iq.check @@ -1,4 +1,8 @@ Empty +q2: Queue(42, 0) +qa: Queue(42, 0) +qb: Queue(42, 0) +qc: Queue(42, 0) Head: 42 q5: Queue(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) q5[5]: 5 diff --git a/test/files/run/iq.scala b/test/files/run/iq.scala index 31859cf867..1eb1d40e37 100644 --- a/test/files/run/iq.scala +++ b/test/files/run/iq.scala @@ -16,10 +16,21 @@ object iq { Console.println("Empty") } - /* Test infix enqueing. */ - //val q2 = q + 42 + 0 // deprecated + /* Test enqueing. */ val q2 = q.enqueue(42).enqueue(0) + val qa = q :+ 42 :+ 0 + assert(q2 == qa) + + val qb = 42 +: 0 +: q + assert(q2 == qb) + val qc = 42 +: q :+ 0 + assert(q2 == qc) + Console.println("q2: " + q2) + Console.println("qa: " + qa) + Console.println("qb: " + qb) + Console.println("qc: " + qc) + /* Test is empty and dequeue. * Expected: Head: 42 */ @@ -37,7 +48,7 @@ object iq { /* Test sequence enqueing. */ val q5: Queue[Any] = q4.enqueue(List(1,2,3,4,5,6,7,8,9)) /* Test toString. - * Expected: Head: q5: Queue(0,1,2,3,4,5,6,7,8,9) + * Expected: q5: Queue(0,1,2,3,4,5,6,7,8,9) */ Console.println("q5: " + q5) /* Test apply diff --git a/test/files/run/literals.check b/test/files/run/literals.check index 5f948762b7..ed7c6ca5b3 100644 --- a/test/files/run/literals.check +++ b/test/files/run/literals.check @@ -1,4 +1,4 @@ -warning: there were 18 deprecation warning(s); re-run with -deprecation for details +warning: there were 5 deprecation warning(s); re-run with -deprecation for details test '\u0024' == '$' was successful test '\u005f' == '_' was successful test 65.asInstanceOf[Char] == 'A' was successful @@ -7,28 +7,19 @@ test "\0x61\0x62".trim() == "x61\0x62" was successful test (65 : Byte) == 'A' was successful -test 01 == 1 was successful -test 010 == 8 was successful test 0X01 == 1 was successful test 0x01 == 1 was successful test 0x10 == 16 was successful test 0xa == 10 was successful test 0x0a == 10 was successful -test +01 == 1 was successful -test +010 == 8 was successful test +0x01 == 1 was successful test +0x10 == 16 was successful test +0xa == 10 was successful test +0x0a == 10 was successful -test -01 == -1 was successful -test -010 == -8 was successful test -0x01 == -1 was successful test -0x10 == -16 was successful test -0xa == -10 was successful test -0x0a == -10 was successful -test 017777777777 == 2147483647 was successful -test 020000000000 == -2147483648 was successful -test 037777777777 == -1 was successful test 0x7fffffff == 2147483647 was successful test 0x80000000 == -2147483648 was successful test 0xffffffff == -1 was successful @@ -36,9 +27,6 @@ test 0xffffffff == -1 was successful test 1l == 1L was successful test 1L == 1l was successful test 1.asInstanceOf[Long] == 1l was successful -test 0777777777777777777777L == 9223372036854775807L was successful -test 01000000000000000000000L == -9223372036854775808L was successful -test 01777777777777777777777L == -1L was successful test 0x7fffffffffffffffL == 9223372036854775807L was successful test 0x8000000000000000L == -9223372036854775808L was successful test 0xffffffffffffffffL == -1L was successful @@ -46,6 +34,7 @@ test 0xffffffffffffffffL == -1L was successful test 1e1f == 10.0f was successful test .3f == 0.3f was successful test 0f == 0.0f was successful +test 01.23f == 1.23f was successful test 3.14f == 3.14f was successful test 6.022e23f == 6.022e23f was successful test 09f == 9.0f was successful @@ -56,6 +45,8 @@ test 1e1 == 10.0 was successful test .3 == 0.3 was successful test 0.0 == 0.0 was successful test 0d == 0.0 was successful +test 01.23 == 1.23 was successful +test 01.23d == 1.23d was successful test 3.14 == 3.14 was successful test 1e-9d == 1.0e-9 was successful test 1e137 == 1.0e137 was successful diff --git a/test/files/run/literals.scala b/test/files/run/literals.scala index 7676125339..5f23e6b492 100644 --- a/test/files/run/literals.scala +++ b/test/files/run/literals.scala @@ -47,32 +47,22 @@ object Test { println // int - check_success("01 == 1", 01, 1) - check_success("010 == 8", 010, 8) check_success("0X01 == 1", 0X01, 1) check_success("0x01 == 1", 0x01, 1) check_success("0x10 == 16", 0x10, 16) check_success("0xa == 10", 0xa, 10) check_success("0x0a == 10", 0x0a, 10) - check_success("+01 == 1", +01, 1) - check_success("+010 == 8", +010, 8) check_success("+0x01 == 1", +0x01, 1) check_success("+0x10 == 16", +0x10, 16) check_success("+0xa == 10", +0xa, 10) check_success("+0x0a == 10", +0x0a, 10) - check_success("-01 == -1", -01, -1) - check_success("-010 == -8", -010, -8) check_success("-0x01 == -1", -0x01, -1) check_success("-0x10 == -16", -0x10, -16) check_success("-0xa == -10", -0xa, -10) check_success("-0x0a == -10", -0x0a, -10) - check_success("017777777777 == 2147483647", 017777777777, 2147483647) - check_success("020000000000 == -2147483648", 020000000000, -2147483648) - check_success("037777777777 == -1", 037777777777, -1) - check_success("0x7fffffff == 2147483647", 0x7fffffff, 2147483647) check_success("0x80000000 == -2147483648", 0x80000000, -2147483648) check_success("0xffffffff == -1", 0xffffffff, -1) @@ -84,13 +74,6 @@ object Test { check_success("1L == 1l", 1L, 1l) check_success("1.asInstanceOf[Long] == 1l", 1.asInstanceOf[Long], 1l) - check_success("0777777777777777777777L == 9223372036854775807L", - 0777777777777777777777L, 9223372036854775807L) - check_success("01000000000000000000000L == -9223372036854775808L", - 01000000000000000000000L, -9223372036854775808L) - check_success("01777777777777777777777L == -1L", - 01777777777777777777777L, -1L) - check_success("0x7fffffffffffffffL == 9223372036854775807L", 0x7fffffffffffffffL, 9223372036854775807L) check_success("0x8000000000000000L == -9223372036854775808L", @@ -105,9 +88,9 @@ object Test { // float check_success("1e1f == 10.0f", 1e1f, 10.0f) - //check_success("2.f == 2.0f", 2.f, 2.0f) check_success(".3f == 0.3f", .3f, 0.3f) check_success("0f == 0.0f", 0f, 0.0f) + check_success("01.23f == 1.23f", 01.23f, 1.23f) check_success("3.14f == 3.14f", 3.14f, 3.14f) check_success("6.022e23f == 6.022e23f", 6.022e23f, 6.022e23f) check_success("09f == 9.0f", 09f, 9.0f) @@ -118,11 +101,11 @@ object Test { // double check_success("1e1 == 10.0", 1e1, 10.0) - //check_success("2. == 2.0", 2., 2.0) - //check_success("2.d == 2.0", 2.d, 2.0) check_success(".3 == 0.3", .3, 0.3) check_success("0.0 == 0.0", 0.0, 0.0) check_success("0d == 0.0", 0d, 0.0) + check_success("01.23 == 1.23", 01.23, 1.23) + check_success("01.23d == 1.23d", 01.23d, 1.23d) check_success("3.14 == 3.14", 3.14, 3.14) check_success("1e-9d == 1.0e-9", 1e-9d, 1.0e-9) check_success("1e137 == 1.0e137", 1e137, 1.0e137) diff --git a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala index 0a9f9a0ced..8506239952 100644 --- a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala +++ b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala @@ -4,7 +4,7 @@ import scala.reflect.macros.{BlackboxContext, WhiteboxContext} object Impls { def foo(c: BlackboxContext)(x: c.Expr[Int]) = x - def refToFoo(dummy: Int) = macro refToFoo_impl + def refToFoo(dummy: Int): Int = macro refToFoo_impl def refToFoo_impl(c: WhiteboxContext)(dummy: c.Expr[Int]) = { import c.universe._ val body = Select(Ident(TermName("Impls")), TermName("foo")) diff --git a/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala b/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala index cfcb59c17b..486e1de090 100644 --- a/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala +++ b/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala @@ -1,7 +1,7 @@ import scala.language.experimental.macros object Macros { - def foo(x: Int) = macro Impls.refToFoo(42) + def foo(x: Int): Int = macro Impls.refToFoo(42) } object Test extends App { diff --git a/test/files/run/macro-bundle-repl.check b/test/files/run/macro-bundle-repl.check index 795debded7..8487042d66 100644 --- a/test/files/run/macro-bundle-repl.check +++ b/test/files/run/macro-bundle-repl.check @@ -7,7 +7,7 @@ import scala.language.experimental.macros scala> import scala.reflect.macros.BlackboxMacro import scala.reflect.macros.BlackboxMacro -scala> trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl +scala> trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl defined trait Bar defined term macro bar: Unit @@ -16,7 +16,7 @@ scala> bar scala> trait Foo extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } } defined trait Foo -scala> def foo = macro Foo.impl +scala> def foo: Unit = macro Foo.impl defined term macro foo: Unit scala> foo diff --git a/test/files/run/macro-bundle-repl.scala b/test/files/run/macro-bundle-repl.scala index 50811cdb65..db64f05943 100644 --- a/test/files/run/macro-bundle-repl.scala +++ b/test/files/run/macro-bundle-repl.scala @@ -4,10 +4,10 @@ object Test extends ReplTest { def code = """ import scala.language.experimental.macros import scala.reflect.macros.BlackboxMacro -trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl +trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl bar trait Foo extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } } -def foo = macro Foo.impl +def foo: Unit = macro Foo.impl foo """ } diff --git a/test/files/run/macro-def-infer-return-type.check b/test/files/run/macro-def-infer-return-type.check deleted file mode 100644 index fbd164f139..0000000000 --- a/test/files/run/macro-def-infer-return-type.check +++ /dev/null @@ -1,8 +0,0 @@ -42 -reflective compilation has failed: - -exception during macro expansion: -java.lang.Error: an implementation is missing - at Impls2$.foo(Impls_1.scala:9) - -42 diff --git a/test/files/run/macro-def-infer-return-type.flags b/test/files/run/macro-def-infer-return-type.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-def-infer-return-type.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type/Impls_1.scala b/test/files/run/macro-def-infer-return-type/Impls_1.scala deleted file mode 100644 index c670b1e57e..0000000000 --- a/test/files/run/macro-def-infer-return-type/Impls_1.scala +++ /dev/null @@ -1,14 +0,0 @@ -import scala.reflect.macros.BlackboxContext - -object Impls1 { - def foo(c: BlackboxContext)(x: c.Expr[Int]) = x -} - -object Impls2 { - def foo[T](c: BlackboxContext)(x: c.Expr[T]) = - throw new Error("an implementation is missing") -} - -object Impls3 { - def foo[T](c: BlackboxContext)(x: c.Expr[T]): c.Expr[T] = x -} diff --git a/test/files/run/macro-def-infer-return-type/Macros_Test_2.scala b/test/files/run/macro-def-infer-return-type/Macros_Test_2.scala deleted file mode 100644 index f579586b7f..0000000000 --- a/test/files/run/macro-def-infer-return-type/Macros_Test_2.scala +++ /dev/null @@ -1,24 +0,0 @@ -object Macros1 { - def foo(x: Int) = macro Impls1.foo -} - -object Macros2 { - def foo[T](x: T) = macro Impls2.foo[T] -} - -object Macros3 { - def foo[T](x: T) = macro Impls3.foo[T] -} - -object Test extends App { - println(Macros1.foo(42)) - - import scala.reflect.runtime.universe._ - import scala.reflect.runtime.{currentMirror => cm} - import scala.tools.reflect.ToolBox - val tree = Apply(Select(Ident(TermName("Macros2")), TermName("foo")), List(Literal(Constant(42)))) - try cm.mkToolBox().eval(tree) - catch { case ex: Throwable => println(ex.getMessage) } - - println(Macros3.foo(42)) -} diff --git a/test/files/run/macro-def-path-dependent/Test_1.scala b/test/files/run/macro-def-path-dependent/Test_1.scala index f9aa13c334..bba97fcae1 100644 --- a/test/files/run/macro-def-path-dependent/Test_1.scala +++ b/test/files/run/macro-def-path-dependent/Test_1.scala @@ -1,23 +1,25 @@ -package test1 - -import scala.reflect.macros.{BlackboxContext => Ctx} - -trait Exprs { - self: Universe => - - class Expr[T] -} - -trait Reifiers { - self: Universe => - - type Expr[T] - - def reify[T](expr: T) = macro Impls.reify[T] -} - -trait Universe extends Exprs with Reifiers - -object Impls { - def reify[T](cc: Ctx{ type PrefixType = Reifiers })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ??? -} +// NOTE: blocked by SI-8049 + +// package test1 +// +// import scala.reflect.macros.{BlackboxContext => Ctx} +// +// trait Exprs { +// self: Universe => +// +// class Expr[T] +// } +// +// trait Reifiers { +// self: Universe => +// +// type Expr[T] +// +// def reify[T](expr: T): Expr[T] = macro Impls.reify[T] +// } +// +// trait Universe extends Exprs with Reifiers +// +// object Impls { +// def reify[T](cc: Ctx{ type PrefixType = Reifiers })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ??? +// } diff --git a/test/files/run/macro-def-path-dependent/Test_2.scala b/test/files/run/macro-def-path-dependent/Test_2.scala index cdedaf2732..c884ab9d0b 100644 --- a/test/files/run/macro-def-path-dependent/Test_2.scala +++ b/test/files/run/macro-def-path-dependent/Test_2.scala @@ -14,7 +14,7 @@ trait Reifiers { } trait Universe extends Exprs with Reifiers { - def reify[T](expr: T) = macro Impls.reify[T] + def reify[T](expr: T): Expr[T] = macro Impls.reify[T] } object Impls { diff --git a/test/files/run/macro-def-path-dependent/Test_4.scala b/test/files/run/macro-def-path-dependent/Test_4.scala index e8a8cf3909..6562802013 100644 --- a/test/files/run/macro-def-path-dependent/Test_4.scala +++ b/test/files/run/macro-def-path-dependent/Test_4.scala @@ -5,7 +5,7 @@ import scala.reflect.macros.BlackboxContext import scala.reflect.api.Universe object Test { - def materializeTypeTag[T](u: Universe)(e: T) = macro materializeTypeTag_impl[T] + def materializeTypeTag[T](u: Universe)(e: T): u.TypeTag[T] = macro materializeTypeTag_impl[T] def materializeTypeTag_impl[T: c.WeakTypeTag](c: BlackboxContext)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? }
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent/Test_6.scala b/test/files/run/macro-def-path-dependent/Test_6.scala index c8ddffc143..011e726b3f 100644 --- a/test/files/run/macro-def-path-dependent/Test_6.scala +++ b/test/files/run/macro-def-path-dependent/Test_6.scala @@ -5,5 +5,5 @@ import scala.reflect.macros.BlackboxContext import scala.reflect.api.Universe object Macros { - def materializeTypeTag[T](u: Universe)(e: T) = macro Impls.materializeTypeTag_impl[T] + def materializeTypeTag[T](u: Universe)(e: T): u.TypeTag[T] = macro Impls.materializeTypeTag_impl[T] }
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala b/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala index ffb04dc80b..fec914632f 100644 --- a/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala +++ b/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala @@ -1,5 +1,5 @@ object Test extends App { implicit val x = 42 - def foo(implicit x: Int) = macro Impls.foo + def foo(implicit x: Int): Unit = macro Impls.foo foo }
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-val/Macros_Test_2.scala b/test/files/run/macro-expand-implicit-macro-is-val/Macros_Test_2.scala index b91b1016c9..2f21785bae 100644 --- a/test/files/run/macro-expand-implicit-macro-is-val/Macros_Test_2.scala +++ b/test/files/run/macro-expand-implicit-macro-is-val/Macros_Test_2.scala @@ -1,5 +1,5 @@ object Test extends App { - implicit def foo = macro Impls.foo + implicit def foo: Int = macro Impls.foo def bar(implicit x: Int) = println(x) bar }
\ No newline at end of file diff --git a/test/files/run/macro-expand-multiple-arglists/Macros_Test_2.scala b/test/files/run/macro-expand-multiple-arglists/Macros_Test_2.scala index fa4504b0ea..54b959983b 100644 --- a/test/files/run/macro-expand-multiple-arglists/Macros_Test_2.scala +++ b/test/files/run/macro-expand-multiple-arglists/Macros_Test_2.scala @@ -1,4 +1,4 @@ object Test extends App { - def foo(x: Int)(y: Int) = macro Impls.foo + def foo(x: Int)(y: Int): Unit = macro Impls.foo foo(40)(2) }
\ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-generic/Macros_Test_2.scala b/test/files/run/macro-expand-nullary-generic/Macros_Test_2.scala index 2d5cf53c3c..edd9051754 100644 --- a/test/files/run/macro-expand-nullary-generic/Macros_Test_2.scala +++ b/test/files/run/macro-expand-nullary-generic/Macros_Test_2.scala @@ -1,8 +1,8 @@ object Macros { - def foo1[T] = macro Impls.fooNullary[T] - def foo2[T]() = macro Impls.fooEmpty[T] - def bar1[T](x: Int) = macro Impls.barNullary[T] - def bar2[T](x: Int)() = macro Impls.barEmpty[T] + def foo1[T]: Unit = macro Impls.fooNullary[T] + def foo2[T](): Unit = macro Impls.fooEmpty[T] + def bar1[T](x: Int): Unit = macro Impls.barNullary[T] + def bar2[T](x: Int)(): Unit = macro Impls.barEmpty[T] } object Test extends App { diff --git a/test/files/run/macro-expand-nullary-nongeneric/Macros_Test_2.scala b/test/files/run/macro-expand-nullary-nongeneric/Macros_Test_2.scala index 1f6d717956..51915dfb27 100644 --- a/test/files/run/macro-expand-nullary-nongeneric/Macros_Test_2.scala +++ b/test/files/run/macro-expand-nullary-nongeneric/Macros_Test_2.scala @@ -1,8 +1,8 @@ object Macros { - def foo1 = macro Impls.fooNullary - def foo2() = macro Impls.fooEmpty - def bar1(x: Int) = macro Impls.barNullary - def bar2(x: Int)() = macro Impls.barEmpty + def foo1: Unit = macro Impls.fooNullary + def foo2(): Unit = macro Impls.fooEmpty + def bar1(x: Int): Unit = macro Impls.barNullary + def bar2(x: Int)(): Unit = macro Impls.barEmpty } object Test extends App { diff --git a/test/files/run/macro-expand-overload/Macros_Test_2.scala b/test/files/run/macro-expand-overload/Macros_Test_2.scala index 7f61f85184..87cff2ecbd 100644 --- a/test/files/run/macro-expand-overload/Macros_Test_2.scala +++ b/test/files/run/macro-expand-overload/Macros_Test_2.scala @@ -1,13 +1,13 @@ object Macros { - def foo(x: String) = macro Impls.fooObjectString - def foo(x: Int) = macro Impls.fooObjectInt - def foo(x: Boolean) = println("fooObjectBoolean") + def foo(x: String): Unit = macro Impls.fooObjectString + def foo(x: Int): Unit = macro Impls.fooObjectInt + def foo(x: Boolean): Unit = println("fooObjectBoolean") } class Macros { - def foo(x: String) = macro Impls.fooClassString - def foo(x: Int) = macro Impls.fooClassInt - def foo(x: Boolean) = println("fooClassBoolean") + def foo(x: String): Unit = macro Impls.fooClassString + def foo(x: Int): Unit = macro Impls.fooClassInt + def foo(x: Boolean): Unit = println("fooClassBoolean") } object Test extends App { diff --git a/test/files/run/macro-expand-override/Macros_Test_2.scala b/test/files/run/macro-expand-override/Macros_Test_2.scala index f162773c95..160831c54e 100644 --- a/test/files/run/macro-expand-override/Macros_Test_2.scala +++ b/test/files/run/macro-expand-override/Macros_Test_2.scala @@ -1,17 +1,17 @@ class B { - def foo(x: String) = macro Impls.fooBString - def foo(x: Int) = macro Impls.fooBInt - def foo(x: Boolean) = println("fooBBoolean") + def foo(x: String): Unit = macro Impls.fooBString + def foo(x: Int): Unit = macro Impls.fooBInt + def foo(x: Boolean): Unit = println("fooBBoolean") } class D extends B { - //override def foo(x: String) = println("fooDString") => method cannot override a macro - override def foo(x: Int) = macro Impls.fooDInt + //override def foo(x: String): Unit = println("fooDString") => method cannot override a macro + override def foo(x: Int): Unit = macro Impls.fooDInt } class Z extends D { - override def foo(x: String) = macro Impls.fooZString - override def foo(x: Boolean) = println("fooZBoolean") + override def foo(x: String): Unit = macro Impls.fooZString + override def foo(x: Boolean): Unit = println("fooZBoolean") } object Test extends App { diff --git a/test/files/run/macro-expand-recursive/Macros_Test_2.scala b/test/files/run/macro-expand-recursive/Macros_Test_2.scala index 6ff691bdb1..5332fdacee 100644 --- a/test/files/run/macro-expand-recursive/Macros_Test_2.scala +++ b/test/files/run/macro-expand-recursive/Macros_Test_2.scala @@ -1,6 +1,6 @@ object Macros { - def foo = macro Impls.foo - def fooFoo = macro Impls.fooFoo + def foo: Unit = macro Impls.foo + def fooFoo: Unit = macro Impls.fooFoo } object Test extends App { diff --git a/test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala index 37a4bcb2b9..6cb2b53465 100644 --- a/test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala +++ b/test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala @@ -1,9 +1,9 @@ object Macros1 { - def foo[U <: String] = macro Impls1.foo[U] + def foo[U <: String]: Unit = macro Impls1.foo[U] } object Macros2 { - def foo[T <: D] = macro Impls2.foo[T] + def foo[T <: D]: Unit = macro Impls2.foo[T] } object Test extends App { diff --git a/test/files/run/macro-expand-tparams-explicit/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-explicit/Macros_Test_2.scala index e72c27881a..2cf7b19d2a 100644 --- a/test/files/run/macro-expand-tparams-explicit/Macros_Test_2.scala +++ b/test/files/run/macro-expand-tparams-explicit/Macros_Test_2.scala @@ -1,4 +1,4 @@ object Test extends App { - def foo[U] = macro Impls.foo[U] + def foo[U]: Unit = macro Impls.foo[U] foo[Int] }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-implicit/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-implicit/Macros_Test_2.scala index f8c573f509..1192931931 100644 --- a/test/files/run/macro-expand-tparams-implicit/Macros_Test_2.scala +++ b/test/files/run/macro-expand-tparams-implicit/Macros_Test_2.scala @@ -1,5 +1,5 @@ object Test extends App { - def foo[U](x: U) = macro Impls.foo[U] + def foo[U](x: U): Unit = macro Impls.foo[U] foo(42) foo("42") }
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala index 2b1730d36e..c8f68b4aff 100644 --- a/test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala +++ b/test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala @@ -1,19 +1,19 @@ object Macros1 { class C[T] { - def foo[U](x: U) = macro Impls1.foo[U] + def foo[U](x: U): Unit = macro Impls1.foo[U] } } object Macros2 { class C[T] { - def foo[U](x: U) = macro Impls2.foo[T, U] + def foo[U](x: U): Unit = macro Impls2.foo[T, U] } } object Macros3 { class D[T] { class C[U] { - def foo[V] = macro Impls345.foo[T, U, V] + def foo[V]: Unit = macro Impls345.foo[T, U, V] } } } @@ -23,7 +23,7 @@ object Macros3 { object Macros5 { class D[T] { class C[U] { - def foo[V] = macro Impls345.foo[T, U, V] + def foo[V]: Unit = macro Impls345.foo[T, U, V] foo[Boolean] } } diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala index b844012d53..6d79b13419 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala @@ -1,5 +1,5 @@ object Macros { - def foo(xs: Int*) = macro Impls.foo + def foo(xs: Int*): Unit = macro Impls.foo } object Test extends App { diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Macros_Test_2.scala index f127ebcde7..13d7cd5d5d 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Macros_Test_2.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Macros_Test_2.scala @@ -1,5 +1,5 @@ object Macros { - def foo(xs: Int*) = macro Impls.foo + def foo(xs: Int*): Unit = macro Impls.foo } object Test extends App { diff --git a/test/files/run/macro-expand-varargs-explicit-over-varargs/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-varargs/Macros_Test_2.scala index f127ebcde7..13d7cd5d5d 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-varargs/Macros_Test_2.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-varargs/Macros_Test_2.scala @@ -1,5 +1,5 @@ object Macros { - def foo(xs: Int*) = macro Impls.foo + def foo(xs: Int*): Unit = macro Impls.foo } object Test extends App { diff --git a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Macros_Test_2.scala index 2311ca0b95..9ab1be9e23 100644 --- a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Macros_Test_2.scala +++ b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Macros_Test_2.scala @@ -1,5 +1,5 @@ object Macros { - def foo(xs: Int*) = macro Impls.foo + def foo(xs: Int*): Unit = macro Impls.foo } object Test extends App { diff --git a/test/files/run/macro-expand-varargs-implicit-over-varargs/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-implicit-over-varargs/Macros_Test_2.scala index 2311ca0b95..9ab1be9e23 100644 --- a/test/files/run/macro-expand-varargs-implicit-over-varargs/Macros_Test_2.scala +++ b/test/files/run/macro-expand-varargs-implicit-over-varargs/Macros_Test_2.scala @@ -1,5 +1,5 @@ object Macros { - def foo(xs: Int*) = macro Impls.foo + def foo(xs: Int*): Unit = macro Impls.foo } object Test extends App { diff --git a/test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala b/test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala index 218c7aec7f..4901e24481 100644 --- a/test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala +++ b/test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala @@ -1,5 +1,5 @@ object Macros { - def foo = macro Impls.foo[String] + def foo: Unit = macro Impls.foo[String] } object Test extends App { diff --git a/test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala b/test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala index e72c27881a..2cf7b19d2a 100644 --- a/test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala +++ b/test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala @@ -1,4 +1,4 @@ object Test extends App { - def foo[U] = macro Impls.foo[U] + def foo[U]: Unit = macro Impls.foo[U] foo[Int] }
\ No newline at end of file diff --git a/test/files/run/macro-quasiquotes/Macros_1.scala b/test/files/run/macro-quasiquotes/Macros_1.scala index c42baafdf4..81775d98e8 100644 --- a/test/files/run/macro-quasiquotes/Macros_1.scala +++ b/test/files/run/macro-quasiquotes/Macros_1.scala @@ -9,7 +9,7 @@ trait Impls extends BlackboxMacro { } object Macros { - def m1 = macro Impls.impl1 - def m2 = macro Impls.impl2 - def m3 = macro Impls.impl3 + def m1: Unit = macro Impls.impl1 + def m2: Unit = macro Impls.impl2 + def m3: Int = macro Impls.impl3 }
\ No newline at end of file diff --git a/test/files/run/macro-reflective-mamd-normal-mi.check b/test/files/run/macro-reflective-mamd-normal-mi.check index f77196b2db..920a139664 100644 --- a/test/files/run/macro-reflective-mamd-normal-mi.check +++ b/test/files/run/macro-reflective-mamd-normal-mi.check @@ -1,2 +1 @@ -warning: there were 1 deprecation warning(s); re-run with -deprecation for details 43 diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala index 13cd953bde..ba12fb05e6 100644 --- a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala +++ b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala @@ -10,9 +10,9 @@ object Test extends App { val macrobody = Select(Ident(TermName("Impls")), TermName("foo")) val macroparam = ValDef(NoMods, TermName("x"), TypeTree(definitions.IntClass.toType), EmptyTree) - val macrodef = DefDef(Modifiers(MACRO), TermName("foo"), Nil, List(List(macroparam)), TypeTree(), macrobody) + val macrodef = DefDef(Modifiers(MACRO), TermName("foo"), Nil, List(List(macroparam)), Ident(TypeName("Int")), macrobody) val modulector = DefDef(NoMods, nme.CONSTRUCTOR, Nil, List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))) - val module = ModuleDef(NoMods, TermName("Macros"), Template(Nil, emptyValDef, List(modulector, macrodef))) + val module = ModuleDef(NoMods, TermName("Macros"), Template(Nil, noSelfType, List(modulector, macrodef))) val macroapp = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42)))) val tree = Block(List(macrodef, module), macroapp) val toolbox = cm.mkToolBox(options = "-language:experimental.macros") diff --git a/test/files/run/macro-reify-ref-to-packageless/Test_2.scala b/test/files/run/macro-reify-ref-to-packageless/Test_2.scala index 9d475f756d..c167b160be 100644 --- a/test/files/run/macro-reify-ref-to-packageless/Test_2.scala +++ b/test/files/run/macro-reify-ref-to-packageless/Test_2.scala @@ -1,4 +1,4 @@ object Test extends App { - def foo = macro Impls.foo + def foo: Int = macro Impls.foo println(foo) }
\ No newline at end of file diff --git a/test/files/run/macro-repl-dontexpand.check b/test/files/run/macro-repl-dontexpand.check index 3ba877b59d..9f538c04b6 100644 --- a/test/files/run/macro-repl-dontexpand.check +++ b/test/files/run/macro-repl-dontexpand.check @@ -5,12 +5,12 @@ scala> def bar1(c: scala.reflect.macros.BlackboxContext) = ??? bar1: (c: scala.reflect.macros.BlackboxContext)Nothing scala> def foo1 = macro bar1 -defined term macro foo1: Any +defined term macro foo1: Nothing scala> def bar2(c: scala.reflect.macros.WhiteboxContext) = ??? bar2: (c: scala.reflect.macros.WhiteboxContext)Nothing scala> def foo2 = macro bar2 -defined term macro foo2: Any +defined term macro foo2: Nothing scala> diff --git a/test/files/run/macro-subpatterns.check b/test/files/run/macro-subpatterns.check new file mode 100644 index 0000000000..b34d4bf4a1 --- /dev/null +++ b/test/files/run/macro-subpatterns.check @@ -0,0 +1,3 @@ +List((a @ Extractor((b @ Extractor((c @ _)))))) +List((b @ Extractor((c @ _)))) +List((c @ _)) diff --git a/test/files/run/macro-subpatterns/Macro_1.scala b/test/files/run/macro-subpatterns/Macro_1.scala new file mode 100644 index 0000000000..d8e86e27c6 --- /dev/null +++ b/test/files/run/macro-subpatterns/Macro_1.scala @@ -0,0 +1,18 @@ +import scala.reflect.macros.WhiteboxContext +import language.experimental.macros + +object Extractor { + def unapply(x: Any): Any = macro unapplyImpl + def unapplyImpl(c: WhiteboxContext)(x: c.Tree) = { + val st = c.universe.asInstanceOf[reflect.internal.SymbolTable] + import st._ + val subpatterns = x.attachments.get[SubpatternsAttachment].get.patterns + q""" + new { + def isEmpty = false + def get = ${subpatterns.toString} + def unapply(x: Any) = this + }.unapply(${x.asInstanceOf[st.Tree]}) + """.asInstanceOf[c.Tree] + } +} diff --git a/test/files/run/macro-subpatterns/Test_2.scala b/test/files/run/macro-subpatterns/Test_2.scala new file mode 100644 index 0000000000..dc6e668877 --- /dev/null +++ b/test/files/run/macro-subpatterns/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + 42 match { + case Extractor(a @ Extractor(b @ Extractor(c))) => println(a); println(b); println(c) + } +} diff --git a/test/files/run/macro-system-properties.check b/test/files/run/macro-system-properties.check index ea4c5a664a..ceed1079b2 100644 --- a/test/files/run/macro-system-properties.check +++ b/test/files/run/macro-system-properties.check @@ -9,7 +9,7 @@ scala> object GrabContext { def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context]) // System.properties lets you stash true globals (unlike statics which are classloader scoped) def impl(c: BlackboxContext)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") } - def grab() = macro impl + def grab(): Unit = macro impl } defined object GrabContext diff --git a/test/files/run/macro-system-properties.scala b/test/files/run/macro-system-properties.scala index 73a3ef5910..3325c1747a 100644 --- a/test/files/run/macro-system-properties.scala +++ b/test/files/run/macro-system-properties.scala @@ -8,7 +8,7 @@ object Test extends ReplTest { def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context]) // System.properties lets you stash true globals (unlike statics which are classloader scoped) def impl(c: BlackboxContext)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") } - def grab() = macro impl + def grab(): Unit = macro impl } object Test { class C(implicit a: Any) { GrabContext.grab } } object Test { class C(implicit a: Any) { GrabContext.grab } } diff --git a/test/files/run/macro-term-declared-in-anonymous/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-anonymous/Macros_Test_2.scala index 88cd29ae4f..5039dffd5f 100644 --- a/test/files/run/macro-term-declared-in-anonymous/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-anonymous/Macros_Test_2.scala @@ -1,6 +1,6 @@ import scala.language.reflectiveCalls object Test extends App { - val macros = new { def foo = macro Impls.foo } + val macros = new { def foo: Unit = macro Impls.foo } macros.foo } diff --git a/test/files/run/macro-term-declared-in-block/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-block/Macros_Test_2.scala index 69088e24bc..80bfc44bee 100644 --- a/test/files/run/macro-term-declared-in-block/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-block/Macros_Test_2.scala @@ -1,6 +1,6 @@ object Test extends App { { - def foo = macro Impls.foo + def foo: Unit = macro Impls.foo foo } }
\ No newline at end of file diff --git a/test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala index 871857a97f..d6b1f9fab1 100644 --- a/test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala @@ -1,6 +1,6 @@ class Macros { class Macros { - def foo = macro Impls.foo + def foo: Unit = macro Impls.foo } } diff --git a/test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala index 994f9fe935..957f666bb0 100644 --- a/test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala @@ -1,6 +1,6 @@ class Macros { object Macros { - def foo = macro Impls.foo + def foo: Unit = macro Impls.foo } } diff --git a/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala index 1b9d13e775..5898d94dc1 100644 --- a/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala @@ -1,5 +1,5 @@ class Macros { - def foo = macro Impls.foo + def foo: Unit = macro Impls.foo } object Test extends App { diff --git a/test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala index 356029e63e..16bd95b1e6 100644 --- a/test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala @@ -1,5 +1,5 @@ object Test extends App { - def foo(bar: String = { def foo = macro Impls.foo; foo }) = println(bar) + def foo(bar: String = { def foo: String = macro Impls.foo; foo }) = println(bar) foo() foo("it works") diff --git a/test/files/run/macro-term-declared-in-method/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-method/Macros_Test_2.scala index ed5c8b7c43..523989df13 100644 --- a/test/files/run/macro-term-declared-in-method/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-method/Macros_Test_2.scala @@ -1,6 +1,6 @@ object Test extends App { def bar() = { - def foo = macro Impls.foo + def foo: Unit = macro Impls.foo foo } diff --git a/test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala index 204deed61c..fe9dbef255 100644 --- a/test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala @@ -1,6 +1,6 @@ object Macros { class Macros { - def foo = macro Impls.foo + def foo: Unit = macro Impls.foo } } diff --git a/test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala index e261a50f3d..4ba7551818 100644 --- a/test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala @@ -1,6 +1,6 @@ object Macros { object Macros { - def foo = macro Impls.foo + def foo: Unit = macro Impls.foo } } diff --git a/test/files/run/macro-term-declared-in-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-object/Macros_Test_2.scala index a5a4862ba0..9ebf5d7dba 100644 --- a/test/files/run/macro-term-declared-in-object/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-object/Macros_Test_2.scala @@ -1,5 +1,5 @@ object Macros { - def foo = macro Impls.foo + def foo: Unit = macro Impls.foo } object Test extends App { diff --git a/test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala index 54a5962e80..1f378b8bfd 100644 --- a/test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala @@ -1,5 +1,5 @@ package object Macros { - def foo = macro Impls.foo + def foo: Unit = macro Impls.foo } object Test extends App { diff --git a/test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala index ff9a66d58a..b38616b71a 100644 --- a/test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala @@ -1,9 +1,8 @@ - import scala.language.reflectiveCalls class Base object Test extends App { - val macros = new Base { def foo = macro Impls.foo } + val macros = new Base { def foo: Unit = macro Impls.foo } macros.foo } diff --git a/test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala index f75906b636..09c60df351 100644 --- a/test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala +++ b/test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala @@ -1,5 +1,5 @@ trait Base { - def foo = macro Impls.foo + def foo: Unit = macro Impls.foo } object Macros extends Base diff --git a/test/files/run/macro-vampire-false-warning/Macros_1.scala b/test/files/run/macro-vampire-false-warning/Macros_1.scala index 5907461c84..bf75e924e8 100644 --- a/test/files/run/macro-vampire-false-warning/Macros_1.scala +++ b/test/files/run/macro-vampire-false-warning/Macros_1.scala @@ -22,7 +22,7 @@ object Macros { // val fields = kvps map { case (k, v) => q"@body($v) def ${TermName(k)} = macro Macros.selFieldImpl" } val fields = kvps map { case (k, v) => DefDef( Modifiers(MACRO, tpnme.EMPTY, List(Apply(Select(New(Ident(TypeName("body"))), nme.CONSTRUCTOR), List(v)))), - TermName(k), Nil, Nil, TypeTree(), Select(Ident(TermName("Macros")), TermName("selFieldImpl"))) } + TermName(k), Nil, Nil, Ident(TypeName("Any")), Select(Ident(TermName("Macros")), TermName("selFieldImpl"))) } // q"import scala.language.experimental.macros; class Workaround { ..$fields }; new Workaround{}" c.Expr[Any](Block( List( @@ -48,5 +48,5 @@ object Macros { } object mkObject { - def apply(xs: Any*) = macro Macros.mkObjectImpl + def apply(xs: Any*): Any = macro Macros.mkObjectImpl } diff --git a/test/files/run/macro-whitebox-extractor/Macros_1.scala b/test/files/run/macro-whitebox-extractor/Macros_1.scala index 4a1138fc9d..64053b8a24 100644 --- a/test/files/run/macro-whitebox-extractor/Macros_1.scala +++ b/test/files/run/macro-whitebox-extractor/Macros_1.scala @@ -2,7 +2,7 @@ import scala.reflect.macros.WhiteboxContext import language.experimental.macros object Extractor { - def unapply(x: Int) = macro Macros.unapplyImpl + def unapply(x: Int): Any = macro Macros.unapplyImpl } object Macros { diff --git a/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala b/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala index 1b975ca850..b8d0c042be 100644 --- a/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala +++ b/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala @@ -12,5 +12,5 @@ object Macros { """ } - def foo = macro impl + def foo: Any = macro impl }
\ No newline at end of file diff --git a/test/files/run/repl-term-macros.check b/test/files/run/repl-term-macros.check index 64c46392a3..f73abb5dc3 100644 --- a/test/files/run/repl-term-macros.check +++ b/test/files/run/repl-term-macros.check @@ -12,7 +12,7 @@ scala> scala> def impl1(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") } impl1: (c: scala.reflect.macros.BlackboxContext)c.Expr[Unit] -scala> def foo1 = macro impl1 +scala> def foo1: Unit = macro impl1 defined term macro foo1: Unit scala> foo1 @@ -22,7 +22,7 @@ scala> scala> def impl2(c: BlackboxContext)() = { import c.universe._; c.Expr[Unit](q"()") } impl2: (c: scala.reflect.macros.BlackboxContext)()c.Expr[Unit] -scala> def foo2() = macro impl2 +scala> def foo2(): Unit = macro impl2 defined term macro foo2: ()Unit scala> foo2() @@ -32,7 +32,7 @@ scala> scala> def impl3(c: BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") } impl3: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int])c.Expr[Unit] -scala> def foo3(x: Int)(y: Int) = macro impl3 +scala> def foo3(x: Int)(y: Int): Unit = macro impl3 defined term macro foo3: (x: Int)(y: Int)Unit scala> foo3(2)(3) diff --git a/test/files/run/repl-term-macros.scala b/test/files/run/repl-term-macros.scala index a779638c00..b4660e258e 100644 --- a/test/files/run/repl-term-macros.scala +++ b/test/files/run/repl-term-macros.scala @@ -6,15 +6,15 @@ object Test extends ReplTest { import language.experimental.macros def impl1(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") } -def foo1 = macro impl1 +def foo1: Unit = macro impl1 foo1 def impl2(c: BlackboxContext)() = { import c.universe._; c.Expr[Unit](q"()") } -def foo2() = macro impl2 +def foo2(): Unit = macro impl2 foo2() def impl3(c: BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") } -def foo3(x: Int)(y: Int) = macro impl3 +def foo3(x: Int)(y: Int): Unit = macro impl3 foo3(2)(3) """ }
\ No newline at end of file diff --git a/test/files/continuations-run/t3199b.check b/test/files/run/t3199b.check index b5d8bb58d9..b5d8bb58d9 100644 --- a/test/files/continuations-run/t3199b.check +++ b/test/files/run/t3199b.check diff --git a/test/files/continuations-run/t3199b.scala b/test/files/run/t3199b.scala index 5010f2b085..5010f2b085 100644 --- a/test/files/continuations-run/t3199b.scala +++ b/test/files/run/t3199b.scala diff --git a/test/files/run/t4841-isolate-plugins.check b/test/files/run/t4841-isolate-plugins.check new file mode 100644 index 0000000000..a6462b424b --- /dev/null +++ b/test/files/run/t4841-isolate-plugins.check @@ -0,0 +1,2 @@ +My phase name is ploogin1_1 +My phase name is ploogin1_2 diff --git a/test/files/run/t4841-isolate-plugins/ploogin.scala b/test/files/run/t4841-isolate-plugins/ploogin.scala new file mode 100644 index 0000000000..bd8c7275ec --- /dev/null +++ b/test/files/run/t4841-isolate-plugins/ploogin.scala @@ -0,0 +1,30 @@ + +package t4841 + +import scala.tools.nsc.{ Global, Phase } +import scala.tools.nsc.plugins.{ Plugin, PluginComponent } +import scala.reflect.io.Path +import scala.reflect.io.File + +/** A test plugin. */ +class Ploogin(val global: Global, val name: String = "ploogin") extends Plugin { + import global._ + + val description = "A sample plugin for testing." + val components = List[PluginComponent](TestComponent) + + private object TestComponent extends PluginComponent { + val global: Ploogin.this.global.type = Ploogin.this.global + //override val runsBefore = List("refchecks") + val runsAfter = List("jvm") + val phaseName = Ploogin.this.name + override def description = "A sample phase that does so many things it's kind of hard to describe briefly." + def newPhase(prev: Phase) = new TestPhase(prev) + class TestPhase(prev: Phase) extends StdPhase(prev) { + override def description = TestComponent.this.description + def apply(unit: CompilationUnit) { + if (settings.developer) inform(s"My phase name is $phaseName") + } + } + } +} diff --git a/test/files/run/t4841-isolate-plugins/t4841-isolate-plugin.scala b/test/files/run/t4841-isolate-plugins/t4841-isolate-plugin.scala new file mode 100644 index 0000000000..5421922c9c --- /dev/null +++ b/test/files/run/t4841-isolate-plugins/t4841-isolate-plugin.scala @@ -0,0 +1,39 @@ + +import tools.nsc.plugins.PluginDescription +import tools.partest.DirectTest + +import java.io.File + +// show that plugins are on isolated class loaders +object Test extends DirectTest { + override def code = "class Code" + + override def extraSettings = s"-usejavacp" + + // plugin named ploogin1_1 or ploogin1_2, but not ploogin2_x + // Although the samples are in different classloaders, the plugin + // loader checks for distinctness by class name, so the names must differ. + def pluginCode(index: Int) = s""" + |package t4841 { + | class SamplePloogin$index(global: scala.tools.nsc.Global) extends Ploogin(global, s"$${PlooginCounter.named}_$index") + | object PlooginCounter { + | val count = new java.util.concurrent.atomic.AtomicInteger + | def named = s"ploogin$${count.incrementAndGet}" + | } + |}""".stripMargin.trim + + def compilePlugin(i: Int) = { + val out = (testOutput / s"p$i").createDirectory() + val args = Seq("-usejavacp", "-d", out.path) + compileString(newCompiler(args: _*))(pluginCode(i)) + val xml = PluginDescription(s"p$i", s"t4841.SamplePloogin$i").toXML + (out / "scalac-plugin.xml").toFile writeAll xml + out + } + + override def show() = { + val dirs = 1 to 2 map (compilePlugin(_)) + compile("-Xdev", s"-Xplugin:${dirs mkString ","}", "-usejavacp", "-d", testOutput.path) + } +} + diff --git a/test/files/run/t4841-no-plugin.check b/test/files/run/t4841-no-plugin.check new file mode 100644 index 0000000000..4338f0ce23 --- /dev/null +++ b/test/files/run/t4841-no-plugin.check @@ -0,0 +1 @@ +warning: No plugin in path t4841-no-plugin-run.obj/plugins.partest diff --git a/test/files/run/t4841-no-plugin.scala b/test/files/run/t4841-no-plugin.scala new file mode 100644 index 0000000000..d91bf7ee21 --- /dev/null +++ b/test/files/run/t4841-no-plugin.scala @@ -0,0 +1,17 @@ + +import tools.partest.DirectTest + +import java.io.File + +// warn only if no plugin on Xplugin path +object Test extends DirectTest { + override def code = "class Code" + + override def extraSettings = s"-usejavacp -d ${testOutput.path}" + + override def show() = { + val tmp = new File(testOutput.jfile, "plugins.partest").getAbsolutePath + compile("-Xdev", s"-Xplugin:$tmp", "-Xpluginsdir", tmp) + } +} + diff --git a/test/files/run/t5894.scala b/test/files/run/t5894.scala index 55767d8889..5d482333f5 100644 --- a/test/files/run/t5894.scala +++ b/test/files/run/t5894.scala @@ -3,7 +3,7 @@ import language.experimental.macros class Test object Test { - def foo = macro fooImpl + def foo: Unit = macro fooImpl def fooImpl(c: reflect.macros.BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") } def main(args: Array[String]) { diff --git a/test/files/run/t5903a/Macros_1.scala b/test/files/run/t5903a/Macros_1.scala index 7888b888e1..ce1b035260 100644 --- a/test/files/run/t5903a/Macros_1.scala +++ b/test/files/run/t5903a/Macros_1.scala @@ -7,7 +7,7 @@ case object SomeTree extends Tree object NewQuasiquotes { implicit class QuasiquoteInterpolation(c: StringContext) { object nq { - def unapply(t: Tree) = macro QuasiquoteMacros.unapplyImpl + def unapply(t: Tree): Any = macro QuasiquoteMacros.unapplyImpl } } } diff --git a/test/files/run/t5903b/Macros_1.scala b/test/files/run/t5903b/Macros_1.scala index 8c03e5579d..97f15cec3b 100644 --- a/test/files/run/t5903b/Macros_1.scala +++ b/test/files/run/t5903b/Macros_1.scala @@ -4,7 +4,7 @@ import language.experimental.macros object Interpolation { implicit class TestInterpolation(c: StringContext) { object t { - def unapply[T](x: T) = macro Macros.unapplyImpl[T] + def unapply[T](x: T): Any = macro Macros.unapplyImpl[T] } } } diff --git a/test/files/run/t5903c/Macros_1.scala b/test/files/run/t5903c/Macros_1.scala index c9dfe9d60c..979284a263 100644 --- a/test/files/run/t5903c/Macros_1.scala +++ b/test/files/run/t5903c/Macros_1.scala @@ -4,7 +4,7 @@ import language.experimental.macros object Interpolation { implicit class TestInterpolation(c: StringContext) { object t { - def unapply[T](x: T) = macro Macros.unapplyImpl[T] + def unapply[T](x: T): Any = macro Macros.unapplyImpl[T] } } } diff --git a/test/files/run/t5903d/Macros_1.scala b/test/files/run/t5903d/Macros_1.scala index 8a57e27602..dc1989462b 100644 --- a/test/files/run/t5903d/Macros_1.scala +++ b/test/files/run/t5903d/Macros_1.scala @@ -4,7 +4,7 @@ import language.experimental.macros object Interpolation { implicit class TestInterpolation(c: StringContext) { object t { - def unapply(x: Int) = macro Macros.unapplyImpl + def unapply(x: Int): Any = macro Macros.unapplyImpl } } } diff --git a/test/files/run/t5940.scala b/test/files/run/t5940.scala index d98f267123..062f11c467 100644 --- a/test/files/run/t5940.scala +++ b/test/files/run/t5940.scala @@ -13,7 +13,7 @@ object Test extends DirectTest { object Macros { //import Impls._ def impl(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") } - def foo = macro impl + def foo: Unit = macro impl } """ def compileMacros() = { diff --git a/test/files/run/t6381.check b/test/files/run/t6381.check index dfc9d44850..ef08d0da09 100644 --- a/test/files/run/t6381.check +++ b/test/files/run/t6381.check @@ -10,7 +10,7 @@ scala> def pos_impl(c: reflect.macros.BlackboxContext): c.Expr[String] = { } pos_impl: (c: scala.reflect.macros.BlackboxContext)c.Expr[String] -scala> def pos = macro pos_impl +scala> def pos: String = macro pos_impl defined term macro pos: String scala> pos diff --git a/test/files/run/t6381.scala b/test/files/run/t6381.scala index 0e2264d8fa..c78dc13ed7 100644 --- a/test/files/run/t6381.scala +++ b/test/files/run/t6381.scala @@ -7,7 +7,7 @@ object Test extends ReplTest { | import c.universe._ | c.Expr[String](Literal(Constant(c.enclosingPosition.getClass.toString))) |} - |def pos = macro pos_impl + |def pos: String = macro pos_impl |pos |""".stripMargin.trim diff --git a/test/files/run/t6992.check b/test/files/run/t6992.check new file mode 100644 index 0000000000..1a0684c995 --- /dev/null +++ b/test/files/run/t6992.check @@ -0,0 +1,3 @@ +Int +42 +42 diff --git a/test/files/run/t6992/Macros_1.scala b/test/files/run/t6992/Macros_1.scala new file mode 100644 index 0000000000..25566dddbf --- /dev/null +++ b/test/files/run/t6992/Macros_1.scala @@ -0,0 +1,75 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Context + +object Macros { + def foo(name: String): Any = macro foo_impl + def foo_impl(c: Context)(name: c.Expr[String]) = { + import c.universe._ + + val Literal(Constant(lit: String)) = name.tree + val anon = newTypeName(c.fresh) + + c.Expr(Block( + ClassDef( + Modifiers(Flag.FINAL), anon, Nil, Template( + Nil, noSelfType, List( + DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))), + TypeDef(Modifiers(), TypeName(lit), Nil, TypeTree(typeOf[Int])) + ) + ) + ), + Apply(Select(New(Ident(anon)), nme.CONSTRUCTOR), Nil) + )) + } + + def bar(name: String): Any = macro bar_impl + def bar_impl(c: Context)(name: c.Expr[String]) = { + import c.universe._ + + val Literal(Constant(lit: String)) = name.tree + val anon = newTypeName(c.fresh) + + c.Expr(Block( + ClassDef( + Modifiers(Flag.FINAL), anon, Nil, Template( + Nil, noSelfType, List( + DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))), + DefDef( + Modifiers(), TermName(lit), Nil, Nil, TypeTree(), + c.literal(42).tree + ) + ) + ) + ), + Apply(Select(New(Ident(anon)), nme.CONSTRUCTOR), Nil) + )) + } + + def baz(name: String): Any = macro baz_impl + def baz_impl(c: Context)(name: c.Expr[String]) = { + import c.universe._ + + val Literal(Constant(lit: String)) = name.tree + val anon = newTypeName(c.fresh) + val wrapper = newTypeName(c.fresh) + + c.Expr(Block( + ClassDef( + Modifiers(), anon, Nil, Template( + Nil, emptyValDef, List( + DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))), + DefDef( + Modifiers(), TermName(lit), Nil, Nil, TypeTree(), + c.literal(42).tree + ) + ) + ) + ), + ClassDef( + Modifiers(Flag.FINAL), wrapper, Nil, + Template(Ident(anon) :: Nil, noSelfType, DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))) :: Nil) + ), + Apply(Select(New(Ident(wrapper)), nme.CONSTRUCTOR), Nil) + )) + } +}
\ No newline at end of file diff --git a/test/files/run/t6992/Test_2.scala b/test/files/run/t6992/Test_2.scala new file mode 100644 index 0000000000..05282d6f5b --- /dev/null +++ b/test/files/run/t6992/Test_2.scala @@ -0,0 +1,12 @@ +import scala.language.reflectiveCalls + +object Test extends App { + val foo = Macros.foo("T") + println(scala.reflect.runtime.universe.weakTypeOf[foo.T].typeSymbol.typeSignature) + + val bar = Macros.bar("test") + println(bar.test) + + val baz = Macros.baz("test") + println(baz.test) +}
\ No newline at end of file diff --git a/test/files/run/t7617b/Test_2.scala b/test/files/run/t7617b/Test_2.scala index e27f650e80..e1d9acdc31 100644 --- a/test/files/run/t7617b/Test_2.scala +++ b/test/files/run/t7617b/Test_2.scala @@ -2,7 +2,7 @@ import scala.language.dynamics import language.experimental.macros class C extends Dynamic { - def updateDynamic(name: String)(value: Any) = macro Macros.impl + def updateDynamic(name: String)(value: Any): Unit = macro Macros.impl } object Test extends App { diff --git a/test/files/run/t7871/Macros_1.scala b/test/files/run/t7871/Macros_1.scala index 778068deb3..801a6af4e7 100644 --- a/test/files/run/t7871/Macros_1.scala +++ b/test/files/run/t7871/Macros_1.scala @@ -7,7 +7,7 @@ case object SomeTree extends Tree object NewQuasiquotes { implicit class QuasiquoteInterpolation(c: StringContext) { object nq { - def unapply(t: Tree) = macro QuasiquoteMacros.unapplyImpl + def unapply(t: Tree): Any = macro QuasiquoteMacros.unapplyImpl } } } diff --git a/test/files/run/t7912.scala b/test/files/run/t7912.scala new file mode 100644 index 0000000000..3d603e0e97 --- /dev/null +++ b/test/files/run/t7912.scala @@ -0,0 +1,16 @@ +case object A { override def toString = ??? } + +object Test { + def foo: Int = (A: Any) match { + case 0 => 0 + } + def main(args: Array[String]): Unit = { + try { + foo + sys.error("no exception") + } catch { + case me: MatchError => assert(me.getMessage == "an instance of class A$", me.getMessage) + case ex: Throwable => sys.error("not a match error: " + ex.getClass) + } + } +} diff --git a/test/files/run/t8010.scala b/test/files/run/t8010.scala new file mode 100644 index 0000000000..8636bbd12e --- /dev/null +++ b/test/files/run/t8010.scala @@ -0,0 +1,22 @@ +trait Base { + def t = 1 + def t(n: Int) = n + def bt = 2 + def bt(n: Int) = n +} +trait Derived extends Base { + // was: double defintion error + override def t = 1 + super.t + override def t(n: Int) = 1 + super.t(n) + override def bt = 1 + super.bt + override def bt(n: Int) = 1 + super.bt(n) +} + +object Test extends App { + val d = new Derived {} + // not the focus of thie bug, but let's just check the runtime behaviour while we're here. + assert(d.t == 2) + assert(d.t(1) == 2) + assert(d.bt == 3) + assert(d.bt(1) == 2) +} diff --git a/test/files/run/t8029.scala b/test/files/run/t8029.scala new file mode 100644 index 0000000000..dbd5c41387 --- /dev/null +++ b/test/files/run/t8029.scala @@ -0,0 +1,57 @@ +import scala.tools.partest._ +import scala.tools.nsc._ + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -nowarn -Ystop-after:typer" + + override def code = "" // not used + + def code1 = """ +package object p1 { + trait A + object A +} + """ + + def code2 = """ +package object p2 { + class A + object A +} + """ + + def code3 = """ +package object p3 { + object A + trait A +} + """ + + def code4 = """ +package object p4 { + object A + trait A +} + """ + + def show() { + val global = newCompiler() + import global._ + def typecheck(code: String): Unit = { + val r = new Run + val sourceFile = newSources(code).head + global.reporter.reset() + r.compileSources(sourceFile :: Nil) + assert(!global.reporter.hasErrors) + } + + def typecheckTwice(code: String): Unit = { + typecheck(code) + typecheck(code) + } + + // was: illegal cyclic reference involving package ... + Seq(code1, code2, code3, code4) foreach typecheckTwice + } +} diff --git a/test/files/run/t8048a.check b/test/files/run/t8048a.check new file mode 100644 index 0000000000..8fb9e26e84 --- /dev/null +++ b/test/files/run/t8048a.check @@ -0,0 +1 @@ +Some(2) diff --git a/test/files/run/t8048a/Macros_1.scala b/test/files/run/t8048a/Macros_1.scala new file mode 100644 index 0000000000..f48e84f1de --- /dev/null +++ b/test/files/run/t8048a/Macros_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.WhiteboxContext +import scala.language.experimental.macros + +object Macros { + def impl(c: WhiteboxContext) = { + import c.universe._ + q"if (true) Some(2) else None" + } + + def foo: Any = macro impl +}
\ No newline at end of file diff --git a/test/files/run/t8048a/Test_2.scala b/test/files/run/t8048a/Test_2.scala new file mode 100644 index 0000000000..4e1c8b16b0 --- /dev/null +++ b/test/files/run/t8048a/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + val x: Option[Int] = Macros.foo + println(x) +}
\ No newline at end of file diff --git a/test/files/run/t8048b.check b/test/files/run/t8048b.check new file mode 100644 index 0000000000..083edaac24 --- /dev/null +++ b/test/files/run/t8048b.check @@ -0,0 +1,3 @@ +2 +2 +2 diff --git a/test/files/run/t8048b/Macros_1.scala b/test/files/run/t8048b/Macros_1.scala new file mode 100644 index 0000000000..b113af86ea --- /dev/null +++ b/test/files/run/t8048b/Macros_1.scala @@ -0,0 +1,37 @@ +// see the following discussions to understand what's being tested here: +// * https://issues.scala-lang.org/browse/SI-6992 +// * https://issues.scala-lang.org/browse/SI-8048 +// * http://stackoverflow.com/questions/14370842/getting-a-structural-type-with-an-anonymous-classs-methods-from-a-macro +// * http://stackoverflow.com/questions/18480707/method-cannot-be-accessed-in-macro-generated-class/18485004#18485004 +// * https://groups.google.com/forum/#!topic/scala-internals/eXQt-BPm4i8 + +import scala.language.experimental.macros +import scala.reflect.macros.WhiteboxContext + +object Macros { + def impl1(c: WhiteboxContext) = { + import c.universe._ + q""" + trait Foo { def x = 2 } + new Foo {} + """ + } + def foo1: Any = macro impl1 + + def impl2(c: WhiteboxContext) = { + import c.universe._ + q""" + class Foo { def x = 2 } + new Foo + """ + } + def foo2: Any = macro impl2 + + def impl3(c: WhiteboxContext) = { + import c.universe._ + q""" + new { def x = 2 } + """ + } + def foo3: Any = macro impl3 +}
\ No newline at end of file diff --git a/test/files/run/t8048b/Test_2.scala b/test/files/run/t8048b/Test_2.scala new file mode 100644 index 0000000000..fb410dab7a --- /dev/null +++ b/test/files/run/t8048b/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + println(Macros.foo1.x) + println(Macros.foo2.x) + println(Macros.foo3.x) +}
\ No newline at end of file diff --git a/test/files/run/toolbox_current_run_compiles.scala b/test/files/run/toolbox_current_run_compiles.scala index bc6a9d343e..31e0a45eea 100644 --- a/test/files/run/toolbox_current_run_compiles.scala +++ b/test/files/run/toolbox_current_run_compiles.scala @@ -9,7 +9,7 @@ package pkg { val g = c.universe.asInstanceOf[scala.tools.nsc.Global] c.Expr[Boolean](Literal(Constant(g.currentRun.compiles(sym.asInstanceOf[g.Symbol])))) } - def compiles[T] = macro impl[T] + def compiles[T]: Boolean = macro impl[T] } } diff --git a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala index 7905a2ca15..c5cac3ea45 100644 --- a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala +++ b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala @@ -1,5 +1,4 @@ import org.scalacheck._, Prop._, Gen._, Arbitrary._ -import scala.reflect.api.{Liftable, Universe} import scala.reflect.runtime.universe._, Flag._ trait ArbitraryTreesAndNames { @@ -265,14 +264,8 @@ trait ArbitraryTreesAndNames { def genTreeIsTypeWrapped(size: Int) = for(tit <- genTreeIsType(size)) yield TreeIsType(tit) - implicit object liftTreeIsTerm extends Liftable[TreeIsTerm] { - def apply(universe: Universe, value: TreeIsTerm): universe.Tree = - value.tree.asInstanceOf[universe.Tree] - } - implicit object liftTreeIsType extends Liftable[TreeIsType] { - def apply(universe: Universe, value: TreeIsType): universe.Tree = - value.tree.asInstanceOf[universe.Tree] - } + implicit val liftTreeIsTerm = Liftable[TreeIsTerm] { _.tree } + implicit val liftTreeIsType = Liftable[TreeIsType] { _.tree } implicit def treeIsTerm2tree(tit: TreeIsTerm): Tree = tit.tree implicit def treeIsType2tree(tit: TreeIsType): Tree = tit.tree diff --git a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala index 2ec679e78b..2af656c7c9 100644 --- a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala @@ -2,12 +2,25 @@ import org.scalacheck._, Prop._, Gen._, Arbitrary._ import scala.reflect.runtime.universe._, Flag._, build.ScalaDot object DefinitionConstructionProps - extends QuasiquoteProperties("definition construction") - with ClassConstruction - with TraitConstruction - with TypeDefConstruction - with ValDefConstruction - with PackageConstruction + extends QuasiquoteProperties("definition construction") + with ClassConstruction + with TraitConstruction + with TypeDefConstruction + with ValDefConstruction + with PackageConstruction { + property("SI-6842") = test { + val x: Tree = q"val x: Int" + assertEqAst(q"def f($x) = 0", "def f(x: Int) = 0") + assertEqAst(q"class C($x)", "class C(val x: Int)") + assertEqAst(q"class C { $x => }", "class C { x: Int => }") + assertEqAst(q"trait B { $x => }", "trait B { x: Int => }") + assertEqAst(q"object A { $x => }", "object A { x: Int => }") + val t: Tree = q"type T" + assertEqAst(q"def f[$t] = 0", "def f[T] = 0") + assertEqAst(q"class C[$t]", "class C[T]") + assertEqAst(q"trait B[$t]", "trait B[T]") + } +} trait ClassConstruction { self: QuasiquoteProperties => val anyRef = ScalaDot(TypeName("AnyRef")) @@ -283,7 +296,7 @@ trait MethodConstruction { self: QuasiquoteProperties => assertEqAst(q"@$a def foo", "@Foo[A,B] def foo") } - property("splice annotation with multiple argument lists") = test{ + property("splice annotation with multiple argument lists") = test { val a = q"new Foo(a)(b)" assertEqAst(q"@$a def foo", "@Foo(a)(b) def foo") } diff --git a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala index dbd26bf72a..94465930ed 100644 --- a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala @@ -88,6 +88,22 @@ trait ClassDeconstruction { self: QuasiquoteProperties => matches("class Foo { self => bar(self) }") matches("case class Foo(x: Int)") } + + property("SI-7979") = test { + val PARAMACCESSOR = (1 << 29).toLong.asInstanceOf[FlagSet] + assertThrows[MatchError] { + val build.SyntacticClassDef(_, _, _, _, _, _, _, _, _) = + ClassDef( + Modifiers(), TypeName("Foo"), List(), + Template( + List(Select(Ident(TermName("scala")), TypeName("AnyRef"))), + noSelfType, + List( + //ValDef(Modifiers(PRIVATE | LOCAL | PARAMACCESSOR), TermName("x"), Ident(TypeName("Int")), EmptyTree), + DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List(ValDef(Modifiers(PARAM | PARAMACCESSOR), TermName("x"), + Ident(TypeName("Int")), EmptyTree))), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(()))))))) + } + } } trait ModsDeconstruction { self: QuasiquoteProperties => diff --git a/test/files/scalacheck/quasiquotes/ErrorProps.scala b/test/files/scalacheck/quasiquotes/ErrorProps.scala index cb46a60dbe..92d299bede 100644 --- a/test/files/scalacheck/quasiquotes/ErrorProps.scala +++ b/test/files/scalacheck/quasiquotes/ErrorProps.scala @@ -105,13 +105,6 @@ object ErrorProps extends QuasiquoteProperties("errors") { q"f($sb)" """) - property("casedef expected") = fails( - "reflect.runtime.universe.CaseDef expected but reflect.runtime.universe.Tree found", - """ - val t = EmptyTree - q"_ { case $t }" - """) - property("can't splice with ... card here") = fails( "Can't splice with ... here", """ @@ -179,6 +172,20 @@ object ErrorProps extends QuasiquoteProperties("errors") { val q"$m1 $m2 def foo" = EmptyTree """) + property("can't splice values of Null") = fails( + "Can't splice Null, bottom type values often indicate programmer mistake", + """ + val n = null + q"$n" + """) + + property("can't splice values of Nothing") = fails( + "Can't splice Nothing, bottom type values often indicate programmer mistake", + """ + def n = ??? + q"$n" + """) + // // Make sure a nice error is reported in this case // { import Flag._; val mods = NoMods; q"lazy $mods val x: Int" } }
\ No newline at end of file diff --git a/test/files/scalacheck/quasiquotes/LiftableProps.scala b/test/files/scalacheck/quasiquotes/LiftableProps.scala index 1271e1accd..539375d905 100644 --- a/test/files/scalacheck/quasiquotes/LiftableProps.scala +++ b/test/files/scalacheck/quasiquotes/LiftableProps.scala @@ -76,4 +76,39 @@ object LiftableProps extends QuasiquoteProperties("liftable") { val const = Constant(0) assert(q"$const" ≈ q"0") } + + property("lift list variants") = test { + val lst = List(1, 2) + val immutable = q"$scalapkg.collection.immutable" + assert(q"$lst" ≈ q"$immutable.List(1, 2)") + assert(q"f(..$lst)" ≈ q"f(1, 2)") + val llst = List(List(1), List(2)) + assert(q"f(..$llst)" ≈ q"f($immutable.List(1), $immutable.List(2))") + assert(q"f(...$llst)" ≈ q"f(1)(2)") + } + + property("lift tuple") = test { + assert(q"${Tuple1(1)}" ≈ q"scala.Tuple1(1)") + assert(q"${(1, 2)}" ≈ q"(1, 2)") + assert(q"${(1, 2, 3)}" ≈ q"(1, 2, 3)") + assert(q"${(1, 2, 3, 4)}" ≈ q"(1, 2, 3, 4)") + assert(q"${(1, 2, 3, 4, 5)}" ≈ q"(1, 2, 3, 4, 5)") + assert(q"${(1, 2, 3, 4, 5, 6)}" ≈ q"(1, 2, 3, 4, 5, 6)") + assert(q"${(1, 2, 3, 4, 5, 6, 7)}" ≈ q"(1, 2, 3, 4, 5, 6, 7)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)") + assert(q"${(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)}" ≈ q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)") + } }
\ No newline at end of file diff --git a/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala b/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala index b331c4b6b6..5411e664a2 100644 --- a/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala +++ b/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala @@ -120,4 +120,6 @@ trait Helpers { def annot(name: TypeName): Tree = annot(name, Nil) def annot(name: String, args: List[Tree]): Tree = annot(TypeName(name), args) def annot(name: TypeName, args: List[Tree]): Tree = q"new $name(..$args)" -}
\ No newline at end of file + + val scalapkg = build.setSymbol(Ident(TermName("scala")), definitions.ScalaPackage) +} diff --git a/test/files/scalacheck/quasiquotes/RuntimeErrorProps.scala b/test/files/scalacheck/quasiquotes/RuntimeErrorProps.scala new file mode 100644 index 0000000000..a3b6137f68 --- /dev/null +++ b/test/files/scalacheck/quasiquotes/RuntimeErrorProps.scala @@ -0,0 +1,75 @@ +import org.scalacheck._, Prop._, Gen._, Arbitrary._ +import scala.reflect.runtime.universe._, Flag._ + +object RuntimeErrorProps extends QuasiquoteProperties("errors") { + def testFails[T](block: =>T) = test { + assertThrows[IllegalArgumentException] { + block + } + } + + property("default param anon function") = testFails { + val param = q"val x: Int = 1" + q"{ $param => x + 1 }" + } + + property("non-casedef case") = testFails { + val x = q"x" + q"foo match { case $x }" + } + + property("non-new annotation") = testFails { + val annot = q"foo" + q"@$annot def foo" + } + + property("non-valdef param") = testFails { + val param = q"foo" + q"def foo($param)" + } + + property("non-valdef class param") = testFails { + val param = q"foo" + q"class Foo($param)" + } + + property("non-typedef type param") = testFails { + val tparam = tq"T" + q"class C[$tparam]" + } + + property("non-definition refine stat") = testFails { + val stat = q"foo" + tq"Foo { $stat }" + } + + property("non-definition early def") = testFails { + val stat = q"foo" + q"class Foo extends { $stat } with Bar" + } + + property("type apply for definition") = testFails { + val defn = q"def foo" + q"$defn[foo]" + } + + property("non-val selftype") = testFails { + val foo = q"foo" + q"class Foo { $foo => }" + } + + property("for empty enums") = testFails { + val enums = List.empty[Tree] + q"for(..$enums) 0" + } + + property("for starts with non-from enum") = testFails { + val enums = fq"foo = bar" :: Nil + q"for(..$enums) 0" + } + + property("for inlalid enum") = testFails { + val enums = q"foo" :: Nil + q"for(..$enums) 0" + } +} diff --git a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala index cdd96205de..6fb05ff9a4 100644 --- a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala @@ -203,4 +203,25 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") { assert(q"f(..${l1 ++ l2}, $baz)" ≈ q"f(foo, bar, baz)") assert(q"f(${if (true) q"a" else q"b"})" ≈ q"f(a)") } + + property("splice iterable of non-parametric type") = test { + object O extends Iterable[Tree] { def iterator = List(q"foo").iterator } + q"f(..$O)" + } + + property("SI-8016") = test { + val xs = q"1" :: q"2" :: Nil + assertEqAst(q"..$xs", "{1; 2}") + assertEqAst(q"{..$xs}", "{1; 2}") + } + + property("SI-6842") = test { + val cases: List[Tree] = cq"a => b" :: cq"_ => c" :: Nil + assertEqAst(q"1 match { case ..$cases }", "1 match { case a => b case _ => c }") + assertEqAst(q"try 1 catch { case ..$cases }", "try 1 catch { case a => b case _ => c }") + } + + property("SI-8009") = test { + q"`foo`".asInstanceOf[reflect.internal.SymbolTable#Ident].isBackquoted + } } diff --git a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala index bd81afa125..8d1ada342a 100644 --- a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala @@ -3,8 +3,10 @@ import scala.reflect.runtime.universe._, Flag._ object TermDeconstructionProps extends QuasiquoteProperties("term deconstruction") { property("f(..x) = f") = test { - val q"f(..$args)" = q"f" - assert(args ≈ Nil) + // see SI-8008 + assertThrows[MatchError] { + val q"f(..$args)" = q"f" + } } property("f(x)") = forAll { (x: Tree) => diff --git a/test/files/scalacheck/quasiquotes/Test.scala b/test/files/scalacheck/quasiquotes/Test.scala index 8b1e779ab2..7a26fa4923 100644 --- a/test/files/scalacheck/quasiquotes/Test.scala +++ b/test/files/scalacheck/quasiquotes/Test.scala @@ -8,7 +8,9 @@ object Test extends Properties("quasiquotes") { include(PatternConstructionProps) include(PatternDeconstructionProps) include(LiftableProps) + include(UnliftableProps) include(ErrorProps) + include(RuntimeErrorProps) include(DefinitionConstructionProps) include(DefinitionDeconstructionProps) include(DeprecationProps) diff --git a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala index f443330e0b..2f501435e3 100644 --- a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala +++ b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala @@ -50,4 +50,29 @@ object TypecheckedProps extends QuasiquoteProperties("typechecked") { assert(enums1 ≈ enums) assert(body1 ≈ body) } + + property("extract UnApply (1)") = test { + val q"object $_ { $_; $_; $m }" = typecheck(q""" + object Test { + class Cell(val x: Int) + object Cell { def unapply(c: Cell) = Some(c.x) } + new Cell(0) match { case Cell(v) => v } + } + """) + val q"$_ match { case $f(..$args) => $_ }" = m + assert(f ≈ pq"Test.this.Cell") + assert(args ≈ List(pq"v")) + } + + property("extract UnApply (2)") = test { + val q"object $_ { $_; $_; $m }" = typecheck(q""" + object Test { + case class Cell(val x: Int) + new Cell(0) match { case Cell(v) => v } + } + """) + val q"$_ match { case ${f: TypeTree}(..$args) => $_ }" = m + assert(f.original ≈ pq"Test.this.Cell") + assert(args ≈ List(pq"v")) + } }
\ No newline at end of file diff --git a/test/files/scalacheck/quasiquotes/UnliftableProps.scala b/test/files/scalacheck/quasiquotes/UnliftableProps.scala new file mode 100644 index 0000000000..8b827c98ff --- /dev/null +++ b/test/files/scalacheck/quasiquotes/UnliftableProps.scala @@ -0,0 +1,160 @@ +import org.scalacheck._, Prop._, Gen._, Arbitrary._ +import scala.reflect.runtime.universe._, Flag._ + +object UnliftableProps extends QuasiquoteProperties("unliftable") { + property("unlift name") = test { + val termname0 = TermName("foo") + val typename0 = TypeName("foo") + val q"${termname1: TermName}" = Ident(termname0) + assert(termname1 == termname0) + val q"${typename1: TypeName}" = Ident(typename0) + assert(typename1 == typename0) + val q"${name1: Name}" = Ident(termname0) + assert(name1 == termname0) + val q"${name2: Name}" = Ident(typename0) + assert(name2 == typename0) + } + + property("unlift type") = test { + val q"${tpe: Type}" = TypeTree(typeOf[Int]) + assert(tpe =:= typeOf[Int]) + } + + property("unlift constant") = test { + val q"${const: Constant}" = Literal(Constant("foo")) + assert(const == Constant("foo")) + } + + property("unlift char") = test { + val q"${c: Char}" = Literal(Constant('0')) + assert(c.isInstanceOf[Char] && c == '0') + } + + property("unlift byte") = test { + val q"${b: Byte}" = Literal(Constant(0: Byte)) + assert(b.isInstanceOf[Byte] && b == 0) + } + + property("unlift short") = test { + val q"${s: Short}" = Literal(Constant(0: Short)) + assert(s.isInstanceOf[Short] && s == 0) + } + + property("unlift int") = test { + val q"${i: Int}" = Literal(Constant(0: Int)) + assert(i.isInstanceOf[Int] && i == 0) + } + + property("unlift long") = test { + val q"${l: Long}" = Literal(Constant(0L: Long)) + assert(l.isInstanceOf[Long] && l == 0L) + } + + property("unlift float") = test { + val q"${f: Float}" = Literal(Constant(0.0f: Float)) + assert(f.isInstanceOf[Float] && f == 0.0f) + } + + property("unlift double") = test { + val q"${d: Double}" = Literal(Constant(0.0: Double)) + assert(d.isInstanceOf[Double] && d == 0.0) + } + + property("unlift bool") = test { + val q"${b: Boolean}" = q"true" + assert(b.isInstanceOf[Boolean] && b == true) + } + + property("unlift string") = test { + val q"${s: String}" = q""" "foo" """ + assert(s.isInstanceOf[String] && s == "foo") + } + + property("unlift scala.symbol") = test { + val q"${s: scala.Symbol}" = q"'foo" + assert(s.isInstanceOf[scala.Symbol] && s == 'foo) + } + + implicit def unliftList[T: Unliftable]: Unliftable[List[T]] = Unliftable { + case q"scala.collection.immutable.List(..$args)" if args.forall { implicitly[Unliftable[T]].unapply(_).nonEmpty } => + val ut = implicitly[Unliftable[T]] + args.flatMap { ut.unapply(_) } + } + + property("unlift list (1)") = test { + val orig = List(1, 2) + val q"${l1: List[Int]}" = q"$orig" // q"List(1, 2)" + assert(l1 == orig) + val q"f(..${l2: List[Int]})" = q"f(..$orig)" // q"f(1, 2) + assert(l2 == orig) + } + + property("unlift list (2)") = test { + val orig2 = List(List(1, 2), List(3)) + val q"f(${l3: List[List[Int]]})" = q"f($orig2)" // q"f(List(List(1, 2), List(3))) + assert(l3 == orig2) + val q"f(..${l4: List[List[Int]]})" = q"f(..$orig2)" // q"f(List(1, 2), List(3))" + assert(l4 == orig2) + val q"f(...${l5: List[List[Int]]})" = q"f(...$orig2)" // q"f(1, 2)(3) + assert(l5 == orig2) + } + + property("don't unlift non-tree splicee (1)") = test { + val q"${a: TermName}.${b: TermName}" = q"a.b" + assert(a == TermName("a")) + assert(b == TermName("b")) + } + + property("don't unlift non-tree splicee (2)") = test { + val q"${mods: Modifiers} def foo" = q"def foo" + assert(mods == Modifiers(DEFERRED)) + } + + property("unlift tuple") = test { + // fails due to SI-8045 + // val q"${t1: Tuple1[Int]}" = q"_root_.scala.Tuple1(1)" + val q"${t2: (Int, Int)}" = q"(1, 2)" + val q"${t3: (Int, Int, Int)}" = q"(1, 2, 3)" + val q"${t4: (Int, Int, Int, Int)}" = q"(1, 2, 3, 4)" + val q"${t5: (Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5)" + val q"${t6: (Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6)" + val q"${t7: (Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7)" + val q"${t8: (Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8)" + val q"${t9: (Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9)" + val q"${t10: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)" + val q"${t11: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)" + val q"${t12: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)" + val q"${t13: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)" + val q"${t14: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)" + val q"${t15: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)" + val q"${t16: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)" + val q"${t17: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)" + val q"${t18: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)" + val q"${t19: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)" + val q"${t20: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)" + val q"${t21: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)" + val q"${t22: (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)}" = q"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)" + // assert(t1 == Tuple1(1)) + assert(t2 == (1, 2)) + assert(t3 == (1, 2, 3)) + assert(t4 == (1, 2, 3, 4)) + assert(t5 == (1, 2, 3, 4, 5)) + assert(t6 == (1, 2, 3, 4, 5, 6)) + assert(t7 == (1, 2, 3, 4, 5, 6, 7)) + assert(t8 == (1, 2, 3, 4, 5, 6, 7, 8)) + assert(t9 == (1, 2, 3, 4, 5, 6, 7, 8, 9)) + assert(t10 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) + assert(t11 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)) + assert(t12 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) + assert(t13 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) + assert(t14 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)) + assert(t15 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) + assert(t16 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)) + assert(t17 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)) + assert(t18 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)) + assert(t19 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)) + assert(t20 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)) + assert(t21 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)) + assert(t22 == (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)) + } +} |