aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/disabled/not-representable/hkt/compiler.error (renamed from tests/pending/hkt/compiler.error)0
-rw-r--r--tests/disabled/not-representable/hkt/hkt.scala (renamed from tests/pending/hkt/hkt.scala)3
-rw-r--r--tests/disabled/not-representable/t2337.scala (renamed from tests/pending/run/t2337.scala)2
-rw-r--r--tests/neg/applydynamic_sip.check52
-rw-r--r--tests/neg/applydynamic_sip.flags (renamed from tests/untried/neg/applydynamic_sip.flags)0
-rw-r--r--tests/neg/applydynamic_sip.scala36
-rw-r--r--tests/neg/emptyCatch.scala3
-rw-r--r--tests/neg/i1503.scala14
-rw-r--r--tests/neg/t6355b.check (renamed from tests/untried/neg/t6355b.check)4
-rw-r--r--tests/neg/t6355b.scala (renamed from tests/untried/neg/t6355b.scala)4
-rw-r--r--tests/neg/t6663.check (renamed from tests/untried/neg/t6663.check)0
-rw-r--r--tests/neg/t6663.scala (renamed from tests/untried/neg/t6663.scala)2
-rw-r--r--tests/neg/t6920.check (renamed from tests/untried/neg/t6920.check)2
-rw-r--r--tests/neg/t6920.scala (renamed from tests/untried/neg/t6920.scala)2
-rw-r--r--tests/neg/t8006.check (renamed from tests/untried/neg/t8006.check)2
-rw-r--r--tests/neg/t8006.scala (renamed from tests/untried/neg/t8006.scala)2
-rw-r--r--tests/pending/import-rewrite/compiler.error6
-rw-r--r--tests/pending/run/t2337.check4
-rw-r--r--tests/pending/run/t3150.scala36
-rw-r--r--tests/pending/run/unapply.check3
-rw-r--r--tests/pos-scala2/naming-resolution/callsite.scala10
-rw-r--r--tests/pos-scala2/naming-resolution/package.scala5
-rw-r--r--tests/pos-scala2/t3050.scala (renamed from tests/pending/run/t3050.scala)0
-rw-r--r--tests/pos/import-rewrite/file.scala (renamed from tests/pending/import-rewrite/file.scala)0
-rw-r--r--tests/pos/import-rewrite/rewrite.scala (renamed from tests/pending/import-rewrite/rewrite.scala)0
-rw-r--r--tests/pos/t1500a.scala28
-rw-r--r--tests/pos/t1513a.scala36
-rw-r--r--tests/pos/t1513b.scala25
-rw-r--r--tests/pos/tryWithoutHandler.scala7
-rw-r--r--tests/run/applydynamic_sip.check (renamed from tests/pending/run/applydynamic_sip.check)0
-rw-r--r--tests/run/applydynamic_sip.flags (renamed from tests/pending/run/applydynamic_sip.flags)0
-rw-r--r--tests/run/applydynamic_sip.scala (renamed from tests/pending/run/applydynamic_sip.scala)1
-rw-r--r--tests/run/dynamic-anyval.check (renamed from tests/pending/run/dynamic-anyval.check)0
-rw-r--r--tests/run/dynamic-anyval.scala (renamed from tests/pending/run/dynamic-anyval.scala)0
-rw-r--r--tests/run/dynamicDynamicTests.scala41
-rw-r--r--tests/run/i1503.check5
-rw-r--r--tests/run/i1503.scala38
-rw-r--r--tests/run/t1335.scala11
-rw-r--r--tests/run/t1500b.scala21
-rw-r--r--tests/run/t1500c.scala19
-rw-r--r--tests/run/t298.check (renamed from tests/pending/run/t298.check)0
-rw-r--r--tests/run/t298.scala (renamed from tests/pending/run/t298.scala)0
-rw-r--r--tests/run/t3026.check (renamed from tests/pending/run/t3026.check)0
-rwxr-xr-xtests/run/t3026.scala (renamed from tests/pending/run/t3026.scala)0
-rw-r--r--tests/run/t3353.check (renamed from tests/pending/run/t3353.check)0
-rw-r--r--tests/run/t3353.scala (renamed from tests/pending/run/t3353.scala)0
-rw-r--r--tests/run/t4536.check (renamed from tests/pending/run/t4536.check)0
-rw-r--r--tests/run/t4536.flags (renamed from tests/pending/run/t4536.flags)0
-rw-r--r--tests/run/t4536.scala (renamed from tests/pending/run/t4536.scala)8
-rw-r--r--tests/run/t5040.check (renamed from tests/pending/run/t5040.check)0
-rw-r--r--tests/run/t5040.flags (renamed from tests/pending/run/t5040.flags)0
-rw-r--r--tests/run/t5040.scala (renamed from tests/pending/run/t5040.scala)1
-rw-r--r--tests/run/t5733.check (renamed from tests/pending/run/t5733.check)0
-rw-r--r--tests/run/t5733.scala (renamed from tests/pending/run/t5733.scala)0
-rw-r--r--tests/run/t6353.check (renamed from tests/pending/run/t6353.check)0
-rw-r--r--tests/run/t6353.scala (renamed from tests/pending/run/t6353.scala)0
-rw-r--r--tests/run/t6355.check (renamed from tests/pending/run/t6355.check)0
-rw-r--r--tests/run/t6355.scala (renamed from tests/pending/run/t6355.scala)0
-rw-r--r--tests/run/t6663.check (renamed from tests/pending/run/t6663.check)0
-rw-r--r--tests/run/t6663.flags (renamed from tests/pending/run/t6663.flags)0
-rw-r--r--tests/run/t6663.scala (renamed from tests/pending/run/t6663.scala)0
-rw-r--r--tests/run/unapply.scala (renamed from tests/pending/run/unapply.scala)4
-rw-r--r--tests/untried/neg/applydynamic_sip.check73
-rw-r--r--tests/untried/neg/applydynamic_sip.scala33
64 files changed, 396 insertions, 147 deletions
diff --git a/tests/pending/hkt/compiler.error b/tests/disabled/not-representable/hkt/compiler.error
index b31760891..b31760891 100644
--- a/tests/pending/hkt/compiler.error
+++ b/tests/disabled/not-representable/hkt/compiler.error
diff --git a/tests/pending/hkt/hkt.scala b/tests/disabled/not-representable/hkt/hkt.scala
index 34858cd95..1a9932d73 100644
--- a/tests/pending/hkt/hkt.scala
+++ b/tests/disabled/not-representable/hkt/hkt.scala
@@ -1,3 +1,6 @@
+// This one is unavoidable. Dotty does not allow several overloaded
+// parameterless methods, so it picks the one in the subclass.
+
import scala.language.higherKinds
// Minimal reproduction for:
// scala.collection.mutable.ArrayStack.empty[Int]
diff --git a/tests/pending/run/t2337.scala b/tests/disabled/not-representable/t2337.scala
index edb574cba..9e3b8c555 100644
--- a/tests/pending/run/t2337.scala
+++ b/tests/disabled/not-representable/t2337.scala
@@ -1,4 +1,4 @@
-
+// Failure of autotupling in the presence of overloaded functions.
object Test {
def compare(first: Any, second: Any): Any = {
diff --git a/tests/neg/applydynamic_sip.check b/tests/neg/applydynamic_sip.check
new file mode 100644
index 000000000..1bd8304bf
--- /dev/null
+++ b/tests/neg/applydynamic_sip.check
@@ -0,0 +1,52 @@
+tests/neg/applydynamic_sip.scala:8: error: value applyDynamic is not a member of Dynamic(Test.qual)
+possible cause: maybe a wrong Dynamic method signature?
+ qual.sel(a, a2: _*) // error
+ ^
+tests/neg/applydynamic_sip.scala:9: error: applyDynamicNamed does not support passing a vararg parameter
+ qual.sel(arg = a, a2: _*) // error
+ ^
+tests/neg/applydynamic_sip.scala:10: error: applyDynamicNamed does not support passing a vararg parameter
+ qual.sel(arg, arg2 = "a2", a2: _*) // error
+ ^
+tests/neg/applydynamic_sip.scala:20: error: type mismatch:
+ found : String("sel")
+ required: Int
+ bad1.sel // error
+ ^
+tests/neg/applydynamic_sip.scala:21: error: type mismatch:
+ found : String("sel")
+ required: Int
+ bad1.sel(1) // error // error
+ ^
+tests/neg/applydynamic_sip.scala:21: error: method applyDynamic in class Bad1 does not take more parameters
+ bad1.sel(1) // error // error
+ ^
+tests/neg/applydynamic_sip.scala:22: error: type mismatch:
+ found : String("sel")
+ required: Int
+ bad1.sel(a = 1) // error // error
+ ^
+tests/neg/applydynamic_sip.scala:22: error: method applyDynamicNamed in class Bad1 does not take more parameters
+ bad1.sel(a = 1) // error // error
+ ^
+tests/neg/applydynamic_sip.scala:23: error: type mismatch:
+ found : String("sel")
+ required: Int
+ bad1.sel = 1 // error // error
+ ^
+tests/neg/applydynamic_sip.scala:23: error: method updateDynamic in class Bad1 does not take more parameters
+ bad1.sel = 1 // error // error
+ ^
+tests/neg/applydynamic_sip.scala:32: error: method selectDynamic in class Bad2 does not take parameters
+ bad2.sel // error
+ ^
+tests/neg/applydynamic_sip.scala:33: error: method applyDynamic in class Bad2 does not take parameters
+ bad2.sel(1) // error
+ ^
+tests/neg/applydynamic_sip.scala:34: error: method applyDynamicNamed in class Bad2 does not take parameters
+ bad2.sel(a = 1) // error
+ ^
+tests/neg/applydynamic_sip.scala:35: error: method updateDynamic in class Bad2 does not take parameters
+ bad2.sel = 1 // error
+ ^
+14 errors found
diff --git a/tests/untried/neg/applydynamic_sip.flags b/tests/neg/applydynamic_sip.flags
index 1141f9750..1141f9750 100644
--- a/tests/untried/neg/applydynamic_sip.flags
+++ b/tests/neg/applydynamic_sip.flags
diff --git a/tests/neg/applydynamic_sip.scala b/tests/neg/applydynamic_sip.scala
new file mode 100644
index 000000000..7b131e7ff
--- /dev/null
+++ b/tests/neg/applydynamic_sip.scala
@@ -0,0 +1,36 @@
+import scala.language.dynamics
+object Test extends App {
+ val qual: Dynamic = ???
+ val expr = "expr"
+ val a = "a"
+ val a2 = "a2"
+
+ qual.sel(a, a2: _*) // error
+ qual.sel(arg = a, a2: _*) // error
+ qual.sel(arg, arg2 = "a2", a2: _*) // error
+
+ class Bad1 extends Dynamic {
+ def selectDynamic(n: Int) = n
+ def applyDynamic(n: Int) = n
+ def applyDynamicNamed(n: Int) = n
+ def updateDynamic(n: Int) = n
+
+ }
+ val bad1 = new Bad1
+ bad1.sel // error
+ bad1.sel(1) // error // error
+ bad1.sel(a = 1) // error // error
+ bad1.sel = 1 // error // error
+
+ class Bad2 extends Dynamic {
+ def selectDynamic = 1
+ def applyDynamic = 1
+ def applyDynamicNamed = 1
+ def updateDynamic = 1
+ }
+ val bad2 = new Bad2
+ bad2.sel // error
+ bad2.sel(1) // error
+ bad2.sel(a = 1) // error
+ bad2.sel = 1 // error
+}
diff --git a/tests/neg/emptyCatch.scala b/tests/neg/emptyCatch.scala
new file mode 100644
index 000000000..60951d27a
--- /dev/null
+++ b/tests/neg/emptyCatch.scala
@@ -0,0 +1,3 @@
+object Test {
+ try {} catch {} // error: `catch` block does not contain a valid expression, try adding a case like - `case e: Exception =>` to the block
+}
diff --git a/tests/neg/i1503.scala b/tests/neg/i1503.scala
new file mode 100644
index 000000000..8e5dc53c6
--- /dev/null
+++ b/tests/neg/i1503.scala
@@ -0,0 +1,14 @@
+object Test {
+
+ val cond = true
+ def foo1() = println("hi")
+ def bar1() = println("there")
+
+ def foo2(x: Int) = println("hi")
+ def bar2(x: Int) = println("there")
+
+ def main(args: Array[String]) = {
+ (if (cond) foo1 else bar1)() // error: Unit does not take parameters
+ (if (cond) foo2 else bar2)(22) // error: missing arguments // error: missing arguments
+ }
+}
diff --git a/tests/untried/neg/t6355b.check b/tests/neg/t6355b.check
index f827f07e5..fb73b9c42 100644
--- a/tests/untried/neg/t6355b.check
+++ b/tests/neg/t6355b.check
@@ -1,11 +1,11 @@
t6355b.scala:14: error: value applyDynamic is not a member of A
error after rewriting to x.<applyDynamic: error>("bippy")
possible cause: maybe a wrong Dynamic method signature?
- println(x.bippy(42))
+ println(x.bippy(42)) // error
^
t6355b.scala:15: error: value applyDynamic is not a member of A
error after rewriting to x.<applyDynamic: error>("bippy")
possible cause: maybe a wrong Dynamic method signature?
- println(x.bippy("42"))
+ println(x.bippy("42")) // error
^
two errors found
diff --git a/tests/untried/neg/t6355b.scala b/tests/neg/t6355b.scala
index 5f3c97cb0..bba3c4fdc 100644
--- a/tests/untried/neg/t6355b.scala
+++ b/tests/neg/t6355b.scala
@@ -11,7 +11,7 @@ class B(method: String) {
object Test {
def main(args: Array[String]): Unit = {
val x = new A
- println(x.bippy(42))
- println(x.bippy("42"))
+ println(x.bippy(42)) // error
+ println(x.bippy("42")) // error
}
}
diff --git a/tests/untried/neg/t6663.check b/tests/neg/t6663.check
index aa4faa4a4..aa4faa4a4 100644
--- a/tests/untried/neg/t6663.check
+++ b/tests/neg/t6663.check
diff --git a/tests/untried/neg/t6663.scala b/tests/neg/t6663.scala
index 4a358dfbc..aa4ab08ed 100644
--- a/tests/untried/neg/t6663.scala
+++ b/tests/neg/t6663.scala
@@ -13,7 +13,7 @@ object Test extends App {
// but, before fixing SI-6663, became
// C(42).selectDynamic("foo").get, ignoring
// the [String] type parameter
- var v = new C(42).foo[String].get :Int
+ var v = new C(42).foo[String].get :Int // error
println(v)
}
diff --git a/tests/untried/neg/t6920.check b/tests/neg/t6920.check
index ee4eafb83..8bfd16a5f 100644
--- a/tests/untried/neg/t6920.check
+++ b/tests/neg/t6920.check
@@ -1,6 +1,6 @@
t6920.scala:9: error: too many arguments for method applyDynamicNamed: (values: Seq[(String, Any)])String
error after rewriting to CompilerError.this.test.applyDynamicNamed("crushTheCompiler")(scala.Tuple2("a", 1), scala.Tuple2("b", 2))
possible cause: maybe a wrong Dynamic method signature?
- test.crushTheCompiler(a = 1, b = 2)
+ test.crushTheCompiler(a = 1, b = 2) // error
^
one error found
diff --git a/tests/untried/neg/t6920.scala b/tests/neg/t6920.scala
index 25dc7b3b6..9601ed8d2 100644
--- a/tests/untried/neg/t6920.scala
+++ b/tests/neg/t6920.scala
@@ -6,5 +6,5 @@ class DynTest extends Dynamic {
class CompilerError {
val test = new DynTest
- test.crushTheCompiler(a = 1, b = 2)
+ test.crushTheCompiler(a = 1, b = 2) // error
}
diff --git a/tests/untried/neg/t8006.check b/tests/neg/t8006.check
index fbac26e3a..98207ba30 100644
--- a/tests/untried/neg/t8006.check
+++ b/tests/neg/t8006.check
@@ -1,6 +1,6 @@
t8006.scala:3: error: too many arguments for method applyDynamicNamed: (value: (String, Any))String
error after rewriting to X.this.d.applyDynamicNamed("meth")(scala.Tuple2("value1", 10), scala.Tuple2("value2", 100))
possible cause: maybe a wrong Dynamic method signature?
- d.meth(value1 = 10, value2 = 100) // two arguments here, but only one is allowed
+ d.meth(value1 = 10, value2 = 100) // error: two arguments here, but only one is allowed
^
one error found
diff --git a/tests/untried/neg/t8006.scala b/tests/neg/t8006.scala
index 8dc60697d..34946a659 100644
--- a/tests/untried/neg/t8006.scala
+++ b/tests/neg/t8006.scala
@@ -1,6 +1,6 @@
object X {
val d = new D
- d.meth(value1 = 10, value2 = 100) // two arguments here, but only one is allowed
+ d.meth(value1 = 10, value2 = 100) // error: two arguments here, but only one is allowed
}
import language.dynamics
class D extends Dynamic {
diff --git a/tests/pending/import-rewrite/compiler.error b/tests/pending/import-rewrite/compiler.error
deleted file mode 100644
index 0832d33bb..000000000
--- a/tests/pending/import-rewrite/compiler.error
+++ /dev/null
@@ -1,6 +0,0 @@
-$ scalac tests/pending/import-rewrite/*.scala
-$ ./bin/dotc tests/pending/import-rewrite/*.scala
-tests/pending/import-rewrite/rewrite.scala:5: error: value apply is not a member of java.io.File.type
- Seq("").map(File.apply)
- ^
-one error found
diff --git a/tests/pending/run/t2337.check b/tests/pending/run/t2337.check
deleted file mode 100644
index 18f1f66fc..000000000
--- a/tests/pending/run/t2337.check
+++ /dev/null
@@ -1,4 +0,0 @@
-(Both Int,-1,-1)
-(Both Float,1,1)
-(Float then Int,0,0)
-(Int then Float,0,0)
diff --git a/tests/pending/run/t3150.scala b/tests/pending/run/t3150.scala
index 034703b5f..dc95af373 100644
--- a/tests/pending/run/t3150.scala
+++ b/tests/pending/run/t3150.scala
@@ -1,10 +1,26 @@
-object Test {
- case object Bob { override def equals(other: Any) = true }
- def f(x: Any) = x match { case Bob => Bob }
-
- def main(args: Array[String]): Unit = {
- assert(f(Bob) eq Bob)
- assert(f(0) eq Bob)
- assert(f(Nil) eq Bob)
- }
-}
+ object Test {
+ case object Bob { override def equals(other: Any) = true }
+
+ class Bob2 {
+ override def equals(other: Any) = true
+ }
+ val Bob2 = new Bob2
+
+ def f0(x: Any) = x match { case Bob2 => Bob2 } // class cast exception at runtime, dotc only
+ def f1(x: Any) = x match { case Bob => Bob } // class cast exception at runtime, dotc only
+ def f2(x: Any): Bob.type = x match { case x @ Bob => x } // class cast exception at runtime, dotc and javac.
+
+ def main(args: Array[String]): Unit = {
+ assert(f0(Bob2) eq Bob2)
+ assert(f0(0) eq Bob2) // only dotty fails here
+ assert(f0(Nil) eq Bob2)
+
+ assert(f1(Bob) eq Bob)
+ assert(f1(0) eq Bob) // only dotty fails here
+ assert(f1(Nil) eq Bob)
+
+ assert(f2(Bob) eq Bob)
+ assert(f2(0) eq Bob) // both dotty and scalac fail here
+ assert(f2(Nil) eq Bob)
+ }
+ }
diff --git a/tests/pending/run/unapply.check b/tests/pending/run/unapply.check
deleted file mode 100644
index 847e3b381..000000000
--- a/tests/pending/run/unapply.check
+++ /dev/null
@@ -1,3 +0,0 @@
-unapply.scala:57: warning: comparing values of types Null and Null using `==' will always yield true
- assert(doMatch2(b) == null)
- ^
diff --git a/tests/pos-scala2/naming-resolution/callsite.scala b/tests/pos-scala2/naming-resolution/callsite.scala
new file mode 100644
index 000000000..036803a26
--- /dev/null
+++ b/tests/pos-scala2/naming-resolution/callsite.scala
@@ -0,0 +1,10 @@
+// This one should be rejected according to spec. The import takes precedence
+// over the type in the same package because the typeis declared in a
+// different compilation unit. scalac does not conform to spec here.
+package naming.resolution
+
+import java.nio.file._ // Imports `Files`
+
+object Resolution {
+ def gimmeFiles: Files = Files.list(Paths.get("."))
+}
diff --git a/tests/pos-scala2/naming-resolution/package.scala b/tests/pos-scala2/naming-resolution/package.scala
new file mode 100644
index 000000000..f0e26ee95
--- /dev/null
+++ b/tests/pos-scala2/naming-resolution/package.scala
@@ -0,0 +1,5 @@
+package naming
+
+package object resolution {
+ type Files = java.util.stream.Stream[java.nio.file.Path]
+}
diff --git a/tests/pending/run/t3050.scala b/tests/pos-scala2/t3050.scala
index 160f8b664..160f8b664 100644
--- a/tests/pending/run/t3050.scala
+++ b/tests/pos-scala2/t3050.scala
diff --git a/tests/pending/import-rewrite/file.scala b/tests/pos/import-rewrite/file.scala
index e52581e81..e52581e81 100644
--- a/tests/pending/import-rewrite/file.scala
+++ b/tests/pos/import-rewrite/file.scala
diff --git a/tests/pending/import-rewrite/rewrite.scala b/tests/pos/import-rewrite/rewrite.scala
index 0bda02c5e..0bda02c5e 100644
--- a/tests/pending/import-rewrite/rewrite.scala
+++ b/tests/pos/import-rewrite/rewrite.scala
diff --git a/tests/pos/t1500a.scala b/tests/pos/t1500a.scala
new file mode 100644
index 000000000..adf46329a
--- /dev/null
+++ b/tests/pos/t1500a.scala
@@ -0,0 +1,28 @@
+trait Step0
+trait Step1
+trait Step2
+trait Step3
+trait Step4
+trait Step5
+trait Step6
+
+object Steps {
+ implicit val Step0: Step0 = new Step0 {}
+ implicit def Step1(implicit p: Step0): Step1 = new Step1 {}
+ implicit def Step2(implicit p: Step1): Step2 = new Step2 {}
+ implicit def Step3(implicit p: Step2): Step3 = new Step3 {}
+ implicit def Step4(implicit p: Step3): Step4 = new Step4 {}
+ implicit def Step5(implicit p: Step4): Step5 = new Step5 {}
+ implicit def Step6(implicit p: Step5): Step6 = new Step6 {}
+}
+
+object StepsTest {
+ import Steps._
+
+ implicitly[Step0]
+ implicitly[Step1]
+ implicitly[Step2]
+ implicitly[Step3]
+ implicitly[Step4]
+ implicitly[Step6]
+}
diff --git a/tests/pos/t1513a.scala b/tests/pos/t1513a.scala
new file mode 100644
index 000000000..3c4c02376
--- /dev/null
+++ b/tests/pos/t1513a.scala
@@ -0,0 +1,36 @@
+object Test {
+ // Heterogeneous lists and natural numbers as defined in shapeless.
+
+ sealed trait HList
+ sealed trait ::[H, T <: HList] extends HList
+ sealed trait HNil extends HList
+
+ sealed trait Nat
+ sealed trait Succ[P <: Nat] extends Nat
+ sealed trait Zero extends Nat
+
+ // Accessor type class to compute the N'th element of an HList L.
+
+ trait Accessor[L <: HList, N <: Nat] { type Out }
+ object Accessor {
+ type Aux[L <: HList, N <: Nat, O] = Accessor[L, N] { type Out = O }
+
+ // (H :: T).At[Zero] = H
+ implicit def caseZero[H, T <: HList]: Aux[H :: T, Zero, H] = ???
+
+ // T.At[N] = O => (H :: T).At[Succ[N]] = O
+ implicit def caseN[H, T <: HList, N <: Nat, O]
+ (implicit a: Aux[T, N, O]): Aux[H :: T, Succ[N], O] = ???
+ }
+
+ case class Proxy[T]()
+
+ def at1[NN <: Nat, OO] (implicit e: Accessor.Aux[String :: HNil, NN, OO]): OO = ???
+ def at2[NN <: Nat, OO](p: Proxy[NN])(implicit e: Accessor.Aux[String :: HNil, NN, OO]): OO = ???
+
+ // N is fixed by a value
+ at2(Proxy[Zero]): String
+
+ // N is fixed as a type parameter (by name)
+ at1[NN = Zero]: String
+}
diff --git a/tests/pos/t1513b.scala b/tests/pos/t1513b.scala
new file mode 100644
index 000000000..546649383
--- /dev/null
+++ b/tests/pos/t1513b.scala
@@ -0,0 +1,25 @@
+object Test {
+ def f[
+ T1 <: String,
+ T2 <: Int,
+ T3 <: Boolean
+ ](a1: T1, a2: T2, a3: T3) = ()
+
+ f ("", 1, true)
+ f[T1 = String] ("", 1, true)
+ f[T2 = Int] ("", 1, true)
+ f[T3 = Boolean] ("", 1, true)
+ f[T1 = String, T2 = Int] ("", 1, true)
+ f[T1 = String, T3 = Boolean] ("", 1, true)
+ f[T2 = Int, T1 = String] ("", 1, true)
+ f[T2 = Int, T3 = Boolean] ("", 1, true)
+ f[T3 = Boolean, T2 = Int] ("", 1, true)
+ f[T3 = Boolean, T1 = String] ("", 1, true)
+ f[T1 = String, T2 = Int, T3 = Boolean]("", 1, true)
+ f[T1 = String, T3 = Boolean, T2 = Int] ("", 1, true)
+ f[T2 = Int, T1 = String, T3 = Boolean]("", 1, true)
+ f[T2 = Int, T3 = Boolean, T1 = String] ("", 1, true)
+ f[T3 = Boolean, T1 = String, T2 = Int] ("", 1, true)
+ f[T3 = Boolean, T2 = Int, T1 = String] ("", 1, true)
+ f[String, Int, Boolean] ("", 1, true)
+}
diff --git a/tests/pos/tryWithoutHandler.scala b/tests/pos/tryWithoutHandler.scala
new file mode 100644
index 000000000..ffe334984
--- /dev/null
+++ b/tests/pos/tryWithoutHandler.scala
@@ -0,0 +1,7 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ try {
+ println("hello")
+ }
+ }
+}
diff --git a/tests/pending/run/applydynamic_sip.check b/tests/run/applydynamic_sip.check
index 6d04dc452..6d04dc452 100644
--- a/tests/pending/run/applydynamic_sip.check
+++ b/tests/run/applydynamic_sip.check
diff --git a/tests/pending/run/applydynamic_sip.flags b/tests/run/applydynamic_sip.flags
index ba6d37305..ba6d37305 100644
--- a/tests/pending/run/applydynamic_sip.flags
+++ b/tests/run/applydynamic_sip.flags
diff --git a/tests/pending/run/applydynamic_sip.scala b/tests/run/applydynamic_sip.scala
index a163ab960..7f81a644a 100644
--- a/tests/pending/run/applydynamic_sip.scala
+++ b/tests/run/applydynamic_sip.scala
@@ -1,3 +1,4 @@
+import scala.language.dynamics
object Test extends dotty.runtime.LegacyApp {
object stubUpdate {
def update(as: Any*) = println(".update"+as.toList.mkString("(",", ", ")"))
diff --git a/tests/pending/run/dynamic-anyval.check b/tests/run/dynamic-anyval.check
index dee7bef8e..dee7bef8e 100644
--- a/tests/pending/run/dynamic-anyval.check
+++ b/tests/run/dynamic-anyval.check
diff --git a/tests/pending/run/dynamic-anyval.scala b/tests/run/dynamic-anyval.scala
index 605503d37..605503d37 100644
--- a/tests/pending/run/dynamic-anyval.scala
+++ b/tests/run/dynamic-anyval.scala
diff --git a/tests/run/dynamicDynamicTests.scala b/tests/run/dynamicDynamicTests.scala
index 3f8da8298..05b878f1c 100644
--- a/tests/run/dynamicDynamicTests.scala
+++ b/tests/run/dynamicDynamicTests.scala
@@ -23,7 +23,16 @@ class Baz extends scala.Dynamic {
def updateDynamic(name: String)(value: String): String = "updateDynamic(" + name + ")(" + value + ")"
}
+class Qux extends scala.Dynamic {
+ def selectDynamic[T](name: String): String = "selectDynamic(" + name + ")"
+ def applyDynamic[T](name: String)(args: String*): String = "applyDynamic(" + name + ")" + args.mkString("(", ", ", ")")
+ def applyDynamicNamed[T](name: String)(args: (String, Any)*): String = "applyDynamicNamed(" + name + ")" + args.mkString("(", ", ", ")")
+ def updateDynamic[T](name: String)(value: T): String = "updateDynamic(" + name + ")(" + value + ")"
+}
+
object Test {
+ val qux = new Qux
+
implicit class StringUpdater(str: String) {
def update(name: String, v: String) = s"$str.update(" + name + ", " + v + ")"
}
@@ -42,6 +51,7 @@ object Test {
runFooTests2()
runBarTests()
runBazTests()
+ runQuxTests()
assert(!failed)
}
@@ -161,4 +171,35 @@ object Test {
assertEquals("selectDynamic(bazSelectUpdate).update(7, value)", baz.bazSelectUpdate(7) = "value")
assertEquals("selectDynamic(bazSelectUpdate).update(7, 10)", baz.bazSelectUpdate(7) = 10)
}
+
+ /** Test correct lifting of type parameters */
+ def runQuxTests() = {
+ implicit def intToString(n: Int): String = n.toString
+
+ val qux = new Qux
+
+ assertEquals("selectDynamic(quxSelect)", qux.quxSelect)
+ assertEquals("selectDynamic(quxSelect)", qux.quxSelect[Int])
+
+ assertEquals("applyDynamic(quxApply)()", qux.quxApply())
+ assertEquals("applyDynamic(quxApply)()", qux.quxApply[Int]())
+ assertEquals("applyDynamic(quxApply)(1)", qux.quxApply(1))
+ assertEquals("applyDynamic(quxApply)(1)", qux.quxApply[Int](1))
+ assertEquals("applyDynamic(quxApply)(1, 2, 3)", qux.quxApply(1, 2, 3))
+ assertEquals("applyDynamic(quxApply)(1, 2, 3)", qux.quxApply[Int](1, 2, 3))
+ assertEquals("applyDynamic(quxApply)(1, 2, a)", qux.quxApply(1, 2, "a"))
+ assertEquals("applyDynamic(quxApply)(1, 2, a)", qux.quxApply[Int](1, 2, "a"))
+
+ assertEquals("applyDynamicNamed(quxApplyNamed)((a,1))", qux.quxApplyNamed(a = 1))
+ assertEquals("applyDynamicNamed(quxApplyNamed)((a,1))", qux.quxApplyNamed[Int](a = 1))
+ assertEquals("applyDynamicNamed(quxApplyNamed)((a,1), (b,2))", qux.quxApplyNamed(a = 1, b = "2"))
+ assertEquals("applyDynamicNamed(quxApplyNamed)((a,1), (b,2))", qux.quxApplyNamed[Int](a = 1, b = "2"))
+ assertEquals("applyDynamicNamed(quxApplyNamed)((a,1), (,abc))", qux.quxApplyNamed(a = 1, "abc"))
+ assertEquals("applyDynamicNamed(quxApplyNamed)((a,1), (,abc))", qux.quxApplyNamed[Int](a = 1, "abc"))
+
+ assertEquals("updateDynamic(quxUpdate)(abc)", qux.quxUpdate = "abc")
+
+ assertEquals("selectDynamic(quxSelectUpdate).update(key, value)", qux.quxSelectUpdate("key") = "value")
+ assertEquals("selectDynamic(quxSelectUpdate).update(key, value)", qux.quxSelectUpdate[Int]("key") = "value")
+ }
}
diff --git a/tests/run/i1503.check b/tests/run/i1503.check
new file mode 100644
index 000000000..8cc0be027
--- /dev/null
+++ b/tests/run/i1503.check
@@ -0,0 +1,5 @@
+hello
+hi
+33
+hi
+hi
diff --git a/tests/run/i1503.scala b/tests/run/i1503.scala
new file mode 100644
index 000000000..56bb9af0c
--- /dev/null
+++ b/tests/run/i1503.scala
@@ -0,0 +1,38 @@
+object Test {
+
+ def test1() =
+ (new Function0[Unit] {
+ def apply() = println("hello")
+ })()
+
+ val cond = true
+ val foo = () => println("hi")
+ val bar = () => println("there")
+
+ val baz = (x: Int) => println(x)
+
+ def test2() =
+ (if (cond) foo else bar)()
+
+ def test2a() =
+ (if (cond) baz else baz)(33)
+
+ def test3() =
+ (try foo
+ catch { case ex: Exception => bar }
+ finally ())()
+
+ def test4() =
+ (cond match {
+ case true => foo
+ case false => bar
+ })()
+
+ def main(args: Array[String]) = {
+ test1()
+ test2()
+ test2a()
+ test3()
+ test4()
+ }
+}
diff --git a/tests/run/t1335.scala b/tests/run/t1335.scala
new file mode 100644
index 000000000..047f7b566
--- /dev/null
+++ b/tests/run/t1335.scala
@@ -0,0 +1,11 @@
+case class MyTuple(a: Int, b: Int)
+
+object Test {
+ def main(args: Array[String]): Unit =
+ try {
+ val mt: MyTuple = null
+ val MyTuple(a, b) = mt
+ } catch {
+ case e: MatchError => ()
+ }
+}
diff --git a/tests/run/t1500b.scala b/tests/run/t1500b.scala
new file mode 100644
index 000000000..8b52731a5
--- /dev/null
+++ b/tests/run/t1500b.scala
@@ -0,0 +1,21 @@
+sealed trait Nat
+sealed trait Succ[Prev <: Nat] extends Nat
+sealed trait Zero extends Nat
+
+case class ToInt[N <: Nat](value: Int)
+
+object ToInt {
+ implicit val caseZero: ToInt[Zero] = ToInt(0)
+ implicit def caseSucc[Prev <: Nat](implicit e: ToInt[Prev]): ToInt[Succ[Prev]] = ToInt(e.value + 1)
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ assert(implicitly[ToInt[Zero]].value == 0)
+ assert(implicitly[ToInt[Succ[Zero]]].value == 1)
+ assert(implicitly[ToInt[Succ[Succ[Zero]]]].value == 2)
+ assert(implicitly[ToInt[Succ[Succ[Succ[Zero]]]]].value == 3)
+ assert(implicitly[ToInt[Succ[Succ[Succ[Succ[Zero]]]]]].value == 4)
+ assert(implicitly[ToInt[Succ[Succ[Succ[Succ[Succ[Zero]]]]]]].value == 5)
+ }
+}
diff --git a/tests/run/t1500c.scala b/tests/run/t1500c.scala
new file mode 100644
index 000000000..5c33b7a2f
--- /dev/null
+++ b/tests/run/t1500c.scala
@@ -0,0 +1,19 @@
+sealed trait HList
+sealed trait HNil extends HList
+sealed trait ::[H, T <: HList] extends HList
+
+case class Size[L <: HList](value: Int)
+
+object Size {
+ implicit val caseHNil: Size[HNil] = Size(0)
+ implicit def caseHCons[H, T <: HList](implicit e: Size[T]): Size[H :: T] = Size(e.value + 1)
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ assert(implicitly[Size[HNil]].value == 0)
+ assert(implicitly[Size[Int :: HNil]].value == 1)
+ assert(implicitly[Size[Int :: Int :: HNil]].value == 2)
+ assert(implicitly[Size[Int :: Int :: Int :: HNil]].value == 3)
+ }
+}
diff --git a/tests/pending/run/t298.check b/tests/run/t298.check
index 1cd1d2266..1cd1d2266 100644
--- a/tests/pending/run/t298.check
+++ b/tests/run/t298.check
diff --git a/tests/pending/run/t298.scala b/tests/run/t298.scala
index 5728bb6c9..5728bb6c9 100644
--- a/tests/pending/run/t298.scala
+++ b/tests/run/t298.scala
diff --git a/tests/pending/run/t3026.check b/tests/run/t3026.check
index 8c29b615f..8c29b615f 100644
--- a/tests/pending/run/t3026.check
+++ b/tests/run/t3026.check
diff --git a/tests/pending/run/t3026.scala b/tests/run/t3026.scala
index 22dde9cc0..22dde9cc0 100755
--- a/tests/pending/run/t3026.scala
+++ b/tests/run/t3026.scala
diff --git a/tests/pending/run/t3353.check b/tests/run/t3353.check
index 8b4ae1fe6..8b4ae1fe6 100644
--- a/tests/pending/run/t3353.check
+++ b/tests/run/t3353.check
diff --git a/tests/pending/run/t3353.scala b/tests/run/t3353.scala
index 472723b3c..472723b3c 100644
--- a/tests/pending/run/t3353.scala
+++ b/tests/run/t3353.scala
diff --git a/tests/pending/run/t4536.check b/tests/run/t4536.check
index 0c5a72ada..0c5a72ada 100644
--- a/tests/pending/run/t4536.check
+++ b/tests/run/t4536.check
diff --git a/tests/pending/run/t4536.flags b/tests/run/t4536.flags
index 1141f9750..1141f9750 100644
--- a/tests/pending/run/t4536.flags
+++ b/tests/run/t4536.flags
diff --git a/tests/pending/run/t4536.scala b/tests/run/t4536.scala
index 6661eae6a..89a93a5e0 100644
--- a/tests/pending/run/t4536.scala
+++ b/tests/run/t4536.scala
@@ -1,8 +1,4 @@
-
-
-
-
-
+import scala.language.dynamics
object dynamicObject extends Dynamic {
def applyDynamic(m: String)() = println("obj: " + m);
@@ -38,7 +34,7 @@ object dynamicMixin extends dynamicAbstractClass with dynamicTrait {
object Test {
- def main(args: Array[String]) {
+ def main(args: Array[String]) = {
val cls = new dynamicClass
dynamicMixin
}
diff --git a/tests/pending/run/t5040.check b/tests/run/t5040.check
index 3f7b5908a..3f7b5908a 100644
--- a/tests/pending/run/t5040.check
+++ b/tests/run/t5040.check
diff --git a/tests/pending/run/t5040.flags b/tests/run/t5040.flags
index 1141f9750..1141f9750 100644
--- a/tests/pending/run/t5040.flags
+++ b/tests/run/t5040.flags
diff --git a/tests/pending/run/t5040.scala b/tests/run/t5040.scala
index 6813c1b27..58d054412 100644
--- a/tests/pending/run/t5040.scala
+++ b/tests/run/t5040.scala
@@ -1,3 +1,4 @@
+import scala.language.dynamics // originaly used the flag -language:dynamics in t5040.flags, .flags are currently ignored
abstract class Prova2 extends Dynamic {
def applyDynamic(m: String)(): Unit
private def privateMethod() = println("private method")
diff --git a/tests/pending/run/t5733.check b/tests/run/t5733.check
index e697046a9..e697046a9 100644
--- a/tests/pending/run/t5733.check
+++ b/tests/run/t5733.check
diff --git a/tests/pending/run/t5733.scala b/tests/run/t5733.scala
index a9e58d77e..a9e58d77e 100644
--- a/tests/pending/run/t5733.scala
+++ b/tests/run/t5733.scala
diff --git a/tests/pending/run/t6353.check b/tests/run/t6353.check
index 5676bed24..5676bed24 100644
--- a/tests/pending/run/t6353.check
+++ b/tests/run/t6353.check
diff --git a/tests/pending/run/t6353.scala b/tests/run/t6353.scala
index 7077eaeda..7077eaeda 100644
--- a/tests/pending/run/t6353.scala
+++ b/tests/run/t6353.scala
diff --git a/tests/pending/run/t6355.check b/tests/run/t6355.check
index ce74ab38a..ce74ab38a 100644
--- a/tests/pending/run/t6355.check
+++ b/tests/run/t6355.check
diff --git a/tests/pending/run/t6355.scala b/tests/run/t6355.scala
index f1921391a..f1921391a 100644
--- a/tests/pending/run/t6355.scala
+++ b/tests/run/t6355.scala
diff --git a/tests/pending/run/t6663.check b/tests/run/t6663.check
index d81cc0710..d81cc0710 100644
--- a/tests/pending/run/t6663.check
+++ b/tests/run/t6663.check
diff --git a/tests/pending/run/t6663.flags b/tests/run/t6663.flags
index ea7fc37e1..ea7fc37e1 100644
--- a/tests/pending/run/t6663.flags
+++ b/tests/run/t6663.flags
diff --git a/tests/pending/run/t6663.scala b/tests/run/t6663.scala
index bfe464ad6..bfe464ad6 100644
--- a/tests/pending/run/t6663.scala
+++ b/tests/run/t6663.scala
diff --git a/tests/pending/run/unapply.scala b/tests/run/unapply.scala
index 43f02b9f3..7b10030ba 100644
--- a/tests/pending/run/unapply.scala
+++ b/tests/run/unapply.scala
@@ -87,8 +87,8 @@ object Mas {
object LisSeqArr {
def run(): Unit = {
- assert((1,2) == ((List(1,2,3): Any) match { case List(x,y,_*) => (x,y)}))
- assert((1,2) == ((List(1,2,3): Any) match { case Seq(x,y,_*) => (x,y)}))
+ assert((1,2) == ((List(1,2,3): Any) match { case List(x,y,_: _*) => (x,y)}))
+ assert((1,2) == ((List(1,2,3): Any) match { case Seq(x,y,_: _*) => (x,y)}))
}
}
diff --git a/tests/untried/neg/applydynamic_sip.check b/tests/untried/neg/applydynamic_sip.check
deleted file mode 100644
index 2cb2e7f09..000000000
--- a/tests/untried/neg/applydynamic_sip.check
+++ /dev/null
@@ -1,73 +0,0 @@
-applydynamic_sip.scala:7: error: applyDynamic does not support passing a vararg parameter
- qual.sel(a, a2: _*)
- ^
-applydynamic_sip.scala:8: error: applyDynamicNamed does not support passing a vararg parameter
- qual.sel(arg = a, a2: _*)
- ^
-applydynamic_sip.scala:8: error: not found: value arg
- qual.sel(arg = a, a2: _*)
- ^
-applydynamic_sip.scala:9: error: applyDynamicNamed does not support passing a vararg parameter
- qual.sel(arg, arg2 = "a2", a2: _*)
- ^
-applydynamic_sip.scala:9: error: not found: value arg
- qual.sel(arg, arg2 = "a2", a2: _*)
- ^
-applydynamic_sip.scala:9: error: not found: value arg2
- qual.sel(arg, arg2 = "a2", a2: _*)
- ^
-applydynamic_sip.scala:18: error: type mismatch;
- found : String("sel")
- required: Int
-error after rewriting to Test.this.bad1.selectDynamic("sel")
-possible cause: maybe a wrong Dynamic method signature?
- bad1.sel
- ^
-applydynamic_sip.scala:19: error: type mismatch;
- found : String("sel")
- required: Int
-error after rewriting to Test.this.bad1.applyDynamic("sel")
-possible cause: maybe a wrong Dynamic method signature?
- bad1.sel(1)
- ^
-applydynamic_sip.scala:20: error: type mismatch;
- found : String("sel")
- required: Int
-error after rewriting to Test.this.bad1.applyDynamicNamed("sel")
-possible cause: maybe a wrong Dynamic method signature?
- bad1.sel(a = 1)
- ^
-applydynamic_sip.scala:20: error: reassignment to val
- bad1.sel(a = 1)
- ^
-applydynamic_sip.scala:21: error: type mismatch;
- found : String("sel")
- required: Int
-error after rewriting to Test.this.bad1.updateDynamic("sel")
-possible cause: maybe a wrong Dynamic method signature?
- bad1.sel = 1
- ^
-applydynamic_sip.scala:29: error: Int does not take parameters
-error after rewriting to Test.this.bad2.selectDynamic("sel")
-possible cause: maybe a wrong Dynamic method signature?
- bad2.sel
- ^
-applydynamic_sip.scala:30: error: Int does not take parameters
-error after rewriting to Test.this.bad2.applyDynamic("sel")
-possible cause: maybe a wrong Dynamic method signature?
- bad2.sel(1)
- ^
-applydynamic_sip.scala:31: error: Int does not take parameters
-error after rewriting to Test.this.bad2.applyDynamicNamed("sel")
-possible cause: maybe a wrong Dynamic method signature?
- bad2.sel(a = 1)
- ^
-applydynamic_sip.scala:31: error: reassignment to val
- bad2.sel(a = 1)
- ^
-applydynamic_sip.scala:32: error: Int does not take parameters
-error after rewriting to Test.this.bad2.updateDynamic("sel")
-possible cause: maybe a wrong Dynamic method signature?
- bad2.sel = 1
- ^
-16 errors found
diff --git a/tests/untried/neg/applydynamic_sip.scala b/tests/untried/neg/applydynamic_sip.scala
deleted file mode 100644
index ee4432ebe..000000000
--- a/tests/untried/neg/applydynamic_sip.scala
+++ /dev/null
@@ -1,33 +0,0 @@
-object Test extends App {
- val qual: Dynamic = ???
- val expr = "expr"
- val a = "a"
- val a2 = "a2"
-
- qual.sel(a, a2: _*)
- qual.sel(arg = a, a2: _*)
- qual.sel(arg, arg2 = "a2", a2: _*)
-
- val bad1 = new Dynamic {
- def selectDynamic(n: Int) = n
- def applyDynamic(n: Int) = n
- def applyDynamicNamed(n: Int) = n
- def updateDynamic(n: Int) = n
-
- }
- bad1.sel
- bad1.sel(1)
- bad1.sel(a = 1)
- bad1.sel = 1
-
- val bad2 = new Dynamic {
- def selectDynamic = 1
- def applyDynamic = 1
- def applyDynamicNamed = 1
- def updateDynamic = 1
- }
- bad2.sel
- bad2.sel(1)
- bad2.sel(a = 1)
- bad2.sel = 1
-}