diff options
Diffstat (limited to 'test/files')
28 files changed, 159 insertions, 71 deletions
diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check index ce3c8062d7..9a2162a906 100644 --- a/test/files/jvm/interpreter.check +++ b/test/files/jvm/interpreter.check @@ -353,7 +353,7 @@ defined class Term scala> def f(e: Exp) = e match { // non-exhaustive warning here case _:Fact => 3 } -<console>:22: warning: match may not be exhaustive. +<console>:18: warning: match may not be exhaustive. It would fail on the following inputs: Exp(), Term() def f(e: Exp) = e match { // non-exhaustive warning here ^ diff --git a/test/files/jvm/serialization-new.check b/test/files/jvm/serialization-new.check index cb26446f40..1c5dd4828b 100644 --- a/test/files/jvm/serialization-new.check +++ b/test/files/jvm/serialization-new.check @@ -85,12 +85,12 @@ x = List((buffers,20), (layers,2), (title,3)) y = List((buffers,20), (layers,2), (title,3)) x equals y: true, y equals x: true -x = Map(buffers -> 20, layers -> 2, title -> 3) -y = Map(buffers -> 20, layers -> 2, title -> 3) +x = ListMap(buffers -> 20, layers -> 2, title -> 3) +y = ListMap(buffers -> 20, layers -> 2, title -> 3) x equals y: true, y equals x: true -x = ListSet(5, 3) -y = ListSet(5, 3) +x = ListSet(3, 5) +y = ListSet(3, 5) x equals y: true, y equals x: true x = Queue(a, b, c) diff --git a/test/files/jvm/serialization.check b/test/files/jvm/serialization.check index cb26446f40..1c5dd4828b 100644 --- a/test/files/jvm/serialization.check +++ b/test/files/jvm/serialization.check @@ -85,12 +85,12 @@ x = List((buffers,20), (layers,2), (title,3)) y = List((buffers,20), (layers,2), (title,3)) x equals y: true, y equals x: true -x = Map(buffers -> 20, layers -> 2, title -> 3) -y = Map(buffers -> 20, layers -> 2, title -> 3) +x = ListMap(buffers -> 20, layers -> 2, title -> 3) +y = ListMap(buffers -> 20, layers -> 2, title -> 3) x equals y: true, y equals x: true -x = ListSet(5, 3) -y = ListSet(5, 3) +x = ListSet(3, 5) +y = ListSet(3, 5) x equals y: true, y equals x: true x = Queue(a, b, c) diff --git a/test/files/neg/constrs.check b/test/files/neg/constrs.check index 4f4a12bc13..8a5bd97ae3 100644 --- a/test/files/neg/constrs.check +++ b/test/files/neg/constrs.check @@ -7,7 +7,7 @@ constrs.scala:6: error: value u is not a member of object test constrs.scala:10: error: called constructor's definition must precede calling constructor's definition def this() = this("abc") ^ -constrs.scala:12: error: called constructor's definition must precede calling constructor's definition +constrs.scala:12: error: constructor invokes itself def this(x: Boolean) = this(x) ^ constrs.scala:16: error: type mismatch; diff --git a/test/files/neg/t4460a.check b/test/files/neg/t4460a.check index b711e7acb1..7a7618a114 100644 --- a/test/files/neg/t4460a.check +++ b/test/files/neg/t4460a.check @@ -1,4 +1,4 @@ -t4460a.scala:6: error: called constructor's definition must precede calling constructor's definition +t4460a.scala:6: error: constructor invokes itself def this() = this() // was binding to Predef.<init> !! ^ one error found diff --git a/test/files/neg/t4460b.check b/test/files/neg/t4460b.check index f0e703fd10..9a621dbd5c 100644 --- a/test/files/neg/t4460b.check +++ b/test/files/neg/t4460b.check @@ -1,4 +1,4 @@ -t4460b.scala:7: error: called constructor's definition must precede calling constructor's definition +t4460b.scala:7: error: constructor invokes itself def this() = this() // was binding to Predef.<init> !! ^ one error found diff --git a/test/files/neg/t9045.check b/test/files/neg/t9045.check new file mode 100644 index 0000000000..07d0e2dd74 --- /dev/null +++ b/test/files/neg/t9045.check @@ -0,0 +1,7 @@ +t9045.scala:3: error: constructor invokes itself + def this(axes: Array[Int]) = this(axes) + ^ +t9045.scala:6: error: called constructor's definition must precede calling constructor's definition + def this(d: Double) = this(d.toLong) + ^ +two errors found diff --git a/test/files/neg/t9045.scala b/test/files/neg/t9045.scala new file mode 100644 index 0000000000..e6710ab324 --- /dev/null +++ b/test/files/neg/t9045.scala @@ -0,0 +1,8 @@ + +case class AffineImageShape(axes: Seq[Int]) { + def this(axes: Array[Int]) = this(axes) +} +class X(i: Int) { + def this(d: Double) = this(d.toLong) + def this(n: Long) = this(n.toInt) +} diff --git a/test/files/pos/constant-warning.check b/test/files/pos/constant-warning.check new file mode 100644 index 0000000000..f7df2165d1 --- /dev/null +++ b/test/files/pos/constant-warning.check @@ -0,0 +1,4 @@ +constant-warning.scala:2: warning: Evaluation of a constant expression results in an arithmetic error: / by zero + val fails = 1 + 2 / (3 - 2 - 1) + ^ +one warning found diff --git a/test/files/pos/constant-warning.flags b/test/files/pos/constant-warning.flags new file mode 100644 index 0000000000..d00cbbe77b --- /dev/null +++ b/test/files/pos/constant-warning.flags @@ -0,0 +1 @@ +-Xlint:constant diff --git a/test/files/pos/constant-warning.scala b/test/files/pos/constant-warning.scala new file mode 100644 index 0000000000..c8ca8823e7 --- /dev/null +++ b/test/files/pos/constant-warning.scala @@ -0,0 +1,3 @@ +object Test { + val fails = 1 + 2 / (3 - 2 - 1) +} diff --git a/test/files/pos/t9397.scala b/test/files/pos/t9397.scala new file mode 100644 index 0000000000..3dbc6591d3 --- /dev/null +++ b/test/files/pos/t9397.scala @@ -0,0 +1,12 @@ +package foo.scala + +import scala.reflect.runtime.universe._ + +object Foo { + + def bar[T: TypeTag]() { + } + + import foo._ + bar[String]() +} diff --git a/test/files/run/reify_printf.scala b/test/files/run/reify_printf.scala index c4ade79837..099a353e89 100644 --- a/test/files/run/reify_printf.scala +++ b/test/files/run/reify_printf.scala @@ -6,7 +6,6 @@ import scala.tools.reflect.ToolBox import scala.reflect.api._ import scala.reflect.api.Trees import scala.reflect.internal.Types -import scala.util.matching.Regex object Test extends App { //val output = new ByteArrayOutputStream() diff --git a/test/files/run/repl-classbased.check b/test/files/run/repl-classbased.check new file mode 100644 index 0000000000..e11fc170e5 --- /dev/null +++ b/test/files/run/repl-classbased.check @@ -0,0 +1,23 @@ + +scala> case class K(s: String) +defined class K + +scala> class C { implicit val k: K = K("OK?"); override def toString = s"C($k)" } +defined class C + +scala> val c = new C +c: C = C(K(OK?)) + +scala> import c.k +import c.k + +scala> implicitly[K] +res0: K = K(OK?) + +scala> val k = 42 +k: Int = 42 + +scala> k // was K(OK?) +res1: Int = 42 + +scala> :quit diff --git a/test/files/run/repl-classbased.scala b/test/files/run/repl-classbased.scala new file mode 100644 index 0000000000..595e123159 --- /dev/null +++ b/test/files/run/repl-classbased.scala @@ -0,0 +1,22 @@ + +import scala.tools.partest.ReplTest +import scala.tools.nsc.Settings + +//SI-9740 +object Test extends ReplTest { + override def transformSettings(s: Settings): Settings = { + s.Yreplclassbased.value = true + s + } + + def code = + """ +case class K(s: String) +class C { implicit val k: K = K("OK?"); override def toString = s"C($k)" } +val c = new C +import c.k +implicitly[K] +val k = 42 +k // was K(OK?) + """ +} diff --git a/test/files/run/repl-implicits-nopredef.check b/test/files/run/repl-implicits-nopredef.check new file mode 100644 index 0000000000..a849801bb4 --- /dev/null +++ b/test/files/run/repl-implicits-nopredef.check @@ -0,0 +1,5 @@ + +scala> :implicits +No implicits have been imported. + +scala> :quit
\ No newline at end of file diff --git a/test/files/run/repl-implicits-nopredef.scala b/test/files/run/repl-implicits-nopredef.scala new file mode 100644 index 0000000000..8a451b0c52 --- /dev/null +++ b/test/files/run/repl-implicits-nopredef.scala @@ -0,0 +1,10 @@ +import scala.tools.partest.ReplTest +import scala.tools.nsc.Settings + +object Test extends ReplTest { + override def transformSettings(settings: Settings): Settings = { + settings.nopredef.value = true + settings + } + def code = ":implicits" +} diff --git a/test/files/run/repl-implicits.check b/test/files/run/repl-implicits.check new file mode 100644 index 0000000000..6e80cc8799 --- /dev/null +++ b/test/files/run/repl-implicits.check @@ -0,0 +1,5 @@ + +scala> :implicits +No implicits have been imported other than those in Predef. + +scala> :quit
\ No newline at end of file diff --git a/test/files/run/repl-implicits.scala b/test/files/run/repl-implicits.scala new file mode 100644 index 0000000000..ca8e16e683 --- /dev/null +++ b/test/files/run/repl-implicits.scala @@ -0,0 +1,5 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = ":implicits" +} diff --git a/test/files/run/t3822.scala b/test/files/run/t3822.scala deleted file mode 100644 index c35804035e..0000000000 --- a/test/files/run/t3822.scala +++ /dev/null @@ -1,19 +0,0 @@ -import scala.collection.{ mutable, immutable, generic } -import immutable.ListSet - -object Test { - def main(args: Array[String]): Unit = { - val xs = ListSet(-100000 to 100001: _*) - - assert(xs.size == 200002) - assert(xs.sum == 100001) - - val ys = ListSet[Int]() - val ys1 = (1 to 12).grouped(3).foldLeft(ys)(_ ++ _) - val ys2 = (1 to 12).foldLeft(ys)(_ + _) - - assert(ys1 == ys2) - } -} - - diff --git a/test/files/run/t6198.scala b/test/files/run/t6198.scala index 5aa8f1c1cf..65dbaf8160 100644 --- a/test/files/run/t6198.scala +++ b/test/files/run/t6198.scala @@ -1,13 +1,6 @@ import scala.collection.immutable._ object Test extends App { - // test that ListSet.tail does not use a builder - // we can't test for O(1) behavior, so the best we can do is to - // check that ls.tail always returns the same instance - val ls = ListSet.empty[Int] + 1 + 2 - - if(ls.tail ne ls.tail) - println("ListSet.tail should not use a builder!") // class that always causes hash collisions case class Collision(value:Int) { override def hashCode = 0 } diff --git a/test/files/run/t6502.scala b/test/files/run/t6502.scala index dffb0e2f98..cb2b3ff449 100644 --- a/test/files/run/t6502.scala +++ b/test/files/run/t6502.scala @@ -1,6 +1,5 @@ import scala.tools.nsc.Settings import scala.tools.nsc.interpreter.{ ILoop, replProps } -import scala.tools.nsc.settings.ClassPathRepresentationType import scala.tools.partest._ object Test extends StoreReporterDirectTest { @@ -14,14 +13,6 @@ object Test extends StoreReporterDirectTest { compileString(newCompiler("-cp", classpath, "-d", s"${testOutput.path}/$jarFileName"))(code) } - var classPathKind: String = "" - - override def settings = { - val settings = new Settings - settings.YclasspathImpl.value = classPathKind - settings - } - def app1 = """ package test @@ -155,7 +146,7 @@ object Test extends StoreReporterDirectTest { assert(output.contains("created test6.Z"), output) } - def testAll(): Unit = { + def show(): Unit = { test1() test2() test3() @@ -163,11 +154,4 @@ object Test extends StoreReporterDirectTest { test5() test6() } - - def show(): Unit = { - classPathKind = ClassPathRepresentationType.Flat - testAll() - classPathKind = ClassPathRepresentationType.Recursive - testAll() - } } diff --git a/test/files/run/t7319.check b/test/files/run/t7319.check index 4d8429e8f2..31923e7119 100644 --- a/test/files/run/t7319.check +++ b/test/files/run/t7319.check @@ -15,21 +15,21 @@ warning: there was one feature warning; re-run with -feature for details convert: [F[X <: F[X]]](builder: F[_ <: F[_]])Int scala> convert(Some[Int](0)) -<console>:16: error: no type parameters for method convert: (builder: F[_ <: F[_]])Int exist so that it can be applied to arguments (Some[Int]) +<console>:15: error: no type parameters for method convert: (builder: F[_ <: F[_]])Int exist so that it can be applied to arguments (Some[Int]) --- because --- argument expression's type is not compatible with formal parameter type; found : Some[Int] required: ?F[_$1] forSome { type _$1 <: ?F[_$2] forSome { type _$2 } } convert(Some[Int](0)) ^ -<console>:16: error: type mismatch; +<console>:15: error: type mismatch; found : Some[Int] required: F[_ <: F[_]] convert(Some[Int](0)) ^ scala> Range(1,2).toArray: Seq[_] -<console>:15: error: polymorphic expression cannot be instantiated to expected type; +<console>:14: error: polymorphic expression cannot be instantiated to expected type; found : [B >: Int]Array[B] required: Seq[_] Range(1,2).toArray: Seq[_] diff --git a/test/files/run/t7445.scala b/test/files/run/t7445.scala deleted file mode 100644 index e4ffeb8e1a..0000000000 --- a/test/files/run/t7445.scala +++ /dev/null @@ -1,6 +0,0 @@ -import scala.collection.immutable.ListMap - -object Test extends App { - val a = ListMap(1 -> 1, 2 -> 2, 3 -> 3, 4 -> 4, 5 -> 5); - require(a.tail == ListMap(2 -> 2, 3 -> 3, 4 -> 4, 5 -> 5)); -} diff --git a/test/files/run/t8549.scala b/test/files/run/t8549.scala index e2d0d335b0..1ce8933efb 100644 --- a/test/files/run/t8549.scala +++ b/test/files/run/t8549.scala @@ -79,7 +79,7 @@ object Test extends App { } } - // Generated on 20160328-17:47:35 with Scala version 2.12.0-20160328-174205-d46145c) + // Generated on 20160515-00:17:51 with Scala version 2.12.0-SNAPSHOT) overwrite.foreach(updateComment) check(Some(1))("rO0ABXNyAApzY2FsYS5Tb21lESLyaV6hi3QCAAFMAAF4dAASTGphdmEvbGFuZy9PYmplY3Q7eHIADHNjYWxhLk9wdGlvbv5pN/3bDmZ0AgAAeHBzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAQ==") @@ -145,6 +145,8 @@ object Test extends App { check(immutable.HashSet(1, 2, 3))( "rO0ABXNyADVzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5IYXNoU2V0JFNlcmlhbGl6YXRpb25Qcm94eQAAAAAAAAACAwAAeHB3BAAAAANzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAXNxAH4AAgAAAAJzcQB+AAIAAAADeA==") // TODO provoke HashSetCollision1 + check(immutable.ListSet())( "rO0ABXNyADBzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5MaXN0U2V0JEVtcHR5TGlzdFNldCRFiHGwmKwhTAIAAHhyACJzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5MaXN0U2V0izCZaSia0jYCAAB4cA==") + check(immutable.ListSet(1))( "rO0ABXNyACdzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5MaXN0U2V0JE5vZGX1EX2lizBAdwIAAkwABiRvdXRlcnQAJExzY2FsYS9jb2xsZWN0aW9uL2ltbXV0YWJsZS9MaXN0U2V0O0wABGVsZW10ABJMamF2YS9sYW5nL09iamVjdDt4cgAic2NhbGEuY29sbGVjdGlvbi5pbW11dGFibGUuTGlzdFNldIswmWkomtI2AgAAeHBzcgAwc2NhbGEuY29sbGVjdGlvbi5pbW11dGFibGUuTGlzdFNldCRFbXB0eUxpc3RTZXQkRYhxsJisIUwCAAB4cQB+AANzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAQ==") check(immutable.ListMap())( "rO0ABXNyADBzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5MaXN0TWFwJEVtcHR5TGlzdE1hcCSNalsvpBZeDgIAAHhyACJzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5MaXN0TWFwBC1gfIkUSKsCAAB4cA==") check(immutable.ListMap(1 -> 2))( "rO0ABXNyACdzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5MaXN0TWFwJE5vZGWmciM1Yav+8gIAA0wABiRvdXRlcnQAJExzY2FsYS9jb2xsZWN0aW9uL2ltbXV0YWJsZS9MaXN0TWFwO0wAA2tleXQAEkxqYXZhL2xhbmcvT2JqZWN0O0wABXZhbHVlcQB+AAJ4cgAic2NhbGEuY29sbGVjdGlvbi5pbW11dGFibGUuTGlzdE1hcAQtYHyJFEirAgAAeHBzcgAwc2NhbGEuY29sbGVjdGlvbi5pbW11dGFibGUuTGlzdE1hcCRFbXB0eUxpc3RNYXAkjWpbL6QWXg4CAAB4cQB+AANzcgARamF2YS5sYW5nLkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIAAHhwAAAAAXNxAH4ABwAAAAI=") check(immutable.Queue())( "rO0ABXNyACBzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5RdWV1ZZY146W3qSuhAgACTAACaW50ACFMc2NhbGEvY29sbGVjdGlvbi9pbW11dGFibGUvTGlzdDtMAANvdXRxAH4AAXhwc3IAMnNjYWxhLmNvbGxlY3Rpb24uaW1tdXRhYmxlLkxpc3QkU2VyaWFsaXphdGlvblByb3h5AAAAAAAAAAEDAAB4cHNyACxzY2FsYS5jb2xsZWN0aW9uLmltbXV0YWJsZS5MaXN0U2VyaWFsaXplRW5kJIpcY1v3UwttAgAAeHB4cQB+AAQ=") diff --git a/test/files/run/t8756.check b/test/files/run/t8756.check new file mode 100644 index 0000000000..9b9dcafe7d --- /dev/null +++ b/test/files/run/t8756.check @@ -0,0 +1,9 @@ +public Bippy<java.lang.Object> Test.f1(long) +public Bippy<java.lang.Object> Test.f2(long) +public Bippy<java.lang.Object> Test.i1(Bippy<java.lang.Object>) +public Bippy<java.lang.Object> Test.i2(Bippy<java.lang.Object>) +public int Test.g1(long) +public int Test.g2(long) +public java.lang.Object Test.h1(long) +public java.lang.Object Test.h2(long) +public static void Test.main(java.lang.String[]) diff --git a/test/files/run/t8756.scala b/test/files/run/t8756.scala new file mode 100644 index 0000000000..edd243473a --- /dev/null +++ b/test/files/run/t8756.scala @@ -0,0 +1,22 @@ +trait Bippy[A] + +class Test { + type T1 = Long + type T2 = Long { type Tag = Nothing } + + def f1(t: T1): Bippy[Object] = ??? + def f2(t: T2): Bippy[Object] = ??? + def g1(t: T1): Int = ??? + def g2(t: T2): Int = ??? + def h1(t: T1): Object = ??? + def h2(t: T2): Object = ??? + def i1(t: Bippy[T1]): Bippy[T1] = ??? + def i2(t: Bippy[T2]): Bippy[T2] = ??? + +} + +object Test { + def main(args: Array[String]) { + println(classOf[Test].getDeclaredMethods.map(_.toGenericString).toList.sorted.mkString("\n")) + } +} diff --git a/test/files/run/various-flat-classpath-types.scala b/test/files/run/various-flat-classpath-types.scala index d39019e885..bc54ffb6cc 100644 --- a/test/files/run/various-flat-classpath-types.scala +++ b/test/files/run/various-flat-classpath-types.scala @@ -5,7 +5,7 @@ import java.io.{File => JFile, FileInputStream, FileOutputStream} import java.util.zip.{ZipEntry, ZipOutputStream} import scala.reflect.io.{Directory, File} -import scala.tools.nsc.classpath.FlatClassPath.RootPackage +import scala.tools.nsc.util.ClassPath.RootPackage import scala.tools.nsc.classpath.PackageNameUtils import scala.tools.nsc.io.Jar @@ -80,7 +80,6 @@ object Test { private val compiler = new scala.tools.nsc.MainClass private val appRunner = new scala.tools.nsc.MainGenericRunner - private val classPathImplFlag = "-YclasspathImpl:flat" private val javaClassPath = sys.props("java.class.path") // creates a test dir in a temporary dir containing compiled files of this test @@ -166,13 +165,13 @@ object Test { val classPath = mkPath(javaClassPath, binDir.path, zipsDir.path + "/Bin.zip", jarsDir.path + "/Bin.jar") val sourcePath = mkPath(srcDir.path, zipsDir.path + "/Src.zip", jarsDir.path + "/Src.jar") - compiler.process(Array(classPathImplFlag, "-cp", classPath, "-sourcepath", sourcePath, + compiler.process(Array("-cp", classPath, "-sourcepath", sourcePath, "-d", outDir.path, s"${srcDir.path}/Main.scala")) } private def runApp(): Unit = { val classPath = mkPath(javaClassPath, outDir.path, binDir.path, zipsDir.path + "/Bin.zip", jarsDir.path + "/Bin.jar") - appRunner.process(Array(classPathImplFlag, "-cp", classPath, "Main")) + appRunner.process(Array("-cp", classPath, "Main")) } private def createStandardSrcHierarchy(baseFileName: String): Unit = @@ -200,7 +199,7 @@ object Test { private def compileSrc(baseFileName: String, destination: JFile = outDir): Unit = { val srcDirPath = srcDir.path - compiler.process(Array(classPathImplFlag, "-cp", javaClassPath, "-d", destination.path, + compiler.process(Array("-cp", javaClassPath, "-d", destination.path, s"$srcDirPath/$baseFileName.scala", s"$srcDirPath/nested/Nested$baseFileName.scala")) } |