diff options
Diffstat (limited to 'test/files')
43 files changed, 298 insertions, 37 deletions
diff --git a/test/files/neg/t6426.check b/test/files/neg/t6426.check deleted file mode 100644 index 149f74c4de..0000000000 --- a/test/files/neg/t6426.check +++ /dev/null @@ -1,7 +0,0 @@ -t6426.scala:4: error: wildcard invalid as backquoted identifier - println(`_`.Buffer(0)) - ^ -t6426.scala:5: error: ')' expected but '}' found. -} -^ -two errors found diff --git a/test/files/neg/t6426.scala b/test/files/neg/t6426.scala deleted file mode 100644 index a27d18eb58..0000000000 --- a/test/files/neg/t6426.scala +++ /dev/null @@ -1,5 +0,0 @@ -class A { - import collection.{mutable => _, _} - - println(`_`.Buffer(0)) -} diff --git a/test/files/neg/t6563.check b/test/files/neg/t6563.check new file mode 100644 index 0000000000..75dca1507d --- /dev/null +++ b/test/files/neg/t6563.check @@ -0,0 +1,4 @@ +t6563.scala:4: error: not found: value e + e("f") + ^ +one error found diff --git a/test/files/neg/t6563.scala b/test/files/neg/t6563.scala new file mode 100644 index 0000000000..b0077b6f94 --- /dev/null +++ b/test/files/neg/t6563.scala @@ -0,0 +1,8 @@ +class A{ + def b(c: => Unit){} + b{ + e("f") + new G()(){} + } +} +class G(h:String="i")() diff --git a/test/files/neg/t8158.check b/test/files/neg/t8158.check new file mode 100644 index 0000000000..fa6b744ba5 --- /dev/null +++ b/test/files/neg/t8158.check @@ -0,0 +1,4 @@ +Test_2.scala:10: error: not enough patterns for <$anon: AnyRef> offering AnyRef{def isEmpty: Boolean; def get: $anon; def unapply(x: String): $anon}: expected 1, found 0 + case X() => + ^ +one error found diff --git a/test/files/neg/t8158/Macros_1.scala b/test/files/neg/t8158/Macros_1.scala new file mode 100644 index 0000000000..b84e3ed8d3 --- /dev/null +++ b/test/files/neg/t8158/Macros_1.scala @@ -0,0 +1,34 @@ +import scala.language.experimental.macros +import scala.reflect.macros.whitebox.Context + +object Max { + def impl(c: Context)(any: c.Expr[Any]): c.Expr[Any] = { + import c.universe._ + def fail(msg: String) = c.abort(c.enclosingPosition, msg) + val t = c.macroApplication match { + case q"$_.unapply($unargs)" => + /* hangs + */ + q""" + new { + def isEmpty = false + def get = this + def unapply(x: String) = this + }.unapply($unargs) + """ + /* + if get returns Unit or Boolean: + wrong number of patterns for <$anon: AnyRef> offering Unit: expected 1, found 0 + */ + /* straightforward + q""" + new { + def unapply(x: String) = true + }.unapply($unargs) + """ + */ + case _ => fail("bad appl") + } + c.Expr[Any](t) + } +}
\ No newline at end of file diff --git a/test/files/neg/t8158/Test_2.scala b/test/files/neg/t8158/Test_2.scala new file mode 100644 index 0000000000..f5ac6616bb --- /dev/null +++ b/test/files/neg/t8158/Test_2.scala @@ -0,0 +1,14 @@ +import scala.language.experimental.macros + +object X { + def unapply(any: Any): Any = macro Max.impl +} + +class BugTest { + def bug(): Unit = { + "any" match { + case X() => + case _ => ??? + } + } +}
\ No newline at end of file diff --git a/test/files/pos/debug-reset-local-attrs.flags b/test/files/pos/debug-reset-local-attrs.flags new file mode 100644 index 0000000000..9c7d6400fc --- /dev/null +++ b/test/files/pos/debug-reset-local-attrs.flags @@ -0,0 +1 @@ +-Ydebug diff --git a/test/files/pos/debug-reset-local-attrs.scala b/test/files/pos/debug-reset-local-attrs.scala new file mode 100644 index 0000000000..8348657965 --- /dev/null +++ b/test/files/pos/debug-reset-local-attrs.scala @@ -0,0 +1 @@ +case class FT(f : Float) diff --git a/test/files/pos/t8062.flags b/test/files/pos/t8062.flags new file mode 100644 index 0000000000..49d036a887 --- /dev/null +++ b/test/files/pos/t8062.flags @@ -0,0 +1 @@ +-optimize diff --git a/test/files/pos/t8062/A_1.scala b/test/files/pos/t8062/A_1.scala new file mode 100644 index 0000000000..ca0411dae8 --- /dev/null +++ b/test/files/pos/t8062/A_1.scala @@ -0,0 +1,5 @@ +package warmup + +object Warmup { + def filter[A](p: Any => Boolean): Any = filter[Any](p) +} diff --git a/test/files/pos/t8062/B_2.scala b/test/files/pos/t8062/B_2.scala new file mode 100644 index 0000000000..f0a6761488 --- /dev/null +++ b/test/files/pos/t8062/B_2.scala @@ -0,0 +1,3 @@ +object Test { + warmup.Warmup.filter[Any](x => false) +} diff --git a/test/files/pos/t8111.scala b/test/files/pos/t8111.scala new file mode 100644 index 0000000000..0d63a16ba4 --- /dev/null +++ b/test/files/pos/t8111.scala @@ -0,0 +1,24 @@ +trait T { + + def crashy(ma: Any) { + // okay + val f1 = (u: Unit) => ma + foo(f1)() + foo((u: Unit) => ma) + foo(0, (u: Any) => ma) apply () + + // crash due to side effects on the onwer of the symbol in the + // qualifier or arguments of the application during an abandoned + // names/defaults transform. The code type checkes because of + // autp-tupling which promotes and empty parmater list to `(): Unit` + foo((u: Any) => ma)() + + {{(u: Any) => ma}; this}.foo(0)() + + foo({def foo = ma; 0})() + + {def foo = ma; this}.foo(0)() + } + + def foo(f: Any): Any => Any +} diff --git a/test/files/pos/t8138.scala b/test/files/pos/t8138.scala new file mode 100644 index 0000000000..b980930955 --- /dev/null +++ b/test/files/pos/t8138.scala @@ -0,0 +1,24 @@ + +class U { + trait Transformer { + def transform(a: Tree): Tree = ??? + } + trait Tree +} + +object Test { + def m(u: U) = { + class C extends u.Transformer { + override def transform(t: u.Tree): u.Tree = { + null match { + case _ => + // crashes in GenICode: + // error: Unknown type: <notype>, <notype> [class scala.reflect.internal.Types$NoType$, class scala.reflect.internal.Types$NoType$] TypeRef? false + (y: Any) => super.transform(???) + null + } + ??? + } + } + } +} diff --git a/test/files/presentation/t8085.check b/test/files/presentation/t8085.check new file mode 100644 index 0000000000..921ca7528b --- /dev/null +++ b/test/files/presentation/t8085.check @@ -0,0 +1,3 @@ +reload: NodeScalaSuite.scala +open package module: package object nodescala +Test OK diff --git a/test/files/presentation/t8085.flags b/test/files/presentation/t8085.flags new file mode 100644 index 0000000000..ec35b223d8 --- /dev/null +++ b/test/files/presentation/t8085.flags @@ -0,0 +1 @@ +-sourcepath src diff --git a/test/files/presentation/t8085/Test.scala b/test/files/presentation/t8085/Test.scala new file mode 100644 index 0000000000..e46b7ab8c8 --- /dev/null +++ b/test/files/presentation/t8085/Test.scala @@ -0,0 +1,27 @@ +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 src = loadSourceAndWaitUntilTypechecked("NodeScalaSuite.scala") + checkErrors(src) + } + + private def loadSourceAndWaitUntilTypechecked(sourceName: String): SourceFile = { + val sourceFile = sourceFiles.find(_.file.name == sourceName).head + askReload(List(sourceFile)).get + askLoadedTyped(sourceFile).get + sourceFile + } + + private def checkErrors(source: SourceFile): Unit = compiler.getUnitOf(source) match { + case Some(unit) => + val problems = unit.problems.toList + if(problems.isEmpty) reporter.println("Test OK") + else problems.foreach(problem => reporter.println(problem.msg)) + + case None => reporter.println("No compilation unit found for " + source.file.name) + } +} diff --git a/test/files/presentation/t8085/src/nodescala/Foo.scala b/test/files/presentation/t8085/src/nodescala/Foo.scala new file mode 100644 index 0000000000..19efdb65dd --- /dev/null +++ b/test/files/presentation/t8085/src/nodescala/Foo.scala @@ -0,0 +1,3 @@ +package nodescala + +class Foo diff --git a/test/files/presentation/t8085/src/nodescala/NodeScalaSuite.scala b/test/files/presentation/t8085/src/nodescala/NodeScalaSuite.scala new file mode 100644 index 0000000000..45e43c7afb --- /dev/null +++ b/test/files/presentation/t8085/src/nodescala/NodeScalaSuite.scala @@ -0,0 +1,10 @@ +package nodescala + +class NodeScalaSuite { + "".rich + + // This is here only to prove that the presentation compiler is instantiated with the + // correct `sourcepath` value (if it wasn't, you would see a `not found: type Foo` in + // the test's output + println(new Foo()) +} diff --git a/test/files/presentation/t8085/src/nodescala/package.scala b/test/files/presentation/t8085/src/nodescala/package.scala new file mode 100644 index 0000000000..26fb9f08e4 --- /dev/null +++ b/test/files/presentation/t8085/src/nodescala/package.scala @@ -0,0 +1,7 @@ +import scala.Some // <-- if you move the import *inside* the package object, then it all works fine!! + +package object nodescala { + implicit class StringOps(val f: String) { + def rich = 0 + } +} diff --git a/test/files/presentation/t8085b.check b/test/files/presentation/t8085b.check new file mode 100644 index 0000000000..921ca7528b --- /dev/null +++ b/test/files/presentation/t8085b.check @@ -0,0 +1,3 @@ +reload: NodeScalaSuite.scala +open package module: package object nodescala +Test OK diff --git a/test/files/presentation/t8085b.flags b/test/files/presentation/t8085b.flags new file mode 100644 index 0000000000..ec35b223d8 --- /dev/null +++ b/test/files/presentation/t8085b.flags @@ -0,0 +1 @@ +-sourcepath src diff --git a/test/files/presentation/t8085b/Test.scala b/test/files/presentation/t8085b/Test.scala new file mode 100644 index 0000000000..e46b7ab8c8 --- /dev/null +++ b/test/files/presentation/t8085b/Test.scala @@ -0,0 +1,27 @@ +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 src = loadSourceAndWaitUntilTypechecked("NodeScalaSuite.scala") + checkErrors(src) + } + + private def loadSourceAndWaitUntilTypechecked(sourceName: String): SourceFile = { + val sourceFile = sourceFiles.find(_.file.name == sourceName).head + askReload(List(sourceFile)).get + askLoadedTyped(sourceFile).get + sourceFile + } + + private def checkErrors(source: SourceFile): Unit = compiler.getUnitOf(source) match { + case Some(unit) => + val problems = unit.problems.toList + if(problems.isEmpty) reporter.println("Test OK") + else problems.foreach(problem => reporter.println(problem.msg)) + + case None => reporter.println("No compilation unit found for " + source.file.name) + } +} diff --git a/test/files/presentation/t8085b/src/p1/nodescala/Foo.scala b/test/files/presentation/t8085b/src/p1/nodescala/Foo.scala new file mode 100644 index 0000000000..8ed1ada6b6 --- /dev/null +++ b/test/files/presentation/t8085b/src/p1/nodescala/Foo.scala @@ -0,0 +1,4 @@ +package p1 +package nodescala + +class Foo diff --git a/test/files/presentation/t8085b/src/p1/nodescala/NodeScalaSuite.scala b/test/files/presentation/t8085b/src/p1/nodescala/NodeScalaSuite.scala new file mode 100644 index 0000000000..f6da67bdc7 --- /dev/null +++ b/test/files/presentation/t8085b/src/p1/nodescala/NodeScalaSuite.scala @@ -0,0 +1,11 @@ +package p1 +package nodescala + +class NodeScalaSuite { + "".rich + + // This is here only to prove that the presentation compiler is instantiated with the + // correct `sourcepath` value (if it wasn't, you would see a `not found: type Foo` in + // the test's output + println(new Foo()) +} diff --git a/test/files/presentation/t8085b/src/p1/nodescala/package.scala b/test/files/presentation/t8085b/src/p1/nodescala/package.scala new file mode 100644 index 0000000000..cc383f1bab --- /dev/null +++ b/test/files/presentation/t8085b/src/p1/nodescala/package.scala @@ -0,0 +1,9 @@ +import scala.Some // <-- if you move the import *inside* the package object, then it all works fine!! + +package p1 { + package object nodescala { + implicit class StringOps(val f: String) { + def rich = 0 + } + } +} diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index d965d8a2ff..9a106785a1 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -149,13 +149,3 @@ scala> val x = 3 : Int @Annot(e+f+g+h) // should have a graceful error message ^ scala> - -scala> class Where(condition: Boolean) extends annotation.Annotation -defined class Where - -scala> - -scala> val x : Int @Where(self > 0 && self < 100) = 3 -x: Int @Where(self.>(0).&&(self.<(100))) = 3 - -scala> diff --git a/test/files/run/constrained-types.scala b/test/files/run/constrained-types.scala index 91bd856d00..7ec8f93d38 100644 --- a/test/files/run/constrained-types.scala +++ b/test/files/run/constrained-types.scala @@ -72,16 +72,10 @@ object A { val x = "hello" : String @ rep } val y = a.x // should drop the annotation val x = 3 : Int @Annot(e+f+g+h) // should have a graceful error message - -class Where(condition: Boolean) extends annotation.Annotation - -val x : Int @Where(self > 0 && self < 100) = 3 - """ override def transformSettings(s: Settings): Settings = { s.Xexperimental.value = true - s.selfInAnnots.value = true s.deprecation.value = true // when running that compiler, give it a scala-library to the classpath s.classpath.value = sys.props("java.class.path") diff --git a/test/files/run/idempotency-case-classes.scala b/test/files/run/idempotency-case-classes.scala index 81e119582b..4ad132174d 100644 --- a/test/files/run/idempotency-case-classes.scala +++ b/test/files/run/idempotency-case-classes.scala @@ -12,7 +12,7 @@ object Test extends App { val tb = cm.mkToolBox() val tcasee = tb.typecheck(casee.tree) println(tcasee) - val rtcasee = tb.resetAllAttrs(tcasee) + val rtcasee = tb.untypecheck(tcasee) try { println(tb.eval(rtcasee)) } catch { diff --git a/test/files/run/idempotency-extractors.scala b/test/files/run/idempotency-extractors.scala index b66b043be1..8c0a0b1106 100644 --- a/test/files/run/idempotency-extractors.scala +++ b/test/files/run/idempotency-extractors.scala @@ -12,7 +12,7 @@ object Test extends App { val tb = cm.mkToolBox() val textractor = tb.typecheck(extractor.tree) println(textractor) - val rtextractor = tb.resetAllAttrs(textractor) + val rtextractor = tb.untypecheck(textractor) try { println(tb.eval(rtextractor)) } catch { diff --git a/test/files/run/idempotency-labels.scala b/test/files/run/idempotency-labels.scala index f1a185d3d0..084c93d3c6 100644 --- a/test/files/run/idempotency-labels.scala +++ b/test/files/run/idempotency-labels.scala @@ -13,7 +13,7 @@ object Test extends App { val tb = cm.mkToolBox() val tlabel = tb.typecheck(label.tree) println(tlabel) - val rtlabel = tb.resetAllAttrs(tlabel) + val rtlabel = tb.untypecheck(tlabel) try { println(tb.eval(rtlabel)) } catch { diff --git a/test/files/run/idempotency-lazy-vals.scala b/test/files/run/idempotency-lazy-vals.scala index e763f2f3f4..9d677caeca 100644 --- a/test/files/run/idempotency-lazy-vals.scala +++ b/test/files/run/idempotency-lazy-vals.scala @@ -17,7 +17,7 @@ object Test extends App { val tb = cm.mkToolBox() val tlazee = tb.typecheck(lazee.tree) println(tlazee) - val rtlazee = tb.resetAllAttrs(tlazee) + val rtlazee = tb.untypecheck(tlazee) try { println(tb.eval(rtlazee)) } catch { diff --git a/test/files/run/idempotency-this.scala b/test/files/run/idempotency-this.scala index 2db1efd2d1..26917ab743 100644 --- a/test/files/run/idempotency-this.scala +++ b/test/files/run/idempotency-this.scala @@ -12,7 +12,7 @@ object Test extends App { val tthiss = tb.typecheck(thiss.tree) println(tthiss) println(showRaw(tthiss)) - val rtthiss = tb.resetAllAttrs(tthiss) + val rtthiss = tb.untypecheck(tthiss) try { println(tb.eval(rtthiss)) } catch { diff --git a/test/files/run/large_code.check b/test/files/run/large_code.check new file mode 100644 index 0000000000..6ad50967bc --- /dev/null +++ b/test/files/run/large_code.check @@ -0,0 +1,3 @@ +newSource1.scala:1: error: Could not write class BigEnoughToFail because it exceeds JVM code size limits. Method tooLong's code too large! +class BigEnoughToFail { + ^ diff --git a/test/files/run/large_code.scala b/test/files/run/large_code.scala new file mode 100644 index 0000000000..f9d7f8c95b --- /dev/null +++ b/test/files/run/large_code.scala @@ -0,0 +1,24 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +// a cold run of partest takes about 15s for this test on my laptop +object Test extends DirectTest { + override def extraSettings: String = "-usejavacp -d " + testOutput.path + + // test that we hit the code size limit and error out gracefully + // 5958 is the magic number (2^16/11 -- each `a(1,2,3,4,5,6)` is 11 bytes of bytecode) + override def code + = s""" + |class BigEnoughToFail { + | def a(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int): Unit = {} + | def tooLong: Unit = { + | ${(1 to 5958) map (_ => "a(1,2,3,4,5,6)") mkString(";")} + | } + |}""".stripMargin.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} diff --git a/test/files/run/resetattrs-this.scala b/test/files/run/resetattrs-this.scala index 6150a4e265..ff45d61dfe 100644 --- a/test/files/run/resetattrs-this.scala +++ b/test/files/run/resetattrs-this.scala @@ -6,6 +6,6 @@ object Test extends App { val tb = cm.mkToolBox() val tree = Select(This(cm.staticPackage("scala").moduleClass), TermName("Predef")) val ttree = tb.typecheck(tree) - val rttree = tb.resetAllAttrs(ttree) + val rttree = tb.untypecheck(ttree) println(tb.eval(rttree) == Predef) } diff --git a/test/files/run/t5256h.check b/test/files/run/t5256h.check index 1a4a92a684..dc3e919897 100644 --- a/test/files/run/t5256h.check +++ b/test/files/run/t5256h.check @@ -3,5 +3,5 @@ Test.$anon$1 java.lang.Object { final private val x: Int def x(): Int - def <init>(): java.lang.Object{def x(): Int} + def <init>(): $anon$1 } diff --git a/test/files/run/t6187.check b/test/files/run/t6187.check index 97ee68271a..0180125809 100644 --- a/test/files/run/t6187.check +++ b/test/files/run/t6187.check @@ -7,7 +7,7 @@ import scala.reflect.macros.blackbox.Context scala> def macroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T]] = { val r = c.universe.reify { List(t.splice) } - c.Expr[List[T]]( c.resetLocalAttrs(r.tree) ) + c.Expr[List[T]]( c.untypecheck(r.tree) ) } macroImpl: [T](c: scala.reflect.macros.blackbox.Context)(t: c.Expr[T])(implicit evidence$1: c.WeakTypeTag[T])c.Expr[List[T]] diff --git a/test/files/run/t6187.scala b/test/files/run/t6187.scala index 7d84419b8a..7a39cfd9e7 100644 --- a/test/files/run/t6187.scala +++ b/test/files/run/t6187.scala @@ -5,7 +5,7 @@ object Test extends ReplTest { import scala.language.experimental.macros, scala.reflect.macros.blackbox.Context def macroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T]] = { val r = c.universe.reify { List(t.splice) } - c.Expr[List[T]]( c.resetLocalAttrs(r.tree) ) + c.Expr[List[T]]( c.untypecheck(r.tree) ) } def demo[T](t: T): List[T] = macro macroImpl[T] def m[T](t: T): List[List[T]] = diff --git a/test/files/run/t8133/A_1.scala b/test/files/run/t8133/A_1.scala new file mode 100644 index 0000000000..a2836cdb3a --- /dev/null +++ b/test/files/run/t8133/A_1.scala @@ -0,0 +1,5 @@ +// a.scala +package object pkg { + class AnyOps(val x: Any) extends AnyVal + def AnyOps(x: Any) = new AnyOps(x) +} diff --git a/test/files/run/t8133/B_2.scala b/test/files/run/t8133/B_2.scala new file mode 100644 index 0000000000..b80e10952d --- /dev/null +++ b/test/files/run/t8133/B_2.scala @@ -0,0 +1,15 @@ +package pkg { + package object other + package other { + class Crash { + AnyOps(0) + () + } + } +} + +object Test { + def main(args: Array[String]): Unit = { + new pkg.other.Crash + } +} diff --git a/test/files/run/t8133b/A_1.scala b/test/files/run/t8133b/A_1.scala new file mode 100644 index 0000000000..24bbfc118d --- /dev/null +++ b/test/files/run/t8133b/A_1.scala @@ -0,0 +1,4 @@ +package object pkg { + def foo(x: Int): String = "a" + def foo(x: String): String = "b" +} diff --git a/test/files/run/t8133b/B_2.scala b/test/files/run/t8133b/B_2.scala new file mode 100644 index 0000000000..865ca0c0b0 --- /dev/null +++ b/test/files/run/t8133b/B_2.scala @@ -0,0 +1,9 @@ +// b.scala +package pkg { + package object other + package other { class Crash { foo("") } } +} + +object Test { + def main(args: Array[String]): Unit = new pkg.other.Crash +} |