summaryrefslogtreecommitdiff
path: root/test/files/pos
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/pos')
-rw-r--r--test/files/pos/MailBox.scala2
-rw-r--r--test/files/pos/SI-7060.flags1
-rw-r--r--test/files/pos/SI-7060.scala11
-rw-r--r--test/files/pos/alladin763.scala37
-rw-r--r--test/files/pos/arrays2.scala2
-rw-r--r--test/files/pos/constant-warning.check4
-rw-r--r--test/files/pos/constant-warning.flags1
-rw-r--r--test/files/pos/constant-warning.scala3
-rw-r--r--test/files/pos/fields_widen_trait_var.scala4
-rw-r--r--test/files/pos/fun_undo_eta.scala10
-rw-r--r--test/files/pos/functions.scala4
-rw-r--r--test/files/pos/hkgadt.scala27
-rw-r--r--test/files/pos/infer_override_def_args.flags1
-rw-r--r--test/files/pos/infer_override_def_args.scala5
-rw-r--r--test/files/pos/inline-access-levels.flags2
-rw-r--r--test/files/pos/inliner2.flags1
-rw-r--r--test/files/pos/inliner2.scala57
-rw-r--r--test/files/pos/issue244.scala2
-rw-r--r--test/files/pos/java-type-annotations/NotNull.java6
-rw-r--r--test/files/pos/java-type-annotations/Test.java4
-rw-r--r--test/files/pos/javaConversions-2.10-ambiguity.scala4
-rw-r--r--test/files/pos/javaConversions-2.10-regression.scala6
-rw-r--r--test/files/pos/list-optim-check.flags1
-rw-r--r--test/files/pos/list-optim-check.scala21
-rw-r--r--test/files/pos/lub-from-hell.scala6
-rw-r--r--test/files/pos/native-warning.scala4
-rw-r--r--test/files/pos/overloaded_ho_fun.scala66
-rw-r--r--test/files/pos/sam_erasure_boundedwild.scala11
-rw-r--r--test/files/pos/sammy_ctor_arg.scala4
-rw-r--r--test/files/pos/sammy_extends_function.scala4
-rw-r--r--test/files/pos/sammy_implicit.scala11
-rw-r--r--test/files/pos/sammy_infer_argtype_subtypes.scala6
-rw-r--r--test/files/pos/sammy_inferargs.scala6
-rw-r--r--test/files/pos/sammy_overload.flags1
-rw-r--r--test/files/pos/sammy_overload.scala27
-rw-r--r--test/files/pos/sammy_override.flags1
-rw-r--r--test/files/pos/sammy_poly.flags1
-rw-r--r--test/files/pos/sammy_poly.scala13
-rw-r--r--test/files/pos/sammy_scope.flags1
-rw-r--r--test/files/pos/sammy_scope.scala4
-rw-r--r--test/files/pos/sammy_single.flags1
-rw-r--r--test/files/pos/sammy_twice.flags1
-rw-r--r--test/files/pos/sd219.scala11
-rw-r--r--test/files/pos/sd248/Prop_1.scala2
-rw-r--r--test/files/pos/sd248/Test_2.scala5
-rw-r--r--test/files/pos/sd248/package_1.scala3
-rw-r--r--test/files/pos/sd268.scala17
-rw-r--r--test/files/pos/sealed-final.flags1
-rw-r--r--test/files/pos/sealed-final.scala14
-rw-r--r--test/files/pos/shapeless-regression.scala16
-rw-r--r--test/files/pos/t10009.scala6
-rw-r--r--test/files/pos/t10066.scala38
-rw-r--r--test/files/pos/t10093.flags1
-rw-r--r--test/files/pos/t10093.scala5
-rw-r--r--test/files/pos/t10154.scala11
-rw-r--r--test/files/pos/t10154b.scala16
-rw-r--r--test/files/pos/t2171.flags1
-rw-r--r--test/files/pos/t2171.scala7
-rw-r--r--test/files/pos/t2293.scala4
-rw-r--r--test/files/pos/t2377b/Q.java13
-rw-r--r--test/files/pos/t2377b/a.scala5
-rw-r--r--test/files/pos/t2956/t2956.scala4
-rw-r--r--test/files/pos/t3234.flags1
-rw-r--r--test/files/pos/t3234.scala17
-rw-r--r--test/files/pos/t3252.flags1
-rw-r--r--test/files/pos/t3252.scala15
-rw-r--r--test/files/pos/t3420.flags2
-rw-r--r--test/files/pos/t3430.flags1
-rw-r--r--test/files/pos/t3430.scala13
-rw-r--r--test/files/pos/t3688.scala4
-rw-r--r--test/files/pos/t3772.scala8
-rw-r--r--test/files/pos/t4237.scala15
-rw-r--r--test/files/pos/t4365/a_1.scala2
-rw-r--r--test/files/pos/t4365/b_1.scala2
-rw-r--r--test/files/pos/t4579.flags1
-rw-r--r--test/files/pos/t4579.scala518
-rw-r--r--test/files/pos/t482.scala7
-rw-r--r--test/files/pos/t4840.flags2
-rw-r--r--test/files/pos/t4914.scala20
-rw-r--r--test/files/pos/t5120.scala2
-rw-r--r--test/files/pos/t5165b.flags1
-rw-r--r--test/files/pos/t5183.scala34
-rw-r--r--test/files/pos/t5240.scala8
-rw-r--r--test/files/pos/t5294b.scala36
-rw-r--r--test/files/pos/t5294c.scala30
-rw-r--r--test/files/pos/t533.scala11
-rw-r--r--test/files/pos/t5644/BoxesRunTime.java4
-rw-r--r--test/files/pos/t5729.scala6
-rw-r--r--test/files/pos/t5899.scala1
-rw-r--r--test/files/pos/t6091.scala4
-rw-r--r--test/files/pos/t6157.flags1
-rw-r--r--test/files/pos/t6157.scala25
-rw-r--r--test/files/pos/t6161b.scala22
-rw-r--r--test/files/pos/t6547.flags1
-rw-r--r--test/files/pos/t6547.scala6
-rw-r--r--test/files/pos/t6734.scala17
-rw-r--r--test/files/pos/t6778.scala5
-rw-r--r--test/files/pos/t6978.flags1
-rw-r--r--test/files/pos/t6978/J.java5
-rw-r--r--test/files/pos/t6978/S.scala7
-rw-r--r--test/files/pos/t7014/ThreadSafety.java9
-rw-r--r--test/files/pos/t7014/ThreadSafetyLevel.java8
-rw-r--r--test/files/pos/t7014/t7014.scala3
-rw-r--r--test/files/pos/t7088.scala8
-rw-r--r--test/files/pos/t7239.scala38
-rw-r--r--test/files/pos/t7294.scala6
-rw-r--r--test/files/pos/t7551.flags1
-rw-r--r--test/files/pos/t7551/A.java9
-rw-r--r--test/files/pos/t7551/T.scala9
-rw-r--r--test/files/pos/t7551/Test.scala5
-rw-r--r--test/files/pos/t7784.scala13
-rw-r--r--test/files/pos/t8002-nested-scope.scala20
-rw-r--r--test/files/pos/t8013.flags2
-rw-r--r--test/files/pos/t8040.flags1
-rw-r--r--test/files/pos/t8040.scala13
-rw-r--r--test/files/pos/t8044.scala15
-rw-r--r--test/files/pos/t8062.flags1
-rw-r--r--test/files/pos/t8062/A_1.scala5
-rw-r--r--test/files/pos/t8062/B_2.scala3
-rw-r--r--test/files/pos/t8079b.scala7
-rw-r--r--test/files/pos/t8306.flags1
-rw-r--r--test/files/pos/t8306.scala8
-rw-r--r--test/files/pos/t8310.flags1
-rw-r--r--test/files/pos/t8315.flags1
-rw-r--r--test/files/pos/t8315.scala12
-rw-r--r--test/files/pos/t8315b.flags1
-rw-r--r--test/files/pos/t8315b.scala11
-rw-r--r--test/files/pos/t8359-closelim-crash.flags1
-rw-r--r--test/files/pos/t8359-closelim-crash.scala23
-rw-r--r--test/files/pos/t8410.flags2
-rw-r--r--test/files/pos/t8429.scala7
-rw-r--r--test/files/pos/t8462.scala11
-rw-r--r--test/files/pos/t8862a.scala47
-rw-r--r--test/files/pos/t8862b.scala12
-rw-r--r--test/files/pos/t8873.scala1
-rw-r--r--test/files/pos/t8947/Macro_1.scala2
-rw-r--r--test/files/pos/t9020.scala6
-rw-r--r--test/files/pos/t9074.scala24
-rw-r--r--test/files/pos/t9074b.scala15
-rw-r--r--test/files/pos/t9111-inliner-workaround.flags2
-rw-r--r--test/files/pos/t9123.flags1
-rw-r--r--test/files/pos/t9123.scala10
-rw-r--r--test/files/pos/t9131.scala12
-rw-r--r--test/files/pos/t9178b.flags (renamed from test/files/pos/sammy_exist.flags)0
-rw-r--r--test/files/pos/t9178b.scala7
-rw-r--r--test/files/pos/t9326a.scala6
-rw-r--r--test/files/pos/t9397.scala12
-rw-r--r--test/files/pos/t9449.scala19
-rw-r--r--test/files/pos/t9479.scala15
-rw-r--r--test/files/pos/t9479b.scala15
-rw-r--r--test/files/pos/t9498.scala25
-rw-r--r--test/files/pos/t9542.scala8
-rw-r--r--test/files/pos/t9658.scala10
-rw-r--r--test/files/pos/t9665.scala7
-rw-r--r--test/files/pos/t9855.scala10
-rw-r--r--test/files/pos/t9855b.scala16
-rw-r--r--test/files/pos/t9918/package.scala1
-rw-r--r--test/files/pos/t9918/t9918.scala3
-rw-r--r--test/files/pos/t9920.scala6
-rw-r--r--test/files/pos/t9943.scala9
-rw-r--r--test/files/pos/tcpoly_bounds1.scala6
-rw-r--r--test/files/pos/trailing-commas.scala155
-rw-r--r--test/files/pos/trait-defaults-super.scala21
-rw-r--r--test/files/pos/trait-force-info.flags1
-rw-r--r--test/files/pos/trait-force-info.scala18
-rw-r--r--test/files/pos/trait_fields_dependent_conflict.scala20
-rw-r--r--test/files/pos/trait_fields_dependent_rebind.scala15
-rw-r--r--test/files/pos/trait_fields_inherit_double_def.scala20
-rw-r--r--test/files/pos/trait_fields_lambdalift.scala22
-rw-r--r--test/files/pos/trait_fields_nested_private_object.scala8
-rw-r--r--test/files/pos/trait_fields_nested_public_object.scala5
-rw-r--r--test/files/pos/trait_fields_owners.scala19
-rw-r--r--test/files/pos/trait_fields_private_this.scala5
-rw-r--r--test/files/pos/trait_fields_static_fwd.scala10
-rw-r--r--test/files/pos/trait_fields_var_override_deferred.scala2
-rw-r--r--test/files/pos/trait_fields_volatile.scala13
-rw-r--r--test/files/pos/trait_lazy_accessboundary.scala2
-rw-r--r--test/files/pos/typevar-in-prefix.scala9
-rw-r--r--test/files/pos/val_infer.scala5
-rw-r--r--test/files/pos/virtpatmat_exist1.scala3
180 files changed, 1378 insertions, 957 deletions
diff --git a/test/files/pos/MailBox.scala b/test/files/pos/MailBox.scala
index 8e27bd362d..6bb25adb19 100644
--- a/test/files/pos/MailBox.scala
+++ b/test/files/pos/MailBox.scala
@@ -1,6 +1,6 @@
package test;
-import scala.actors.TIMEOUT;
+object TIMEOUT
class MailBox {
diff --git a/test/files/pos/SI-7060.flags b/test/files/pos/SI-7060.flags
deleted file mode 100644
index c926ad6493..0000000000
--- a/test/files/pos/SI-7060.flags
+++ /dev/null
@@ -1 +0,0 @@
--Yinline -Ydead-code
diff --git a/test/files/pos/SI-7060.scala b/test/files/pos/SI-7060.scala
deleted file mode 100644
index c87620e020..0000000000
--- a/test/files/pos/SI-7060.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-object Test {
-
- @inline final def mbarray_apply_minibox(array: Any, tag: Byte): Long =
- if (tag == 0) {
- array.asInstanceOf[Array[Long]](0)
- } else
- array.asInstanceOf[Array[Byte]](0).toLong
-
- def crash_method(): Unit =
- mbarray_apply_minibox(null, 0)
-}
diff --git a/test/files/pos/alladin763.scala b/test/files/pos/alladin763.scala
new file mode 100644
index 0000000000..29c9b25318
--- /dev/null
+++ b/test/files/pos/alladin763.scala
@@ -0,0 +1,37 @@
+// Test from http://lrytz.github.io/scala-aladdin-bugtracker/displayItem.do%3Fid=763.html
+// and expanded with package object variants
+
+
+trait Foo { type T; def apply() : T }
+object e extends Foo { type T = Int; def apply() = 42 }
+
+package p {
+ trait T[X] { def O : { def apply(): X } }
+ object `package` extends T[Int] {
+ def O: { def apply(): Int } = new { def apply(): Int = 42 }
+ }
+
+ object Test {
+ val x: Int = O()
+ }
+}
+
+object Test {
+
+ val f = new Foo { type T = Int; def apply() = 42 }
+
+ def main(args: Array[String]): Unit = {
+ val g = new Foo { type T = Int; def apply() = 42 }
+
+ (e: Foo)()
+ val ee: Int = e()
+
+ (f: Foo)()
+ val ff: Int = f()
+
+ (g: Foo)()
+ val gg: Int = g()
+
+ val pp: Int = p.O()
+ }
+}
diff --git a/test/files/pos/arrays2.scala b/test/files/pos/arrays2.scala
index 795c486e37..b770d21b8a 100644
--- a/test/files/pos/arrays2.scala
+++ b/test/files/pos/arrays2.scala
@@ -17,7 +17,7 @@ object arrays4 {
// #2461
object arrays3 {
- import scala.collection.JavaConversions._
+ import collection.convert.ImplicitConversions._
def apply[X](xs : X*) : java.util.List[X] = java.util.Arrays.asList(xs: _*)
}
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/fields_widen_trait_var.scala b/test/files/pos/fields_widen_trait_var.scala
new file mode 100644
index 0000000000..0ea9d9629a
--- /dev/null
+++ b/test/files/pos/fields_widen_trait_var.scala
@@ -0,0 +1,4 @@
+// check that the `var x` below is assigned the type `Int`, and not `Constant(0)`,
+// and that we can assign to it (if it gets a constant type, the `x` in `x = 42`
+// is constant-folded to `0` and we can't find a setter..
+trait C { protected final var x = 0; x = 42 }
diff --git a/test/files/pos/fun_undo_eta.scala b/test/files/pos/fun_undo_eta.scala
new file mode 100644
index 0000000000..466b0e2629
--- /dev/null
+++ b/test/files/pos/fun_undo_eta.scala
@@ -0,0 +1,10 @@
+class Test {
+ def m(i: Int) = i
+
+ def expectWild[A](f: A) = ???
+ def expectFun[A](f: A => Int) = ???
+
+ expectWild((i => m(i))) // manual eta expansion
+ expectWild(m(_)) // have to undo eta expansion with wildcard expected type
+ expectFun(m(_)) // have to undo eta expansion with function expected type
+}
diff --git a/test/files/pos/functions.scala b/test/files/pos/functions.scala
index 0207523dde..25d1c46eac 100644
--- a/test/files/pos/functions.scala
+++ b/test/files/pos/functions.scala
@@ -1,4 +1,6 @@
-import scala.actors.Actor
+object Actor {
+ def receive[A](f: PartialFunction[Any, A]): A = ???
+}
object Test {
diff --git a/test/files/pos/hkgadt.scala b/test/files/pos/hkgadt.scala
index efd7d3df21..5719c752cd 100644
--- a/test/files/pos/hkgadt.scala
+++ b/test/files/pos/hkgadt.scala
@@ -1,18 +1,35 @@
-package test
-
object HKGADT {
sealed trait Foo[F[_]]
final case class Bar() extends Foo[List]
def frob[F[_]](foo: Foo[F]): F[Int] =
foo match {
- case Bar() =>
- List(1)
+ case Bar() => List(1)
+ }
+
+ sealed trait Foo1[F]
+ final case class Bar1() extends Foo1[Int]
+ def frob1[A](foo: Foo1[A]): A = foo match {
+ case Bar1() => 1
+ }
+}
+
+object HKGADT2 {
+ sealed trait Foo[F[_]]
+ final case class Bar() extends Foo[List]
+ final case class Baz() extends Foo[Set]
+
+ def frob[F[_]](foo: Foo[F]): F[Int] =
+ foo match {
+ case Bar() => List(1)
+ case Baz() => Set(1)
}
sealed trait Foo1[F]
final case class Bar1() extends Foo1[Int]
- def frob1[A](foo: Foo1[A]) = foo match {
+ final case class Baz1() extends Foo1[Boolean]
+ def frob1[A](foo: Foo1[A]): A = foo match {
case Bar1() => 1
+ case Baz1() => true
}
}
diff --git a/test/files/pos/infer_override_def_args.flags b/test/files/pos/infer_override_def_args.flags
new file mode 100644
index 0000000000..d1a8244169
--- /dev/null
+++ b/test/files/pos/infer_override_def_args.flags
@@ -0,0 +1 @@
+-Yinfer-argument-types \ No newline at end of file
diff --git a/test/files/pos/infer_override_def_args.scala b/test/files/pos/infer_override_def_args.scala
new file mode 100644
index 0000000000..ac10720c81
--- /dev/null
+++ b/test/files/pos/infer_override_def_args.scala
@@ -0,0 +1,5 @@
+abstract class A { def foo(a: Int): A }
+class B extends A {
+ implicit def spackle(x: Int): A = new B
+ def foo(a) = a
+} \ No newline at end of file
diff --git a/test/files/pos/inline-access-levels.flags b/test/files/pos/inline-access-levels.flags
index 882f40f050..faa7d2b186 100644
--- a/test/files/pos/inline-access-levels.flags
+++ b/test/files/pos/inline-access-levels.flags
@@ -1 +1 @@
--optimise -Xfatal-warnings -Yinline-warnings
+-opt:l:classpath -Xfatal-warnings -opt-warnings
diff --git a/test/files/pos/inliner2.flags b/test/files/pos/inliner2.flags
deleted file mode 100644
index ea03113c66..0000000000
--- a/test/files/pos/inliner2.flags
+++ /dev/null
@@ -1 +0,0 @@
--optimise -Xfatal-warnings \ No newline at end of file
diff --git a/test/files/pos/inliner2.scala b/test/files/pos/inliner2.scala
deleted file mode 100644
index bc83e04312..0000000000
--- a/test/files/pos/inliner2.scala
+++ /dev/null
@@ -1,57 +0,0 @@
-// This isn't actually testing much, because no warning is emitted in versions
-// before the fix which comes with this because the method isn't even considered
-// for inlining due to the bug.
-class A {
- private var debug = false
- @inline private def ifelse[T](cond: => Boolean, ifPart: => T, elsePart: => T): T =
- if (cond) ifPart else elsePart
-
- final def bob1() = ifelse(debug, 1, 2)
- final def bob2() = if (debug) 1 else 2
-}
-// Cool:
-//
-// % ls -1 /tmp/2901/
-// A$$anonfun$bob1$1.class
-// A$$anonfun$bob1$2.class
-// A$$anonfun$bob1$3.class
-// A.class
-// % ls -1 /tmp/trunk
-// A.class
-//
-// Observations:
-//
-// (1) The inlined version accesses the field: the explicit one calls the accessor.
-// (2) The inlined version fails to eliminate boxing. With reference types it emits
-// an unneeded checkcast.
-// (3) The private var debug is mangled to A$$debug, but after inlining it is never accessed
-// from outside of the class and doesn't need mangling.
-// (4) We could forego emitting bytecode for ifelse entirely if it has been
-// inlined at all sites.
-//
-// Generated bytecode for the above:
-//
-// public final int bob1();
-// Code:
-// Stack=1, Locals=1, Args_size=1
-// 0: aload_0
-// 1: getfield #11; //Field A$$debug:Z
-// 4: ifeq 14
-// 7: iconst_1
-// 8: invokestatic #41; //Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer;
-// 11: goto 18
-// 14: iconst_2
-// 15: invokestatic #41; //Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer;
-// 18: invokestatic #45; //Method scala/runtime/BoxesRunTime.unboxToInt:(Ljava/lang/Object;)I
-// 21: ireturn
-//
-// public final int bob2();
-// Code:
-// Stack=1, Locals=1, Args_size=1
-// 0: aload_0
-// 1: invokevirtual #48; //Method A$$debug:()Z
-// 4: ifeq 11
-// 7: iconst_1
-// 8: goto 12
-// 11: iconst_2
-// 12: ireturn
diff --git a/test/files/pos/issue244.scala b/test/files/pos/issue244.scala
new file mode 100644
index 0000000000..f9189c9313
--- /dev/null
+++ b/test/files/pos/issue244.scala
@@ -0,0 +1,2 @@
+trait T { lazy val overloaded: String = "a" }
+class C extends T { def overloaded(a: String): String = "b" }
diff --git a/test/files/pos/java-type-annotations/NotNull.java b/test/files/pos/java-type-annotations/NotNull.java
new file mode 100644
index 0000000000..2716fe1a99
--- /dev/null
+++ b/test/files/pos/java-type-annotations/NotNull.java
@@ -0,0 +1,6 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+public @interface NotNull {
+}
diff --git a/test/files/pos/java-type-annotations/Test.java b/test/files/pos/java-type-annotations/Test.java
new file mode 100644
index 0000000000..d6bda1dedb
--- /dev/null
+++ b/test/files/pos/java-type-annotations/Test.java
@@ -0,0 +1,4 @@
+public class Test {
+ static class C<@NotNull T> {};
+ @NotNull String foo() { return ""; }
+}
diff --git a/test/files/pos/javaConversions-2.10-ambiguity.scala b/test/files/pos/javaConversions-2.10-ambiguity.scala
index c4aad6cbfc..b08568f475 100644
--- a/test/files/pos/javaConversions-2.10-ambiguity.scala
+++ b/test/files/pos/javaConversions-2.10-ambiguity.scala
@@ -1,5 +1,5 @@
-import collection.{JavaConversions, mutable, concurrent}
-import JavaConversions._
+import collection.{mutable, concurrent}
+import collection.convert.ImplicitConversionsToScala._
import java.util.concurrent.{ConcurrentHashMap => CHM}
object Bar {
diff --git a/test/files/pos/javaConversions-2.10-regression.scala b/test/files/pos/javaConversions-2.10-regression.scala
index 7c7ff03b55..8d84c92b61 100644
--- a/test/files/pos/javaConversions-2.10-regression.scala
+++ b/test/files/pos/javaConversions-2.10-regression.scala
@@ -1,10 +1,10 @@
-import collection.{JavaConversions, mutable, concurrent}
-import JavaConversions._
+import collection.{convert, mutable, concurrent, JavaConverters}
+import convert.ImplicitConversionsToScala._
import java.util.concurrent.{ConcurrentHashMap => CHM}
object Foo {
def buildCache2_9_simple[K <: AnyRef, V <: AnyRef]: concurrent.Map[K, V] =
- mapAsScalaConcurrentMap(new CHM())
+ JavaConverters.mapAsScalaConcurrentMap(new CHM())
def buildCache2_9_implicit[K <: AnyRef, V <: AnyRef]: concurrent.Map[K, V] =
new CHM[K, V]()
diff --git a/test/files/pos/list-optim-check.flags b/test/files/pos/list-optim-check.flags
deleted file mode 100644
index 49d036a887..0000000000
--- a/test/files/pos/list-optim-check.flags
+++ /dev/null
@@ -1 +0,0 @@
--optimize
diff --git a/test/files/pos/list-optim-check.scala b/test/files/pos/list-optim-check.scala
deleted file mode 100644
index f6e6ddec77..0000000000
--- a/test/files/pos/list-optim-check.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-// Tests a map known to crash in optimizer with faster List map in SI-8240.
-// Equivalent tests for collect and flatmap do not crash, but are provided
-// anyway.
-// See ticket SI-8334 for optimizer bug.
-// TODO - Remove this test once SI-8334 is fixed and has its own test.
-class A {
- def f: Boolean = {
- val xs = Nil map (_ => return false)
- true
- }
-
- def g: Boolean = {
- val xs = Nil collect { case _ => return false }
- true
- }
-
- def h: Boolean = {
- val xs = Nil flatMap { _ => return false }
- true
- }
-}
diff --git a/test/files/pos/lub-from-hell.scala b/test/files/pos/lub-from-hell.scala
new file mode 100644
index 0000000000..cb4b1733c7
--- /dev/null
+++ b/test/files/pos/lub-from-hell.scala
@@ -0,0 +1,6 @@
+class Test {
+ trait Tree
+ def foo(b: Boolean, buf: collection.mutable.ArrayBuffer[Any], acc: StringBuilder) = if (b) buf else acc
+}
+// This test case minimizes a case that failed to compile due to a bug in my work on
+// SI-5294. After refining my patches, it compiles again, as expected. \ No newline at end of file
diff --git a/test/files/pos/native-warning.scala b/test/files/pos/native-warning.scala
index f721a57e8f..a2918c11b5 100644
--- a/test/files/pos/native-warning.scala
+++ b/test/files/pos/native-warning.scala
@@ -1,3 +1,7 @@
class A {
@native def setup(): Unit
+
+ // also kosher
+ @native private def f(): Unit
+ @native final def g(): Unit
}
diff --git a/test/files/pos/overloaded_ho_fun.scala b/test/files/pos/overloaded_ho_fun.scala
new file mode 100644
index 0000000000..17176715f0
--- /dev/null
+++ b/test/files/pos/overloaded_ho_fun.scala
@@ -0,0 +1,66 @@
+import scala.math.Ordering
+import scala.reflect.ClassTag
+
+trait Sam { def apply(x: Int): String }
+trait SamP[U] { def apply(x: Int): U }
+
+class OverloadedFun[T](x: T) {
+ def foo(f: T => String): String = f(x)
+ def foo(f: Any => T): T = f("a")
+
+ def poly[U](f: Int => String): String = f(1)
+ def poly[U](f: Int => U): U = f(1)
+
+ def polySam[U](f: Sam): String = f(1)
+ def polySam[U](f: SamP[U]): U = f(1)
+
+ // check that we properly instantiate java.util.function.Function's type param to String
+ def polyJavaSam(f: String => String) = 1
+ def polyJavaSam(f: java.util.function.Function[String, String]) = 2
+}
+
+class StringLike(xs: String) {
+ def map[A](f: Char => A): Array[A] = ???
+ def map(f: Char => Char): String = ???
+}
+
+object Test {
+ val of = new OverloadedFun[Int](1)
+
+ of.foo(_.toString)
+
+ of.poly(x => x / 2 )
+ of.polySam(x => x / 2 )
+ of.polyJavaSam(x => x)
+
+ val sl = new StringLike("a")
+ sl.map(_ == 'a') // : Array[Boolean]
+ sl.map(x => 'a') // : String
+}
+
+object sorting {
+ def stableSort[K: ClassTag](a: Seq[K], f: (K, K) => Boolean): Array[K] = ???
+ def stableSort[L: ClassTag](a: Array[L], f: (L, L) => Boolean): Unit = ???
+
+ stableSort(??? : Seq[Boolean], (x: Boolean, y: Boolean) => x && !y)
+}
+
+// trait Bijection[A, B] extends (A => B) {
+// def andThen[C](g: Bijection[B, C]): Bijection[A, C] = ???
+// def compose[T](g: Bijection[T, A]) = g andThen this
+// }
+
+object SI10194 {
+ trait X[A] {
+ def map[B](f: A => B): Unit
+ }
+
+ trait Y[A] extends X[A] {
+ def map[B](f: A => B)(implicit ordering: Ordering[B]): Unit
+ }
+
+ trait Z[A] extends Y[A]
+
+ (null: Y[Int]).map(x => x.toString) // compiled
+ (null: Z[Int]).map(x => x.toString) // didn't compile
+}
diff --git a/test/files/pos/sam_erasure_boundedwild.scala b/test/files/pos/sam_erasure_boundedwild.scala
new file mode 100644
index 0000000000..1ec27e0ea4
--- /dev/null
+++ b/test/files/pos/sam_erasure_boundedwild.scala
@@ -0,0 +1,11 @@
+class Test {
+ trait Q[T] {
+ def toArray[T](x: Array[T]): Array[T]
+ def toArray(): Array[T]
+ }
+
+ def crashTyper: Array[_] = {
+ val x : Q[_] = ???
+ x.toArray // crashes while doing overload resolution
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/sammy_ctor_arg.scala b/test/files/pos/sammy_ctor_arg.scala
new file mode 100644
index 0000000000..3c556d59f0
--- /dev/null
+++ b/test/files/pos/sammy_ctor_arg.scala
@@ -0,0 +1,4 @@
+trait Fun[A, B] { def apply(a: A): B }
+// can't do sam expansion until the sam body def is a static method in the sam class, and not a local method in a block'
+class C(f: Fun[Int, String])
+class Test extends C(s => "a") \ No newline at end of file
diff --git a/test/files/pos/sammy_extends_function.scala b/test/files/pos/sammy_extends_function.scala
new file mode 100644
index 0000000000..e8cf5d8749
--- /dev/null
+++ b/test/files/pos/sammy_extends_function.scala
@@ -0,0 +1,4 @@
+// https://github.com/scala/scala-dev/issues/206
+
+trait T extends Function1[String, String]
+object O { (x => x): T }
diff --git a/test/files/pos/sammy_implicit.scala b/test/files/pos/sammy_implicit.scala
new file mode 100644
index 0000000000..ab63fc729e
--- /dev/null
+++ b/test/files/pos/sammy_implicit.scala
@@ -0,0 +1,11 @@
+trait Fun[A, B] { def apply(a: A): B }
+
+abstract class SamImplicitConvert {
+ class Lst[T]
+ abstract class Str { def getBytes: Array[Int] }
+ def flatMap[B](f: Fun[Str, Lst[B]]): List[B] = ???
+
+ implicit def conv(xs: Array[Int]): Lst[Int]
+
+ def encoded = flatMap (_.getBytes)
+}
diff --git a/test/files/pos/sammy_infer_argtype_subtypes.scala b/test/files/pos/sammy_infer_argtype_subtypes.scala
new file mode 100644
index 0000000000..63966f879e
--- /dev/null
+++ b/test/files/pos/sammy_infer_argtype_subtypes.scala
@@ -0,0 +1,6 @@
+trait Fun[A, B] { def apply(a: A): B }
+
+class SamInferResult {
+ def foreach[U](f: Fun[String, U]): U = ???
+ def foo = foreach(println)
+} \ No newline at end of file
diff --git a/test/files/pos/sammy_inferargs.scala b/test/files/pos/sammy_inferargs.scala
new file mode 100644
index 0000000000..10d9b4f0dd
--- /dev/null
+++ b/test/files/pos/sammy_inferargs.scala
@@ -0,0 +1,6 @@
+trait Proc { def apply(): Unit }
+class Test {
+ val initCode = List[Proc]()
+ initCode foreach { proc => proc() }
+
+}
diff --git a/test/files/pos/sammy_overload.flags b/test/files/pos/sammy_overload.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/sammy_overload.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/sammy_overload.scala b/test/files/pos/sammy_overload.scala
index 5472248f4d..6a3c88ec55 100644
--- a/test/files/pos/sammy_overload.scala
+++ b/test/files/pos/sammy_overload.scala
@@ -6,4 +6,29 @@ object Test {
def foo(x: String): Unit = ???
def foo(): Unit = ???
val f: Consumer[_ >: String] = foo
-} \ No newline at end of file
+}
+
+trait A[A, B] { def apply(a: A): B }
+
+class ArityDisambiguate {
+ object O {
+ def m(a: A[Int, Int]) = 0
+ def m(f: (Int, Int) => Int) = 1
+ }
+
+ O.m(x => x) // ok
+ O.m((x, y) => x) // ok
+}
+
+class InteractionWithImplicits {
+ object O {
+ class Ev
+ implicit object E1 extends Ev
+ implicit object E2 extends Ev
+ def m(a: A[Int, Int])(implicit ol: E1.type) = 0
+ def m(a: A[String, Int])(implicit ol: E2.type) = 1
+ }
+
+ O.m((x: Int) => 1) // ok
+ O.m((x: String) => 1) // ok
+}
diff --git a/test/files/pos/sammy_override.flags b/test/files/pos/sammy_override.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/sammy_override.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/sammy_poly.flags b/test/files/pos/sammy_poly.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/sammy_poly.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/sammy_poly.scala b/test/files/pos/sammy_poly.scala
index c629be7166..ba10baea49 100644
--- a/test/files/pos/sammy_poly.scala
+++ b/test/files/pos/sammy_poly.scala
@@ -1,7 +1,12 @@
// test synthesizeSAMFunction where the sam type is not fully defined
-class T {
- trait F[T, U] { def apply(x: T): U }
- // NOTE: the f(x) desugaring for now assumes the single abstract method is called 'apply'
+trait F[T, R]{ def apply(x: T): R }
+
+class PolySammy {
+ (x => x + 1): F[Int, Int]
+ ((x: Int) => x + 1): F[Int, Int]
+ ((x: String) => 1): F[String, Int]
+ ((x: Object) => 1): F[String, Int]
+
def app[T, U](x: T)(f: F[T, U]): U = f(x)
app(1)(x => List(x))
-} \ No newline at end of file
+}
diff --git a/test/files/pos/sammy_scope.flags b/test/files/pos/sammy_scope.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/sammy_scope.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/sammy_scope.scala b/test/files/pos/sammy_scope.scala
index 8f1fe7058e..9d35501a47 100644
--- a/test/files/pos/sammy_scope.scala
+++ b/test/files/pos/sammy_scope.scala
@@ -1,8 +1,8 @@
// test synthesizeSAMFunction: scope hygiene
-abstract class SamFun[T1, R] { self =>
+trait SamFun[T1, R] { self =>
def apply(v1: T1): R
// this should type check, as the apply ref is equivalent to self.apply
// it shouldn't resolve to the sam's apply that's synthesized (that wouldn't type check, hence the pos test)
def compose[A](g: SamFun[A, T1]): SamFun[A, R] = { x => apply(g(x)) }
-} \ No newline at end of file
+}
diff --git a/test/files/pos/sammy_single.flags b/test/files/pos/sammy_single.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/sammy_single.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/sammy_twice.flags b/test/files/pos/sammy_twice.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/sammy_twice.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/sd219.scala b/test/files/pos/sd219.scala
new file mode 100644
index 0000000000..3c3f4962f0
--- /dev/null
+++ b/test/files/pos/sd219.scala
@@ -0,0 +1,11 @@
+class Global { class Name }
+
+trait CommonPrintUtils {
+ val global: Global
+
+ lazy val precedence: global.Name => Int = ???
+}
+
+trait CompilerProvider { val global: Global = ??? }
+
+class AbstractPrinter extends CommonPrintUtils with CompilerProvider \ No newline at end of file
diff --git a/test/files/pos/sd248/Prop_1.scala b/test/files/pos/sd248/Prop_1.scala
new file mode 100644
index 0000000000..d5decda547
--- /dev/null
+++ b/test/files/pos/sd248/Prop_1.scala
@@ -0,0 +1,2 @@
+package p
+object Prop { class Whitelist }
diff --git a/test/files/pos/sd248/Test_2.scala b/test/files/pos/sd248/Test_2.scala
new file mode 100644
index 0000000000..602e6d37b5
--- /dev/null
+++ b/test/files/pos/sd248/Test_2.scala
@@ -0,0 +1,5 @@
+package p
+
+object PropTest {
+ def t = new Prop.Whitelist
+}
diff --git a/test/files/pos/sd248/package_1.scala b/test/files/pos/sd248/package_1.scala
new file mode 100644
index 0000000000..a90354e66f
--- /dev/null
+++ b/test/files/pos/sd248/package_1.scala
@@ -0,0 +1,3 @@
+package object p {
+ type Prop = String
+}
diff --git a/test/files/pos/sd268.scala b/test/files/pos/sd268.scala
new file mode 100644
index 0000000000..8839651501
--- /dev/null
+++ b/test/files/pos/sd268.scala
@@ -0,0 +1,17 @@
+class Context(val v : AnyRef)
+
+trait AbidePlugin {
+ val someVal = ""
+
+ val x = null.asInstanceOf[Context { val v : someVal.type }] // CRASH
+ lazy val y = null.asInstanceOf[Context { val v : someVal.type }] // CRASH
+ var z = null.asInstanceOf[Context { val v : someVal.type }] // CRASH
+}
+
+class C {
+ val someVal = ""
+
+ val x = null.asInstanceOf[Context { val v : someVal.type }]
+ lazy val y = null.asInstanceOf[Context { val v : someVal.type }] // CRASH
+ var z = null.asInstanceOf[Context { val v : someVal.type }]
+}
diff --git a/test/files/pos/sealed-final.flags b/test/files/pos/sealed-final.flags
deleted file mode 100644
index cfabf7a5b4..0000000000
--- a/test/files/pos/sealed-final.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xfatal-warnings -Yinline-warnings -optimise \ No newline at end of file
diff --git a/test/files/pos/sealed-final.scala b/test/files/pos/sealed-final.scala
deleted file mode 100644
index bdedb5c1f6..0000000000
--- a/test/files/pos/sealed-final.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-sealed abstract class Foo {
- @inline def bar(x: Int) = x + 1
-}
-object Foo {
- def mkFoo(): Foo = new Baz2
-}
-
-object Baz1 extends Foo
-final class Baz2 extends Foo
-
-object Test {
- // bar should be inlined now
- def f = Foo.mkFoo() bar 10
-}
diff --git a/test/files/pos/shapeless-regression.scala b/test/files/pos/shapeless-regression.scala
new file mode 100644
index 0000000000..f3a1ed1ba0
--- /dev/null
+++ b/test/files/pos/shapeless-regression.scala
@@ -0,0 +1,16 @@
+class W[T <: AnyRef](val t: T) {
+ val v: T {} = t
+}
+
+object W {
+ def apply[T <: AnyRef](t: T) = new W[t.type](t)
+}
+
+object RightAssoc {
+ def ra_:[T](t: T): Unit = ()
+}
+
+object Boom {
+ W("fooo").v ra_: RightAssoc
+}
+
diff --git a/test/files/pos/t10009.scala b/test/files/pos/t10009.scala
new file mode 100644
index 0000000000..7cd96f0f3d
--- /dev/null
+++ b/test/files/pos/t10009.scala
@@ -0,0 +1,6 @@
+class C {
+ def c(a: Any, b: Any*) = a
+}
+object Test {
+ new C().c(b = new { val x = 42 }, a = 0)
+}
diff --git a/test/files/pos/t10066.scala b/test/files/pos/t10066.scala
new file mode 100644
index 0000000000..bef85cb08c
--- /dev/null
+++ b/test/files/pos/t10066.scala
@@ -0,0 +1,38 @@
+package dynamicrash
+
+import scala.language.dynamics
+
+class Config
+
+trait Extractor[A] {
+ def extract(config: Config, name: String): A
+}
+
+object Extractor {
+ // this has "implicit", unlike the corresponding neg test
+ implicit val stringExtractor = new Extractor[String] {
+ override def extract(config: Config, name: String): String = ???
+ }
+}
+
+class Workspace extends Dynamic {
+ val config: Config = new Config
+
+ def selectDynamic[A](name: String)(implicit extractor: Extractor[A]): A =
+ extractor.extract(config, name)
+}
+
+object Main {
+ val storage = new Workspace
+
+ // this line works fine
+ // val a = storage.foo
+
+ // this line crashes the compiler ("head of empty list")
+ // in ContextErrors$InferencerContextErrors$InferErrorGen$.NotWithinBoundsErrorMessage
+ println(storage.foo[String])
+
+ // this line crashes the compiler in different way ("unknown type")
+ // in the backend, warning: an unexpected type representation reached the compiler backend while compiling Test.scala: <error>
+ println(storage.foo)
+}
diff --git a/test/files/pos/t10093.flags b/test/files/pos/t10093.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/pos/t10093.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/pos/t10093.scala b/test/files/pos/t10093.scala
new file mode 100644
index 0000000000..a894a54926
--- /dev/null
+++ b/test/files/pos/t10093.scala
@@ -0,0 +1,5 @@
+class A[@specialized(Int) T](val value: T) {
+ trait B
+ def useValue(x:T): Unit = ()
+ useValue(value)
+}
diff --git a/test/files/pos/t10154.scala b/test/files/pos/t10154.scala
new file mode 100644
index 0000000000..51616b71d6
--- /dev/null
+++ b/test/files/pos/t10154.scala
@@ -0,0 +1,11 @@
+trait Bar2[T]
+
+object Test2 {
+ def wrap {
+ object Foo {
+ implicit def fooBar: Bar2[Foo.type] = ???
+ }
+
+ implicitly[Bar2[Foo.type]]
+ }
+}
diff --git a/test/files/pos/t10154b.scala b/test/files/pos/t10154b.scala
new file mode 100644
index 0000000000..809a286c0e
--- /dev/null
+++ b/test/files/pos/t10154b.scala
@@ -0,0 +1,16 @@
+ import scala.language.existentials
+
+ class Bar[T]
+ class Test {
+ def method = {
+ object Foo {
+ implicit def x: Bar[Foo.type] = new Bar[Foo.type]
+ }
+ type T = Foo.type
+
+ {
+ object Foo
+ implicitly[Bar[T]]
+ }
+ }
+}
diff --git a/test/files/pos/t2171.flags b/test/files/pos/t2171.flags
deleted file mode 100644
index eb4d19bcb9..0000000000
--- a/test/files/pos/t2171.flags
+++ /dev/null
@@ -1 +0,0 @@
--optimise \ No newline at end of file
diff --git a/test/files/pos/t2171.scala b/test/files/pos/t2171.scala
deleted file mode 100644
index 6c754c76a6..0000000000
--- a/test/files/pos/t2171.scala
+++ /dev/null
@@ -1,7 +0,0 @@
-final object test {
- def logIgnoredException(msg: => String) =
- try 0 catch { case ex => println(msg) }
-
- def main (args: Array[String]): Unit =
- while (true) logIgnoredException ("...")
-}
diff --git a/test/files/pos/t2293.scala b/test/files/pos/t2293.scala
index 65f717f851..baa44552c9 100644
--- a/test/files/pos/t2293.scala
+++ b/test/files/pos/t2293.scala
@@ -1,5 +1,5 @@
-import scala.collection.JavaConversions._
+import scala.collection.convert.ImplicitConversionsToJava._
object Test {
val m: java.util.Map[String,String] = collection.mutable.Map("1"->"2")
-} \ No newline at end of file
+}
diff --git a/test/files/pos/t2377b/Q.java b/test/files/pos/t2377b/Q.java
new file mode 100644
index 0000000000..fbf9c776e9
--- /dev/null
+++ b/test/files/pos/t2377b/Q.java
@@ -0,0 +1,13 @@
+public class Q {
+
+ public static class Builder {}
+
+ public static class Inner {
+ public static class Builder { public void innerMethod() {} }
+ public Builder foo() { return new Builder(); } // this line gives an error, that Builder is ambiguous
+
+ public Inner.Builder viaSelect() { return new Builder(); } // this line gives an error, that Builder is ambiguous
+ }
+
+}
+
diff --git a/test/files/pos/t2377b/a.scala b/test/files/pos/t2377b/a.scala
new file mode 100644
index 0000000000..3053841589
--- /dev/null
+++ b/test/files/pos/t2377b/a.scala
@@ -0,0 +1,5 @@
+object Test {
+ (new Q.Inner).foo.innerMethod
+ (new Q.Inner).viaSelect.innerMethod
+
+}
diff --git a/test/files/pos/t2956/t2956.scala b/test/files/pos/t2956/t2956.scala
index eb6e817465..9b6ae8098f 100644
--- a/test/files/pos/t2956/t2956.scala
+++ b/test/files/pos/t2956/t2956.scala
@@ -1,7 +1,7 @@
-import scala.collection.JavaConversions._
+import scala.collection.convert.ImplicitConversionsToScala._
class Outer {
protected class Inner extends BeanDefinitionVisitor {
protected def visitMap(mapVal: Map[_, _]): Unit = ()
}
-} \ No newline at end of file
+}
diff --git a/test/files/pos/t3234.flags b/test/files/pos/t3234.flags
new file mode 100644
index 0000000000..b88ec8709d
--- /dev/null
+++ b/test/files/pos/t3234.flags
@@ -0,0 +1 @@
+-opt:l:project -opt-warnings -Xfatal-warnings
diff --git a/test/files/pos/t3234.scala b/test/files/pos/t3234.scala
new file mode 100644
index 0000000000..8c588e5aa9
--- /dev/null
+++ b/test/files/pos/t3234.scala
@@ -0,0 +1,17 @@
+trait Trait1 {
+ @inline final def foo2(n: Int) = n*n
+}
+
+trait Trait2 {
+ @inline final def foo3(n: Int) = 1
+}
+
+class Base extends Trait1 {
+ @inline final def foo(n: Int) = n
+}
+
+object Test extends Base with Trait2 {
+ def main(args: Array[String]) = {
+ println(foo(42) + foo2(11) + foo3(2))
+ }
+}
diff --git a/test/files/pos/t3252.flags b/test/files/pos/t3252.flags
deleted file mode 100644
index eb4d19bcb9..0000000000
--- a/test/files/pos/t3252.flags
+++ /dev/null
@@ -1 +0,0 @@
--optimise \ No newline at end of file
diff --git a/test/files/pos/t3252.scala b/test/files/pos/t3252.scala
deleted file mode 100644
index 3ecc1e7cef..0000000000
--- a/test/files/pos/t3252.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-class A {
- def f(x : Boolean) : Thread = {
- g {
- x match {
- case false =>
- B.h { }
- }
- }
- }
-
- private def g[T](block : => T) = sys.error("")
-}
-object B {
- def h(block : => Unit) : Nothing = sys.error("")
-}
diff --git a/test/files/pos/t3420.flags b/test/files/pos/t3420.flags
index d37e817882..5eea92d94a 100644
--- a/test/files/pos/t3420.flags
+++ b/test/files/pos/t3420.flags
@@ -1 +1 @@
--optimise -Xfatal-warnings
+-opt-warnings -opt:l:classpath -Xfatal-warnings \ No newline at end of file
diff --git a/test/files/pos/t3430.flags b/test/files/pos/t3430.flags
deleted file mode 100644
index eb4d19bcb9..0000000000
--- a/test/files/pos/t3430.flags
+++ /dev/null
@@ -1 +0,0 @@
--optimise \ No newline at end of file
diff --git a/test/files/pos/t3430.scala b/test/files/pos/t3430.scala
deleted file mode 100644
index 3129c6276a..0000000000
--- a/test/files/pos/t3430.scala
+++ /dev/null
@@ -1,13 +0,0 @@
-// package com.example
-
-object A {
- def f1(f: String => Boolean) = f("a")
-
- def f2(): Boolean =
- f1 { s1 =>
- f1 { s2 =>
- while (true) { }
- true
- }
- }
-} \ No newline at end of file
diff --git a/test/files/pos/t3688.scala b/test/files/pos/t3688.scala
index d15e9d1a84..58464332d1 100644
--- a/test/files/pos/t3688.scala
+++ b/test/files/pos/t3688.scala
@@ -1,5 +1,5 @@
import collection.mutable
-import collection.JavaConversions._
+import collection.convert.ImplicitConversionsToJava._
import java.{util => ju}
object Test {
@@ -11,4 +11,4 @@ object Test {
object Test2 {
def m[P <% ju.List[Int]](l: P) = 1
m(List(1)) // bug: should compile
-} \ No newline at end of file
+}
diff --git a/test/files/pos/t3772.scala b/test/files/pos/t3772.scala
new file mode 100644
index 0000000000..62c433ebd1
--- /dev/null
+++ b/test/files/pos/t3772.scala
@@ -0,0 +1,8 @@
+class Test {
+ def m = {
+ case class C(c: Int)
+ object C { def xxx = true}
+ C(42).c
+ C.xxx
+ }
+}
diff --git a/test/files/pos/t4237.scala b/test/files/pos/t4237.scala
index fcf6eb8bf1..3f605607b2 100644
--- a/test/files/pos/t4237.scala
+++ b/test/files/pos/t4237.scala
@@ -2,5 +2,16 @@ class A {
(new { def field = 0; def field_=(i: Int) = () }).field = 5 // compiles as expected
(new { def field(implicit i: Int) = 0; def field_=(i: Int) = () }).field = 5 // compiles even with implicit params on getter
(new { def field = 0; def field_=[T](i: Int) = () }).field = 5 // compiles with type param on setter
- (new { def field[T] = 0; def field_=(i: Int) = () }).field = 5 // DOESN'T COMPILE
-} \ No newline at end of file
+ (new { def field[T] = 0; def field_=(i: Int) = () }).field = 5 // DIDN'T COMPILE
+
+ class Imp
+ implicit val imp: Imp = new Imp
+ implicit val implicitList: List[Int] = null
+
+ // compiles even with implicit params on setter
+ (new { def field(implicit i: Int) = 0; def field_=(i: Int)(implicit j: Imp) = () }).field = 5
+ (new { def field(implicit i: Int) = 0; def field_=[T <: Imp](i: Int)(implicit j: T) = () }).field = 5
+ // was reassignment to val
+ (new { def field[T](implicit ts: List[T]) = 0; def field_=[T](i: Int)(implicit ts: List[T]) = () }).field = 5
+ (new { def field[T](implicit ts: List[T]) = 0; def field_=[T](i: T)(implicit ts: List[T]) = () }).field = 5
+}
diff --git a/test/files/pos/t4365/a_1.scala b/test/files/pos/t4365/a_1.scala
index a24b57772d..e7466e0d48 100644
--- a/test/files/pos/t4365/a_1.scala
+++ b/test/files/pos/t4365/a_1.scala
@@ -9,7 +9,7 @@ trait SeqViewLike[+A,
trait Transformed[+B] extends super[GenSeqViewLike].Transformed[B]
abstract class AbstractTransformed[+B] extends Seq[B] with Transformed[B] {
- def underlying: Coll = error("")
+ def underlying: Coll = sys.error("")
}
trait Reversed extends Transformed[A] with super[GenSeqViewLike].Reversed
diff --git a/test/files/pos/t4365/b_1.scala b/test/files/pos/t4365/b_1.scala
index e1423813f1..1158db6c32 100644
--- a/test/files/pos/t4365/b_1.scala
+++ b/test/files/pos/t4365/b_1.scala
@@ -10,7 +10,7 @@ self =>
trait Transformed[+B] {
def length: Int = 0
- def apply(idx: Int): B = error("")
+ def apply(idx: Int): B = sys.error("")
}
trait Reversed extends Transformed[A] {
diff --git a/test/files/pos/t4579.flags b/test/files/pos/t4579.flags
deleted file mode 100644
index 1182725e86..0000000000
--- a/test/files/pos/t4579.flags
+++ /dev/null
@@ -1 +0,0 @@
--optimize \ No newline at end of file
diff --git a/test/files/pos/t4579.scala b/test/files/pos/t4579.scala
deleted file mode 100644
index cd1553f02a..0000000000
--- a/test/files/pos/t4579.scala
+++ /dev/null
@@ -1,518 +0,0 @@
-//############################################################################
-// Lisp interpreter (revived as an optimizer test.)
-//############################################################################
-
-//############################################################################
-// Lisp Scanner
-
-class LispTokenizer(s: String) extends Iterator[String] {
- private var i = 0;
- private def isDelimiter(ch: Char) = ch <= ' ' || ch == '(' || ch == ')'
- def hasNext: Boolean = {
- while (i < s.length() && s.charAt(i) <= ' ') i += 1
- i < s.length()
- }
- def next: String =
- if (hasNext) {
- val start = i
- if (isDelimiter(s charAt i)) i += 1
- else
- do i = i + 1
- while (!isDelimiter(s charAt i))
- s.substring(start, i)
- } else sys.error("premature end of string")
-}
-
-//############################################################################
-// Lisp Interface
-
-trait Lisp {
- type Data
-
- def string2lisp(s: String): Data
- def lisp2string(s: Data): String
-
- def evaluate(d: Data): Data
- // !!! def evaluate(s: String): Data = evaluate(string2lisp(s))
- def evaluate(s: String): Data
-}
-
-//############################################################################
-// Lisp Implementation Using Case Classes
-
-object LispCaseClasses extends Lisp {
-
- import List.range
-
- trait Data {
- def elemsToString(): String = toString();
- }
- case class CONS(car: Data, cdr: Data) extends Data {
- override def toString() = "(" + elemsToString() + ")";
- override def elemsToString() = car.toString() + (cdr match {
- case NIL() => ""
- case _ => " " + cdr.elemsToString();
- })
- }
- case class NIL() extends Data { // !!! use case object
- override def toString() = "()";
- }
- case class SYM(name: String) extends Data {
- override def toString() = name;
- }
- case class NUM(x: Int) extends Data {
- override def toString() = x.toString();
- }
- case class STR(x: String) extends Data {
- override def toString() = "\"" + x + "\"";
- }
- case class FUN(f: List[Data] => Data) extends Data {
- override def toString() = "<fn>";
- }
-
- def list(): Data =
- NIL();
- def list(x0: Data): Data =
- CONS(x0, NIL());
- def list(x0: Data, x1: Data): Data =
- CONS(x0, list(x1));
- def list(x0: Data, x1: Data, x2: Data): Data =
- CONS(x0, list(x1, x2));
- def list(x0: Data, x1: Data, x2: Data, x3: Data): Data =
- CONS(x0, list(x1, x2, x3));
- def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data): Data =
- CONS(x0, list(x1, x2, x3, x4));
- def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data): Data =
- CONS(x0, list(x1, x2, x3, x4, x5));
- def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data,
- x6: Data): Data =
- CONS(x0, list(x1, x2, x3, x4, x5, x6));
- def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data,
- x6: Data, x7: Data): Data =
- CONS(x0, list(x1, x2, x3, x4, x5, x6, x7));
- def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data,
- x6: Data, x7: Data, x8: Data): Data =
- CONS(x0, list(x1, x2, x3, x4, x5, x6, x7, x8));
- def list(x0: Data, x1: Data, x2: Data, x3: Data, x4: Data, x5: Data,
- x6: Data, x7: Data, x8: Data, x9: Data): Data =
- CONS(x0, list(x1, x2, x3, x4, x5, x6, x7, x8, x9));
-
- var curexp: Data = null
- var trace: Boolean = false
- var indent: Int = 0
-
- def lispError[a](msg: String): a =
- sys.error("error: " + msg + "\n" + curexp);
-
- trait Environment {
- def lookup(n: String): Data;
- def extendRec(name: String, expr: Environment => Data) =
- new Environment {
- def lookup(n: String): Data =
- if (n == name) expr(this) else Environment.this.lookup(n);
- }
- def extend(name: String, v: Data) = extendRec(name, (env1 => v));
- }
- val EmptyEnvironment = new Environment {
- def lookup(n: String): Data = lispError("undefined: " + n);
- }
-
- def toList(x: Data): List[Data] = x match {
- case NIL() => List()
- case CONS(y, ys) => y :: toList(ys)
- case _ => lispError("malformed list: " + x);
- }
-
- def toBoolean(x: Data) = x match {
- case NUM(0) => false
- case _ => true
- }
-
- def normalize(x: Data): Data = x match {
- case CONS(SYM("def"),
- CONS(CONS(SYM(name), args), CONS(body, CONS(expr, NIL())))) =>
- normalize(list(SYM("def"),
- SYM(name), list(SYM("lambda"), args, body), expr))
- case CONS(SYM("cond"), CONS(CONS(SYM("else"), CONS(expr, NIL())),NIL())) =>
- normalize(expr)
- case CONS(SYM("cond"), CONS(CONS(test, CONS(expr, NIL())), rest)) =>
- normalize(list(SYM("if"), test, expr, CONS(SYM("cond"), rest)))
- case CONS(h, t) => CONS(normalize(h), normalize(t))
- case _ => x
- }
-
- def eval(x: Data, env: Environment): Data = {
- val prevexp = curexp;
- curexp = x;
- if (trace) {
- for (x <- range(1, indent)) Console.print(" ");
- Console.println("===> " + x);
- indent = indent + 1;
- }
- val result = eval1(x, env);
- if (trace) {
- indent = indent - 1;
- for (x <- range(1, indent)) Console.print(" ");
- Console.println("<=== " + result);
- }
- curexp = prevexp;
- result
- }
-
- def eval1(x: Data, env: Environment): Data = x match {
- case SYM(name) =>
- env lookup name
- case CONS(SYM("def"), CONS(SYM(name), CONS(y, CONS(z, NIL())))) =>
- eval(z, env.extendRec(name, (env1 => eval(y, env1))))
- case CONS(SYM("val"), CONS(SYM(name), CONS(y, CONS(z, NIL())))) =>
- eval(z, env.extend(name, eval(y, env)))
- case CONS(SYM("lambda"), CONS(params, CONS(y, NIL()))) =>
- mkLambda(params, y, env)
- case CONS(SYM("if"), CONS(c, CONS(t, CONS(e, NIL())))) =>
- if (toBoolean(eval(c, env))) eval(t, env) else eval(e, env)
- case CONS(SYM("quote"), CONS(x, NIL())) =>
- x
- case CONS(y, xs) =>
- apply(eval(y, env), toList(xs) map (x => eval(x, env)))
- case NUM(_) => x
- case STR(_) => x
- case FUN(_) => x
- case _ =>
- lispError("illegal term")
- }
-
- def apply(fn: Data, args: List[Data]): Data = fn match {
- case FUN(f) => f(args);
- case _ => lispError("application of non-function: " + fn);
- }
-
- def mkLambda(params: Data, expr: Data, env: Environment): Data = {
-
- def extendEnv(env: Environment,
- ps: List[String], args: List[Data]): Environment =
- (ps, args) match {
- case (List(), List()) =>
- env
- case (p :: ps1, arg :: args1) =>
- extendEnv(env.extend(p, arg), ps1, args1)
- case _ =>
- lispError("wrong number of arguments")
- }
-
- val ps: List[String] = toList(params) map {
- case SYM(name) => name
- case _ => sys.error("illegal parameter list");
- }
-
- FUN(args => eval(expr, extendEnv(env, ps, args)))
- }
-
- val globalEnv = EmptyEnvironment
- .extend("=", FUN({
- case List(NUM(arg1),NUM(arg2)) => NUM(if (arg1 == arg2) 1 else 0)
- case List(STR(arg1),STR(arg2)) => NUM(if (arg1 == arg2) 1 else 0)}))
- .extend("+", FUN({
- case List(NUM(arg1),NUM(arg2)) => NUM(arg1 + arg2)
- case List(STR(arg1),STR(arg2)) => STR(arg1 + arg2)}))
- .extend("-", FUN({
- case List(NUM(arg1),NUM(arg2)) => NUM(arg1 - arg2)}))
- .extend("*", FUN({
- case List(NUM(arg1),NUM(arg2)) => NUM(arg1 * arg2)}))
- .extend("/", FUN({
- case List(NUM(arg1),NUM(arg2)) => NUM(arg1 / arg2)}))
- .extend("car", FUN({
- case List(CONS(x, xs)) => x}))
- .extend("cdr", FUN({
- case List(CONS(x, xs)) => xs}))
- .extend("null?", FUN({
- case List(NIL()) => NUM(1)
- case _ => NUM(0)}))
- .extend("cons", FUN({
- case List(x, y) => CONS(x, y)}));
-
- def evaluate(x: Data): Data = eval(normalize(x), globalEnv);
- def evaluate(s: String): Data = evaluate(string2lisp(s));
-
- def string2lisp(s: String): Data = {
- val it = new LispTokenizer(s);
- def parse(token: String): Data = {
- if (token == "(") parseList
- else if (token == ")") sys.error("unbalanced parentheses")
- else if ('0' <= token.charAt(0) && token.charAt(0) <= '9')
- NUM(token.toInt)
- else if (token.charAt(0) == '\"' && token.charAt(token.length()-1)=='\"')
- STR(token.substring(1,token.length() - 1))
- else SYM(token)
- }
- def parseList: Data = {
- val token = it.next;
- if (token == ")") NIL() else CONS(parse(token), parseList)
- }
- parse(it.next)
- }
-
- def lisp2string(d: Data): String = d.toString();
-}
-
-//############################################################################
-// Lisp Implementation Using Any
-
-object LispAny extends Lisp {
-
- import List._;
-
- type Data = Any;
-
- case class Lambda(f: List[Data] => Data);
-
- var curexp: Data = null;
- var trace: Boolean = false;
- var indent: Int = 0;
-
- def lispError[a](msg: String): a =
- sys.error("error: " + msg + "\n" + curexp);
-
- trait Environment {
- def lookup(n: String): Data;
- def extendRec(name: String, expr: Environment => Data) =
- new Environment {
- def lookup(n: String): Data =
- if (n == name) expr(this) else Environment.this.lookup(n);
- }
- def extend(name: String, v: Data) = extendRec(name, (env1 => v));
- }
- val EmptyEnvironment = new Environment {
- def lookup(n: String): Data = lispError("undefined: " + n);
- }
-
- def asList(x: Data): List[Data] = x match {
- case y: List[_] => y
- case _ => lispError("malformed list: " + x)
- }
-
- def asInt(x: Data): Int = x match {
- case y: Int => y
- case _ => lispError("not an integer: " + x)
- }
-
- def asString(x: Data): String = x match {
- case y: String => y
- case _ => lispError("not a string: " + x)
- }
-
- def asBoolean(x: Data): Boolean = x != 0
-
- def normalize(x: Data): Data = x match {
- case 'and :: x :: y :: Nil =>
- normalize('if :: x :: y :: 0 :: Nil)
- case 'or :: x :: y :: Nil =>
- normalize('if :: x :: 1 :: y :: Nil)
- case 'def :: (name :: args) :: body :: expr :: Nil =>
- normalize('def :: name :: ('lambda :: args :: body :: Nil) :: expr :: Nil)
- case 'cond :: ('else :: expr :: Nil) :: rest =>
- normalize(expr);
- case 'cond :: (test :: expr :: Nil) :: rest =>
- normalize('if :: test :: expr :: ('cond :: rest) :: Nil)
- case 'cond :: 'else :: expr :: Nil =>
- normalize(expr)
- case h :: t =>
- normalize(h) :: asList(normalize(t))
- case _ =>
- x
- }
-
- def eval(x: Data, env: Environment): Data = {
- val prevexp = curexp;
- curexp = x;
- if (trace) {
- for (x <- range(1, indent)) Console.print(" ");
- Console.println("===> " + x);
- indent += 1;
- }
- val result = eval1(x, env);
- if (trace) {
- indent -= 1;
- for (x <- range(1, indent)) Console.print(" ");
- Console.println("<=== " + result);
- }
- curexp = prevexp;
- result
- }
-
- def eval1(x: Data, env: Environment): Data = x match {
- case Symbol(name) =>
- env lookup name
- case 'def :: Symbol(name) :: y :: z :: Nil =>
- eval(z, env.extendRec(name, (env1 => eval(y, env1))))
- case 'val :: Symbol(name) :: y :: z :: Nil =>
- eval(z, env.extend(name, eval(y, env)))
- case 'lambda :: params :: y :: Nil =>
- mkLambda(params, y, env)
- case 'if :: c :: y :: z :: Nil =>
- if (asBoolean(eval(c, env))) eval(y, env) else eval(z, env)
- case 'quote :: y :: Nil =>
- y
- case y :: z =>
- apply(eval(y, env), z map (x => eval(x, env)))
- case Lambda(_) => x
- case y: String => x
- case y: Int => x
- case y => lispError("illegal term")
- }
-
- def lisp2string(x: Data): String = x match {
- case Symbol(name) => name
- case Nil => "()"
- case y :: ys =>
- def list2string(xs: List[Data]): String = xs match {
- case List() => ""
- case y :: ys => " " + lisp2string(y) + list2string(ys)
- }
- "(" + lisp2string(y) + list2string(ys) + ")"
- case _ => if (x.isInstanceOf[String]) "\"" + x + "\""; else x.toString()
- }
-
- def apply(fn: Data, args: List[Data]): Data = fn match {
- case Lambda(f) => f(args);
- case _ => lispError("application of non-function: " + fn + " to " + args);
- }
-
- def mkLambda(params: Data, expr: Data, env: Environment): Data = {
-
- def extendEnv(env: Environment,
- ps: List[String], args: List[Data]): Environment =
- (ps, args) match {
- case (List(), List()) =>
- env
- case (p :: ps1, arg :: args1) =>
- extendEnv(env.extend(p, arg), ps1, args1)
- case _ =>
- lispError("wrong number of arguments")
- }
-
- val ps: List[String] = asList(params) map {
- case Symbol(name) => name
- case _ => sys.error("illegal parameter list");
- }
-
- Lambda(args => eval(expr, extendEnv(env, ps, args)))
- }
-
- val globalEnv = EmptyEnvironment
- .extend("=", Lambda{
- case List(arg1, arg2) => if(arg1 == arg2) 1 else 0})
- .extend("+", Lambda{
- case List(arg1: Int, arg2: Int) => arg1 + arg2
- case List(arg1: String, arg2: String) => arg1 + arg2})
- .extend("-", Lambda{
- case List(arg1: Int, arg2: Int) => arg1 - arg2})
- .extend("*", Lambda{
- case List(arg1: Int, arg2: Int) => arg1 * arg2})
- .extend("/", Lambda{
- case List(arg1: Int, arg2: Int) => arg1 / arg2})
- .extend("nil", Nil)
- .extend("cons", Lambda{
- case List(arg1, arg2) => arg1 :: asList(arg2)})
- .extend("car", Lambda{
- case List(x :: xs) => x})
- .extend("cdr", Lambda{
- case List(x :: xs) => xs})
- .extend("null?", Lambda{
- case List(Nil) => 1
- case _ => 0});
-
- def evaluate(x: Data): Data = eval(normalize(x), globalEnv);
- def evaluate(s: String): Data = evaluate(string2lisp(s));
-
- def string2lisp(s: String): Data = {
- val it = new LispTokenizer(s);
- def parse(token: String): Data = {
- if (token == "(") parseList
- else if (token == ")") sys.error("unbalanced parentheses")
- //else if (Character.isDigit(token.charAt(0)))
- else if (token.charAt(0).isDigit)
- token.toInt
- else if (token.charAt(0) == '\"' && token.charAt(token.length()-1)=='\"')
- token.substring(1,token.length() - 1)
- else Symbol(token)
- }
- def parseList: List[Data] = {
- val token = it.next;
- if (token == ")") Nil else parse(token) :: parseList
- }
- parse(it.next)
- }
-}
-
-//############################################################################
-// List User
-
-class LispUser(lisp: Lisp) {
-
- import lisp._;
-
- def evaluate(s: String) = lisp2string(lisp.evaluate(s));
-
- def run = {
-
- Console.println(string2lisp("(lambda (x) (+ (* x x) 1))").asInstanceOf[AnyRef]);
- Console.println(lisp2string(string2lisp("(lambda (x) (+ (* x x) 1))")));
- Console.println;
-
- Console.println("( '(1 2 3)) = " + evaluate(" (quote(1 2 3))"));
- Console.println("(car '(1 2 3)) = " + evaluate("(car (quote(1 2 3)))"));
- Console.println("(cdr '(1 2 3)) = " + evaluate("(cdr (quote(1 2 3)))"));
- Console.println("(null? '(2 3)) = " + evaluate("(null? (quote(2 3)))"));
- Console.println("(null? '()) = " + evaluate("(null? (quote()))"));
- Console.println;
-
- Console.println("faculty(10) = " + evaluate(
- "(def (faculty n) " +
- "(if (= n 0) " +
- "1 " +
- "(* n (faculty (- n 1)))) " +
- "(faculty 10))"));
- Console.println("faculty(10) = " + evaluate(
- "(def (faculty n) " +
- "(cond " +
- "((= n 0) 1) " +
- "(else (* n (faculty (- n 1))))) " +
- "(faculty 10))"));
- Console.println("foobar = " + evaluate(
- "(def (foo n) " +
- "(cond " +
- "((= n 0) \"a\")" +
- "((= n 1) \"b\")" +
- "((= (/ n 2) 1) " +
- "(cond " +
- "((= n 2) \"c\")" +
- "(else \"d\")))" +
- "(else " +
- "(def (bar m) " +
- "(cond " +
- "((= m 0) \"e\")" +
- "((= m 1) \"f\")" +
- "(else \"z\"))" +
- "(bar (- n 4)))))" +
- "(val nil (quote ())" +
- "(val v1 (foo 0) " +
- "(val v2 (+ (foo 1) (foo 2)) " +
- "(val v3 (+ (+ (foo 3) (foo 4)) (foo 5)) " +
- "(val v4 (foo 6) " +
- "(cons v1 (cons v2 (cons v3 (cons v4 nil))))))))))"));
- Console.println;
- }
-}
-
-//############################################################################
-// Main
-
-object Test {
- def main(args: Array[String]) {
- new LispUser(LispCaseClasses).run;
- new LispUser(LispAny).run;
- ()
- }
-}
-
-//############################################################################
diff --git a/test/files/pos/t482.scala b/test/files/pos/t482.scala
new file mode 100644
index 0000000000..b121c93337
--- /dev/null
+++ b/test/files/pos/t482.scala
@@ -0,0 +1,7 @@
+object Test {
+ class Foo { val z = "foo"; val y : z.type = z }
+
+ val x : ({ val y : z.type } forSome { val z : String }) = new Foo
+
+ val x2 : ({ val y : T } forSome { type T <: String with Singleton }) = new Foo
+}
diff --git a/test/files/pos/t4840.flags b/test/files/pos/t4840.flags
index eb4d19bcb9..768ca4f13b 100644
--- a/test/files/pos/t4840.flags
+++ b/test/files/pos/t4840.flags
@@ -1 +1 @@
--optimise \ No newline at end of file
+-opt:l:classpath \ No newline at end of file
diff --git a/test/files/pos/t4914.scala b/test/files/pos/t4914.scala
new file mode 100644
index 0000000000..a6c8ef5a4e
--- /dev/null
+++ b/test/files/pos/t4914.scala
@@ -0,0 +1,20 @@
+trait Type {
+ type S
+}
+
+class ConcreteType extends Type {
+ type S = Double
+}
+
+trait Base {
+ type T <: Type
+ val m: Map[t#S, t#S] forSome { type t <: T with Singleton }
+ val n: Map[x.type#S, x.type#S] forSome { val x: T }
+}
+
+abstract class Derived extends Base {
+ override type T = ConcreteType
+ override val m = Map[Double, Double]()
+ /** This does not work. §3.2.10 indicates that types n is shorthand for type of m. */
+ override val n = Map[Double, Double]()
+}
diff --git a/test/files/pos/t5120.scala b/test/files/pos/t5120.scala
index 86d4470bd5..40540b8a7d 100644
--- a/test/files/pos/t5120.scala
+++ b/test/files/pos/t5120.scala
@@ -1,4 +1,4 @@
-// An example extracted from SBT by Iulian
+// An example extracted from sbt by Iulian
// that showed that the previous fix to t5120
// was too strict.
class Test {
diff --git a/test/files/pos/t5165b.flags b/test/files/pos/t5165b.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/pos/t5165b.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/pos/t5183.scala b/test/files/pos/t5183.scala
new file mode 100644
index 0000000000..783b8c28dc
--- /dev/null
+++ b/test/files/pos/t5183.scala
@@ -0,0 +1,34 @@
+trait Day
+
+object Test {
+ def foo(t: Int with Day) = t == t
+}
+
+class DayOps(val i: Int with Day) extends AnyVal
+
+case class Test1(d: Int with Day)
+case class Test2(d1: Int with Day, d2: Int with Day)
+
+class User
+class Checkin
+object Example {
+
+ type Tagged[U] = { type Tag = U }
+ type @@[T, U] = T with Tagged[U] // Thanks to @retronym for suggesting this type alias
+
+ class Tagger[U] {
+ def apply[T](t : T) : T @@ U = t.asInstanceOf[T @@ U]
+ }
+ def tag[U] = new Tagger[U]
+
+ // Manual specialization needed here ... specializing apply above doesn't help
+ def tag[U](i : Int) : Int @@ U = i.asInstanceOf[Int @@ U]
+ def tag[U](l : Long) : Long @@ U = l.asInstanceOf[Long @@ U]
+ def tag[U](d : Double) : Double @@ U = d.asInstanceOf[Double @@ U]
+
+ def fetch[A](id: Int @@ A): A = null.asInstanceOf[A]
+
+ def tag[U](arr: Array[Int]):Array[Int @@ U] = arr.asInstanceOf[Array[Int @@ U]]
+
+ tag[User](Array(3, 4, 5)).map(_.toString)
+} \ No newline at end of file
diff --git a/test/files/pos/t5240.scala b/test/files/pos/t5240.scala
index 065d175f2f..ae52c6d69a 100644
--- a/test/files/pos/t5240.scala
+++ b/test/files/pos/t5240.scala
@@ -1,11 +1,3 @@
-
-
-
-
-
-
package object foo {
-
var labels: Array[_ <: String] = null
-
}
diff --git a/test/files/pos/t5294b.scala b/test/files/pos/t5294b.scala
new file mode 100644
index 0000000000..038d2ff806
--- /dev/null
+++ b/test/files/pos/t5294b.scala
@@ -0,0 +1,36 @@
+class Test {
+ def test = {
+
+ val l1 = null: Int #: String #: Boolean #: String #: HNil.type
+
+ type _2 = Succ[Succ[Zero.type]]
+
+ val t1: Boolean = null.asInstanceOf[ l1.type#Drop[_2]#Head ]
+
+ val t2: Boolean = null.asInstanceOf[ l1.type#Apply[_2] ]
+ }
+}
+
+
+sealed trait Nat {
+ type Fold[U, F[_ <: U] <: U, Z <: U] <: U
+}
+
+final object Zero extends Nat {
+ type Fold[U, F[_ <: U] <: U, Z <: U] = Z
+}
+
+final class Succ[N <: Nat] extends Nat {
+ type Fold[U, F[_ <: U] <: U, Z <: U] = F[N#Fold[U, F, Z]]
+}
+
+trait HList {
+ type Head
+ type Tail <: HList
+ type Drop[N <: Nat] = N#Fold[HList, ({ type L[X <: HList] = X#Tail })#L, this.type]
+ type Apply[N <: Nat] = Drop[N]#Head
+}
+
+class #: [H, T <: HList] extends HList { type Head = H; type Tail = T }
+
+object HNil extends HList { type Head = Nothing; type Tail = Nothing }
diff --git a/test/files/pos/t5294c.scala b/test/files/pos/t5294c.scala
new file mode 100644
index 0000000000..2709098988
--- /dev/null
+++ b/test/files/pos/t5294c.scala
@@ -0,0 +1,30 @@
+sealed trait Nat {
+ type IsZero[U, A <: U, B <: U] <: U
+}
+
+final object Zero extends Nat {
+ type IsZero[U, T <: U, F <: U] = T
+}
+
+final class Succ[N <: Nat] extends Nat {
+ type IsZero[U, T <: U, F <: U] = F
+}
+
+trait HList {
+ type Head
+ type Tail <: HList
+ type Drop[N <: Nat] = N#IsZero[HList, this.type, Tail]
+ type Apply[N <: Nat] = Drop[N]#Head // typechecks as HList.this.Head
+}
+
+object Test {
+ type ::[H, T <: HList] = HList { type Head = H; type Tail = T}
+ type HNil <: HList
+ type T = Int :: String :: HNil
+
+ type U = T#Drop[Succ[Zero.type]]#Head
+ type V = T#Apply[Succ[Zero.type]]
+ var u: U = ???
+ var v: V = ???
+ u = v
+}
diff --git a/test/files/pos/t533.scala b/test/files/pos/t533.scala
deleted file mode 100644
index 0a6515fed3..0000000000
--- a/test/files/pos/t533.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-import scala.actors._
-
-object test extends Actor {
- def act() {
- receive {
- case TIMEOUT => Console.println("TIMEOUT")
- //case _ => Console.println("_")
- }
- }
-}
-
diff --git a/test/files/pos/t5644/BoxesRunTime.java b/test/files/pos/t5644/BoxesRunTime.java
index 74c4c6b4b9..2b931519aa 100644
--- a/test/files/pos/t5644/BoxesRunTime.java
+++ b/test/files/pos/t5644/BoxesRunTime.java
@@ -267,10 +267,6 @@ public final class BoxesRunTime
else if (n instanceof java.lang.Float) return hashFromFloat((java.lang.Float)n);
else return n.hashCode();
}
- public static int hashFromObject(Object a) {
- if (a instanceof Number) return hashFromNumber((Number)a);
- else return a.hashCode();
- }
private static int unboxCharOrInt(Object arg1, int code) {
if (code == CHAR)
diff --git a/test/files/pos/t5729.scala b/test/files/pos/t5729.scala
deleted file mode 100644
index 9fd9c9ffbb..0000000000
--- a/test/files/pos/t5729.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-trait T[X]
-object Test {
- def join(in: Seq[T[_]]): Int = ???
- def join[S](in: Seq[T[S]]): String = ???
- join(null: Seq[T[_]])
-} \ No newline at end of file
diff --git a/test/files/pos/t5899.scala b/test/files/pos/t5899.scala
index b16f1f84fe..885baca790 100644
--- a/test/files/pos/t5899.scala
+++ b/test/files/pos/t5899.scala
@@ -14,6 +14,7 @@ trait Foo {
Bippy(Stable) match {
case Bippy(nme.WILDCARD) => 1
case Bippy(Stable) => 2 // should not be considered unreachable
+ case Bippy(_) => 3
}
}
} \ No newline at end of file
diff --git a/test/files/pos/t6091.scala b/test/files/pos/t6091.scala
index 72e663ec3b..0318640e7b 100644
--- a/test/files/pos/t6091.scala
+++ b/test/files/pos/t6091.scala
@@ -1,6 +1,6 @@
-object Foo { def eq(x:Int) = x }
+object Foo { def eq(x: Int) = x }
-class X { def ==(other: String) = true }
+class X { def ==(other: String) = other.nonEmpty }
object Test {
def main(args: Array[String]): Unit = {
diff --git a/test/files/pos/t6157.flags b/test/files/pos/t6157.flags
deleted file mode 100644
index 0ebca3e7af..0000000000
--- a/test/files/pos/t6157.flags
+++ /dev/null
@@ -1 +0,0 @@
- -optimize
diff --git a/test/files/pos/t6157.scala b/test/files/pos/t6157.scala
deleted file mode 100644
index 7463989b14..0000000000
--- a/test/files/pos/t6157.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-// SI-6157 - Compiler crash on inlined function and -optimize option
-
-object Test {
- def main(args: Array[String]) {
- Console.println(
- ErrorHandler.defaultIfIOException("String")("String")
- )
- }
-}
-
-import java.io.IOException
-
-object ErrorHandler {
-
- @inline
- def defaultIfIOException[T](default: => T)(closure: => T): T = {
- try {
- closure
- } catch {
- case e: IOException =>
- default
- }
- }
-}
-
diff --git a/test/files/pos/t6161b.scala b/test/files/pos/t6161b.scala
new file mode 100644
index 0000000000..5783cc85f2
--- /dev/null
+++ b/test/files/pos/t6161b.scala
@@ -0,0 +1,22 @@
+object t6161 {
+ trait N {
+ type Name
+ }
+
+ trait N1 extends N {
+ class Name {
+ type ThisNameType <: Name
+ def encode: ThisNameType = ???
+ }
+ }
+
+ trait S {
+ self: N => // change to N1 and it compiles
+ type NameType <: Name
+ }
+
+ object g extends S with N1
+
+ val n1: g.NameType = ???
+ val n2: g.Name = n1.encode
+}
diff --git a/test/files/pos/t6547.flags b/test/files/pos/t6547.flags
deleted file mode 100644
index c9b68d70dc..0000000000
--- a/test/files/pos/t6547.flags
+++ /dev/null
@@ -1 +0,0 @@
--optimise
diff --git a/test/files/pos/t6547.scala b/test/files/pos/t6547.scala
deleted file mode 100644
index 53bd798219..0000000000
--- a/test/files/pos/t6547.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-trait ConfigurableDefault[@specialized V] {
- def fillArray(arr: Array[V], v: V) = (arr: Any) match {
- case x: Array[Int] => null
- case x: Array[Long] => v.asInstanceOf[Long]
- }
-}
diff --git a/test/files/pos/t6734.scala b/test/files/pos/t6734.scala
new file mode 100644
index 0000000000..88932cd2cc
--- /dev/null
+++ b/test/files/pos/t6734.scala
@@ -0,0 +1,17 @@
+
+// desugars to package p { object `package` }
+// previously, synthetic p.C was incorrectly added to this tree
+// This only matters because synthetics are not hygienic
+package object p
+
+package p {
+ import scala.concurrent.Future
+ case class C private[p] (value: Future[Int]) // private to avoid rewriting C.apply to new C
+}
+
+package client {
+ trait X {
+ import scala.concurrent.Future
+ def f = p.C(Future(42)(null)) // ensure synthetics were generated, i.e., p.C.apply
+ }
+}
diff --git a/test/files/pos/t6778.scala b/test/files/pos/t6778.scala
new file mode 100644
index 0000000000..b7483c8fce
--- /dev/null
+++ b/test/files/pos/t6778.scala
@@ -0,0 +1,5 @@
+object test extends AnyRef with App {
+ // Check that random can be called with parenthesis.
+ scala.math.random()
+}
+
diff --git a/test/files/pos/t6978.flags b/test/files/pos/t6978.flags
new file mode 100644
index 0000000000..7949c2afa2
--- /dev/null
+++ b/test/files/pos/t6978.flags
@@ -0,0 +1 @@
+-Xlint -Xfatal-warnings
diff --git a/test/files/pos/t6978/J.java b/test/files/pos/t6978/J.java
new file mode 100644
index 0000000000..1b9029ce53
--- /dev/null
+++ b/test/files/pos/t6978/J.java
@@ -0,0 +1,5 @@
+
+public class J {
+ public int f() { return 42; }
+}
+
diff --git a/test/files/pos/t6978/S.scala b/test/files/pos/t6978/S.scala
new file mode 100644
index 0000000000..41897db5ac
--- /dev/null
+++ b/test/files/pos/t6978/S.scala
@@ -0,0 +1,7 @@
+
+trait X { def f: Int }
+
+object Test extends J with X with App {
+ println(f)
+}
+
diff --git a/test/files/pos/t7014/ThreadSafety.java b/test/files/pos/t7014/ThreadSafety.java
deleted file mode 100644
index ed508804e3..0000000000
--- a/test/files/pos/t7014/ThreadSafety.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package t7014;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(RetentionPolicy.RUNTIME) // must be exactly RUNTIME retention (those we parse)
-public @interface ThreadSafety {
- ThreadSafetyLevel level();
-} \ No newline at end of file
diff --git a/test/files/pos/t7014/ThreadSafetyLevel.java b/test/files/pos/t7014/ThreadSafetyLevel.java
deleted file mode 100644
index 4df1dc787a..0000000000
--- a/test/files/pos/t7014/ThreadSafetyLevel.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package t7014; // package needed due to other bug in scalac's java parser
-
-// since we parse eagerly, we have not yet parsed the classfile when parsing the annotation,
-// and on doing so, fail to find a symbol for the COMPLETELY_THREADSAFE reference
-// from the annotation's argument to the enum's member
-// for now, let's just not crash -- should implement lazy completing at some point
-@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
-public enum ThreadSafetyLevel { COMPLETELY_THREADSAFE }
diff --git a/test/files/pos/t7014/t7014.scala b/test/files/pos/t7014/t7014.scala
deleted file mode 100644
index 7c73f700be..0000000000
--- a/test/files/pos/t7014/t7014.scala
+++ /dev/null
@@ -1,3 +0,0 @@
-package t7014
-
-import ThreadSafetyLevel.COMPLETELY_THREADSAFE // refer to annotation so it gets parsed
diff --git a/test/files/pos/t7088.scala b/test/files/pos/t7088.scala
new file mode 100644
index 0000000000..de9d1b7040
--- /dev/null
+++ b/test/files/pos/t7088.scala
@@ -0,0 +1,8 @@
+object Example extends App {
+ type Tag[X] = {type Tag = X}
+ type TaggedArray[T] = Array[T] with Tag[Any]
+
+ def method[T: reflect.ClassTag](a: TaggedArray[T], value: T) {a.update(0, value)}
+
+ method(Array(1, 2).asInstanceOf[TaggedArray[Int]], 1)
+}
diff --git a/test/files/pos/t7239.scala b/test/files/pos/t7239.scala
deleted file mode 100644
index 16e9d00f17..0000000000
--- a/test/files/pos/t7239.scala
+++ /dev/null
@@ -1,38 +0,0 @@
-object Test {
- def BrokenMethod(): HasFilter[(Int, String)] = ???
-
- trait HasFilter[B] {
- def filter(p: B => Boolean) = ???
- }
-
- trait HasWithFilter {
- def withFilter = ???
- }
-
- object addWithFilter {
- trait NoImplicit
- implicit def enrich(v: Any)
- (implicit F0: NoImplicit): HasWithFilter = ???
- }
-
- BrokenMethod().withFilter(_ => true) // okay
- BrokenMethod().filter(_ => true) // okay
-
- locally {
- import addWithFilter._
- BrokenMethod().withFilter((_: (Int, String)) => true) // okay
- }
-
- locally {
- import addWithFilter._
- // adaptToMemberWithArgs sets the type of the tree `x`
- // to ErrorType (while in silent mode, so the error is not
- // reported. Later, when the fallback from `withFilter`
- // to `filter` is attempted, the closure is taken to have
- // have the type `<error> => Boolean`, which conforms to
- // `(B => Boolean)`. Only later during pickling does the
- // defensive check for erroneous types in the tree pick up
- // the problem.
- BrokenMethod().withFilter(x => true) // erroneous or inaccessible type.
- }
-}
diff --git a/test/files/pos/t7294.scala b/test/files/pos/t7294.scala
deleted file mode 100644
index ccac2b1400..0000000000
--- a/test/files/pos/t7294.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-object Test {
- // no fruitless warning as Tuple2 isn't (yet) final.
- // The corresponding `neg` test will treat it as final
- // for the purposes of these tests under -Xfuture.
- (1, 2) match { case Seq() => 0; case _ => 1 }
-}
diff --git a/test/files/pos/t7551.flags b/test/files/pos/t7551.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/pos/t7551.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/pos/t7551/A.java b/test/files/pos/t7551/A.java
new file mode 100644
index 0000000000..72aeb40fa0
--- /dev/null
+++ b/test/files/pos/t7551/A.java
@@ -0,0 +1,9 @@
+package p;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface A {
+ Class<?> subInterface();
+}
diff --git a/test/files/pos/t7551/T.scala b/test/files/pos/t7551/T.scala
new file mode 100644
index 0000000000..017926e0e2
--- /dev/null
+++ b/test/files/pos/t7551/T.scala
@@ -0,0 +1,9 @@
+package p
+
+@A(subInterface = classOf[T.S])
+trait T {
+}
+
+object T {
+ private[p] trait S extends T { }
+}
diff --git a/test/files/pos/t7551/Test.scala b/test/files/pos/t7551/Test.scala
new file mode 100644
index 0000000000..c1f529c4b1
--- /dev/null
+++ b/test/files/pos/t7551/Test.scala
@@ -0,0 +1,5 @@
+package p
+
+object Foo {
+ def bar(t: T) { }
+}
diff --git a/test/files/pos/t7784.scala b/test/files/pos/t7784.scala
new file mode 100644
index 0000000000..e6824a4203
--- /dev/null
+++ b/test/files/pos/t7784.scala
@@ -0,0 +1,13 @@
+object Test {
+ final val a = ""
+ var b: a.type = a
+ b = a
+
+ final val x = classOf[Object]
+ var y: x.type = x
+ y = x
+
+ final val e = Thread.State.NEW
+ var e1: e.type = e
+ e1 = e
+}
diff --git a/test/files/pos/t8002-nested-scope.scala b/test/files/pos/t8002-nested-scope.scala
deleted file mode 100644
index 8ce809e556..0000000000
--- a/test/files/pos/t8002-nested-scope.scala
+++ /dev/null
@@ -1,20 +0,0 @@
-// This test serves to capture the status quo, but should really
-// emit an accessibility error.
-
-// `Namers#companionSymbolOf` seems too lenient, and currently doesn't
-// implement the same-scope checks mentioned:
-//
-// https://github.com/scala/scala/pull/2816#issuecomment-22555206
-//
-class C {
- def foo = {
- class C { private def x = 0 }
-
- {
- val a = 0
- object C {
- new C().x
- }
- }
- }
-}
diff --git a/test/files/pos/t8013.flags b/test/files/pos/t8013.flags
index 3955bb6710..219723cec9 100644
--- a/test/files/pos/t8013.flags
+++ b/test/files/pos/t8013.flags
@@ -1 +1 @@
--Xfatal-warnings -Xlint:-infer-any,_
+-Xfatal-warnings -Xlint:missing-interpolator
diff --git a/test/files/pos/t8040.flags b/test/files/pos/t8040.flags
new file mode 100644
index 0000000000..3126c059f0
--- /dev/null
+++ b/test/files/pos/t8040.flags
@@ -0,0 +1 @@
+-Xfatal-warnings -Ywarn-unused:params
diff --git a/test/files/pos/t8040.scala b/test/files/pos/t8040.scala
new file mode 100644
index 0000000000..3e01014ab4
--- /dev/null
+++ b/test/files/pos/t8040.scala
@@ -0,0 +1,13 @@
+
+object Test {
+ implicit class C(val sc: StringContext) { // no warn unused sc
+ def c(args: Any*): String = "c?" + args.mkString(",") // would warn unused args
+ }
+
+ def f(implicit x: DummyImplicit) = 42 // no warn DummyImplicit
+
+
+ def f(x: Int)(y: Int = 1) = x + y // no warn default getter
+
+ def g(@deprecated("","") x: Int) = 42 // no warn deprecated
+}
diff --git a/test/files/pos/t8044.scala b/test/files/pos/t8044.scala
new file mode 100644
index 0000000000..2519a8306b
--- /dev/null
+++ b/test/files/pos/t8044.scala
@@ -0,0 +1,15 @@
+
+trait T {
+ def f = 42 match { case `x` @ _ => x }
+ def g = 42 match { case `type` @ _ => `type` }
+ def h = 42 match { case `type` : Int => `type` }
+ def i = (null: Any) match { case _: Int | _: String => 17 }
+
+ // arbitrary idents allowed in @ syntax
+ def j = "Fred" match { case Name @ (_: String) => Name }
+ def k = "Fred" match { case * @ (_: String) => * }
+
+ // also in sequence pattern
+ def m = List(1,2,3,4,5) match { case List(1, `Rest of them` @ _*) => `Rest of them` }
+
+}
diff --git a/test/files/pos/t8062.flags b/test/files/pos/t8062.flags
deleted file mode 100644
index 49d036a887..0000000000
--- a/test/files/pos/t8062.flags
+++ /dev/null
@@ -1 +0,0 @@
--optimize
diff --git a/test/files/pos/t8062/A_1.scala b/test/files/pos/t8062/A_1.scala
deleted file mode 100644
index ca0411dae8..0000000000
--- a/test/files/pos/t8062/A_1.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-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
deleted file mode 100644
index f0a6761488..0000000000
--- a/test/files/pos/t8062/B_2.scala
+++ /dev/null
@@ -1,3 +0,0 @@
-object Test {
- warmup.Warmup.filter[Any](x => false)
-}
diff --git a/test/files/pos/t8079b.scala b/test/files/pos/t8079b.scala
new file mode 100644
index 0000000000..f3b7b78077
--- /dev/null
+++ b/test/files/pos/t8079b.scala
@@ -0,0 +1,7 @@
+trait F1[/* - */T, /* + */ R]
+
+object Test {
+ import scala.annotation.unchecked._
+ type VariantF1[-T, +R] = F1[T @uncheckedVariance, R @uncheckedVariance]
+ trait C[+T] { def foo: VariantF1[Any, T] }
+}
diff --git a/test/files/pos/t8306.flags b/test/files/pos/t8306.flags
deleted file mode 100644
index 49d036a887..0000000000
--- a/test/files/pos/t8306.flags
+++ /dev/null
@@ -1 +0,0 @@
--optimize
diff --git a/test/files/pos/t8306.scala b/test/files/pos/t8306.scala
deleted file mode 100644
index e04b054eb9..0000000000
--- a/test/files/pos/t8306.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-class Si8306 {
- def foo: Int = 123
- lazy val extension: Int =
- foo match {
- case idx if idx != -1 => 15
- case _ => 17
- }
-}
diff --git a/test/files/pos/t8310.flags b/test/files/pos/t8310.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/pos/t8310.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/pos/t8315.flags b/test/files/pos/t8315.flags
deleted file mode 100644
index c926ad6493..0000000000
--- a/test/files/pos/t8315.flags
+++ /dev/null
@@ -1 +0,0 @@
--Yinline -Ydead-code
diff --git a/test/files/pos/t8315.scala b/test/files/pos/t8315.scala
deleted file mode 100644
index 2f7742ed67..0000000000
--- a/test/files/pos/t8315.scala
+++ /dev/null
@@ -1,12 +0,0 @@
-object Test {
- def crash(as: Listt): Unit = {
- map(as, (_: Any) => return)
- }
-
- final def map(x: Listt, f: Any => Any): Any = {
- if (x eq Nill) "" else f("")
- }
-}
-
-object Nill extends Listt
-class Listt
diff --git a/test/files/pos/t8315b.flags b/test/files/pos/t8315b.flags
deleted file mode 100644
index c926ad6493..0000000000
--- a/test/files/pos/t8315b.flags
+++ /dev/null
@@ -1 +0,0 @@
--Yinline -Ydead-code
diff --git a/test/files/pos/t8315b.scala b/test/files/pos/t8315b.scala
deleted file mode 100644
index d7a2bf565f..0000000000
--- a/test/files/pos/t8315b.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-object Test extends Object {
- def crash: Unit = {
- val key = ""
- try map(new F(key))
- catch { case _: Throwable => }
- };
- final def map(f: F): Any = f.apply("");
-};
-final class F(key: String) {
- final def apply(a: Any): Any = throw new RuntimeException(key);
-}
diff --git a/test/files/pos/t8359-closelim-crash.flags b/test/files/pos/t8359-closelim-crash.flags
deleted file mode 100644
index 49d036a887..0000000000
--- a/test/files/pos/t8359-closelim-crash.flags
+++ /dev/null
@@ -1 +0,0 @@
--optimize
diff --git a/test/files/pos/t8359-closelim-crash.scala b/test/files/pos/t8359-closelim-crash.scala
deleted file mode 100644
index 1413694d10..0000000000
--- a/test/files/pos/t8359-closelim-crash.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-package test
-
-// This is a minimization of code that crashed the compiler during bootstrapping
-// in the first iteration of https://github.com/scala/scala/pull/4373, the PR
-// that adjusted the order of free and declared params in LambdaLift.
-
-// Was:
-// java.lang.AssertionError: assertion failed:
-// Record Record(<$anon: Function1>,Map(value a$1 -> Deref(LocalVar(value b)))) does not contain a field value b$1
-// at scala.tools.nsc.Global.assert(Global.scala:262)
-// at scala.tools.nsc.backend.icode.analysis.CopyPropagation$copyLattice$State.getFieldNonRecordValue(CopyPropagation.scala:113)
-// at scala.tools.nsc.backend.icode.analysis.CopyPropagation$copyLattice$State.getFieldNonRecordValue(CopyPropagation.scala:122)
-// at scala.tools.nsc.backend.opt.ClosureElimination$ClosureElim$$anonfun$analyzeMethod$1$$anonfun$apply$2.replaceFieldAccess$1(ClosureElimination.scala:124)
-class Typer {
- def bar(a: Boolean, b: Boolean): Unit = {
- @inline
- def baz(): Unit = {
- ((_: Any) => (Typer.this, a, b)).apply("")
- }
- ((_: Any) => baz()).apply("")
- }
-}
-
diff --git a/test/files/pos/t8410.flags b/test/files/pos/t8410.flags
index dcd5943c2f..85e4257541 100644
--- a/test/files/pos/t8410.flags
+++ b/test/files/pos/t8410.flags
@@ -1 +1 @@
--optimise -Xfatal-warnings -deprecation:false -Yinline-warnings:false
+-opt:l:project -Xfatal-warnings -deprecation:false -opt-warnings:none
diff --git a/test/files/pos/t8429.scala b/test/files/pos/t8429.scala
new file mode 100644
index 0000000000..a2d32637e1
--- /dev/null
+++ b/test/files/pos/t8429.scala
@@ -0,0 +1,7 @@
+trait Must { def musta(str: String, i: Int): Unit }
+
+object Mustare {
+ def takesM(m: Must) = ???
+ takesM{ (a, b) => println } // ok
+ takesM{ case (a: String, b: Int) => println("") } // should also be accepted
+}
diff --git a/test/files/pos/t8462.scala b/test/files/pos/t8462.scala
new file mode 100644
index 0000000000..6946cf8e5e
--- /dev/null
+++ b/test/files/pos/t8462.scala
@@ -0,0 +1,11 @@
+
+trait ConstantOps {
+ def exprs = (
+ 1 << 2L : Int, // was: error: type mismatch; found : Long(4L)
+ 64 >> 2L : Int, // was: error: type mismatch; found : Long(4L)
+ 64 >>> 2L : Int, // was: error: type mismatch; found : Long(4L)
+ 'a' << 2L : Int,
+ 'a' >> 2L : Int,
+ 'a'>>> 2L : Int
+ )
+}
diff --git a/test/files/pos/t8862a.scala b/test/files/pos/t8862a.scala
new file mode 100644
index 0000000000..f9576707ba
--- /dev/null
+++ b/test/files/pos/t8862a.scala
@@ -0,0 +1,47 @@
+package p {
+
+ abstract class C[A] {
+ def x: A
+ implicit def oops: A = x
+ implicit def oopso: Option[A] = None
+ }
+
+ package q {
+
+ class Oops
+
+ object `package` extends C[Oops] {
+ override def x = new Oops
+ }
+
+ object Blah {
+ oops
+ oopso
+
+ // implicits found in enclosing context
+ implicitly[Oops]
+ implicitly[Option[Oops]]
+ }
+ }
+}
+
+package other {
+
+ object Blah {
+ // implicits found through this import
+ import p.q._
+
+ oops
+ oopso
+
+ implicitly[Oops]
+ implicitly[Option[Oops]]
+ }
+
+
+ object Blee {
+ // implicits found through the companion implicits
+ implicitly[p.q.Oops]
+ implicitly[Option[p.q.Oops]]
+ }
+}
diff --git a/test/files/pos/t8862b.scala b/test/files/pos/t8862b.scala
new file mode 100644
index 0000000000..8be7fb5fab
--- /dev/null
+++ b/test/files/pos/t8862b.scala
@@ -0,0 +1,12 @@
+package p {
+ trait T[X] { def O : { def apply(): X } }
+ object `package` extends T[Int] {
+ def O: { def apply(): Int } = new { def apply(): Int = 42 }
+ }
+
+ object Test {
+ def main(args: Array[String]): Unit = {
+ val x: Int = O()
+ }
+ }
+}
diff --git a/test/files/pos/t8873.scala b/test/files/pos/t8873.scala
new file mode 100644
index 0000000000..e2f0a5fad2
--- /dev/null
+++ b/test/files/pos/t8873.scala
@@ -0,0 +1 @@
+case class X(@volatile var x:Int)
diff --git a/test/files/pos/t8947/Macro_1.scala b/test/files/pos/t8947/Macro_1.scala
index ace389f339..c669e68b1e 100644
--- a/test/files/pos/t8947/Macro_1.scala
+++ b/test/files/pos/t8947/Macro_1.scala
@@ -36,6 +36,6 @@ object X {
// }
//
// To make this visible to the macro implementation, it will need to be compiled in an earlier stage,
- // e.g a separate SBT sub-project.
+ // e.g a separate sbt sub-project.
}
diff --git a/test/files/pos/t9020.scala b/test/files/pos/t9020.scala
index 16e31e2572..c77a63cb1a 100644
--- a/test/files/pos/t9020.scala
+++ b/test/files/pos/t9020.scala
@@ -8,3 +8,9 @@ test/files/pos/t9020.scala:2: warning: discarded non-Unit value
^
one warning found
*/
+
+trait DiscardThis {
+ import collection.mutable.ListBuffer
+ val b = ListBuffer.empty[String]
+ def add(s: String): Unit = b += s
+}
diff --git a/test/files/pos/t9074.scala b/test/files/pos/t9074.scala
new file mode 100644
index 0000000000..67db281f54
--- /dev/null
+++ b/test/files/pos/t9074.scala
@@ -0,0 +1,24 @@
+package blam {
+
+ package foo {
+
+ trait F[T] {
+ def f(d: Double, t: T): T = ???
+ def f(d: Int, t: T): T = ???
+ def f(d: String, t: T): T = ???
+
+ def g[A](a: T): T = ???
+ def g(a: Int) = ???
+ }
+ }
+
+ package object foo extends foo.F[Double] {
+ override def f(d: Double, t: Double): Double = ???
+ }
+}
+
+object Test {
+ import blam._
+ foo.f("3", 4.0)
+ foo.g[Any](1d) : Double
+}
diff --git a/test/files/pos/t9074b.scala b/test/files/pos/t9074b.scala
new file mode 100644
index 0000000000..dadcebf399
--- /dev/null
+++ b/test/files/pos/t9074b.scala
@@ -0,0 +1,15 @@
+trait Echo [T] {
+ def echo(t: T): Unit
+}
+
+trait IntEcho extends Echo[Int] {
+ def echo(t: Int) = println(t)
+}
+
+object echo extends IntEcho
+package object echo1 extends IntEcho
+
+object App extends App {
+ echo.echo(1)
+ echo1.echo(1)
+}
diff --git a/test/files/pos/t9111-inliner-workaround.flags b/test/files/pos/t9111-inliner-workaround.flags
index 63b5558cfd..768ca4f13b 100644
--- a/test/files/pos/t9111-inliner-workaround.flags
+++ b/test/files/pos/t9111-inliner-workaround.flags
@@ -1 +1 @@
--Ybackend:GenBCode -Yopt:l:classpath \ No newline at end of file
+-opt:l:classpath \ No newline at end of file
diff --git a/test/files/pos/t9123.flags b/test/files/pos/t9123.flags
deleted file mode 100644
index c16e2f71dc..0000000000
--- a/test/files/pos/t9123.flags
+++ /dev/null
@@ -1 +0,0 @@
--optimize -Ydelambdafy:method
diff --git a/test/files/pos/t9123.scala b/test/files/pos/t9123.scala
deleted file mode 100644
index 22d55b4351..0000000000
--- a/test/files/pos/t9123.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-trait Setting {
- type T
- def value: T
-}
-
-object Test {
- def test(x: Some[Setting]) = x match {
- case Some(dep) => Some(dep.value) map (_ => true)
- }
-}
diff --git a/test/files/pos/t9131.scala b/test/files/pos/t9131.scala
new file mode 100644
index 0000000000..1a186a0a24
--- /dev/null
+++ b/test/files/pos/t9131.scala
@@ -0,0 +1,12 @@
+class Test {
+
+ def byNameFunc(f: (=> (() => Any)) => Any): Unit = ()
+
+ def test = {
+ // "value apply is not a member of => () => Any"
+ byNameFunc(z => z())
+ // okay
+ byNameFunc(z => z.apply())
+ byNameFunc(z => {val f = z; f()})
+ }
+}
diff --git a/test/files/pos/sammy_exist.flags b/test/files/pos/t9178b.flags
index 48fd867160..48fd867160 100644
--- a/test/files/pos/sammy_exist.flags
+++ b/test/files/pos/t9178b.flags
diff --git a/test/files/pos/t9178b.scala b/test/files/pos/t9178b.scala
new file mode 100644
index 0000000000..cbeaed4f17
--- /dev/null
+++ b/test/files/pos/t9178b.scala
@@ -0,0 +1,7 @@
+abstract class Test{
+ val writeInput: java.io.OutputStream => Unit
+ def getOutputStream(): java.io.OutputStream
+
+ writeInput(getOutputStream)
+}
+
diff --git a/test/files/pos/t9326a.scala b/test/files/pos/t9326a.scala
new file mode 100644
index 0000000000..aefc735585
--- /dev/null
+++ b/test/files/pos/t9326a.scala
@@ -0,0 +1,6 @@
+package p
+
+trait M[A]
+
+class C extends M[Tuple1[X] forSome { type X }]
+
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/pos/t9449.scala b/test/files/pos/t9449.scala
new file mode 100644
index 0000000000..3b86dc80a0
--- /dev/null
+++ b/test/files/pos/t9449.scala
@@ -0,0 +1,19 @@
+trait II {
+ def apply(x: Int): Int
+}
+
+object Test {
+ def ii(x: Int): Int = x
+ def test = {
+ val ii1: II = x => ii(x) // works
+ val ii2: II = ii // works (adapting `ii` to `II`)
+ val ii3: II = ii _ // works (failed before the fix)
+ // typedTyped({ii : (() => <empty>)})
+ // typedEta(ii, pt = II)
+ // adapt(ii, pt = (? => ?))
+ // instantiatedToMethodType(ii, pt = (? => ?))
+ // val ii3: II = ii _ // error:
+ // found : Int => Int
+ // required: II
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/t9479.scala b/test/files/pos/t9479.scala
new file mode 100644
index 0000000000..38eabf4338
--- /dev/null
+++ b/test/files/pos/t9479.scala
@@ -0,0 +1,15 @@
+trait Predefs {
+ def bridge(p: String): Unit = ???
+ def bridge(p: Any): Unit = ???
+}
+
+package object molecule extends Predefs
+
+package molecule {
+ package process {
+ class Test {
+ def main(): Unit = bridge(null, null)
+ }
+ }
+}
+
diff --git a/test/files/pos/t9479b.scala b/test/files/pos/t9479b.scala
new file mode 100644
index 0000000000..5fc795a1fd
--- /dev/null
+++ b/test/files/pos/t9479b.scala
@@ -0,0 +1,15 @@
+trait Predefs {
+ def bridge(p: String): Unit = ???
+ def bridge(p: Any): Unit = ???
+}
+
+package object molecule extends Predefs
+
+package molecule {
+ package process {
+ class Test {
+ def main(): Unit = molecule.bridge(null, null)
+ }
+ }
+}
+
diff --git a/test/files/pos/t9498.scala b/test/files/pos/t9498.scala
new file mode 100644
index 0000000000..32fc01a806
--- /dev/null
+++ b/test/files/pos/t9498.scala
@@ -0,0 +1,25 @@
+trait Inv[A] { def head: A }
+trait Cov[+A] { def head: A }
+
+class Test {
+ def inv(i: Inv[Inv[String]]) = i match {
+ case l: Inv[a] =>
+ val x: a = l.head
+ x.head: String // okay
+ }
+
+ def cov(c: Cov[Cov[String]]) = c match {
+ case l: Cov[a] =>
+ val x: a = l.head
+ x.head: String // was: found A, required String
+ }
+
+ def cov1(c: Cov[Cov[String]]) = c match {
+ case l: Cov[a] => l.head.head
+ }
+ cov1(null): String // was: found A, required String
+
+ def cov3(c: Cov[Cov[String]]): String = c match {
+ case l: Cov[a] => val l1: l.type = l; l1.head.head
+ }
+}
diff --git a/test/files/pos/t9542.scala b/test/files/pos/t9542.scala
new file mode 100644
index 0000000000..d65f7ac4c6
--- /dev/null
+++ b/test/files/pos/t9542.scala
@@ -0,0 +1,8 @@
+object O {
+ trait T
+
+ class VC(val self: Any) extends AnyVal {
+ def extMethod(f: F1[T, Any]) = ()
+ }
+}
+trait F1[A, B]
diff --git a/test/files/pos/t9658.scala b/test/files/pos/t9658.scala
new file mode 100644
index 0000000000..a2c695a8ae
--- /dev/null
+++ b/test/files/pos/t9658.scala
@@ -0,0 +1,10 @@
+sealed trait G[T]
+case object GI extends G[Int]
+
+class C {
+ def typerFail[T](rt: G[T]): T = rt match {
+ case GI =>
+ { case x => x } : PartialFunction[Any, Any] // comment this line, compiles.
+ 0 // found Int, required T
+ }
+}
diff --git a/test/files/pos/t9665.scala b/test/files/pos/t9665.scala
new file mode 100644
index 0000000000..1aa7a5d459
--- /dev/null
+++ b/test/files/pos/t9665.scala
@@ -0,0 +1,7 @@
+
+object | { def unapply(x: (Any, Any)) = Some(x) }
+
+trait Test {
+ def f() = (1,2) match { case 1 `|` 2 => }
+ def g() = 2 match { case 1 | 2 => }
+}
diff --git a/test/files/pos/t9855.scala b/test/files/pos/t9855.scala
new file mode 100644
index 0000000000..b6ac3e2432
--- /dev/null
+++ b/test/files/pos/t9855.scala
@@ -0,0 +1,10 @@
+class C {
+ def xx(verb: String, a: Array[Int]) {
+ val reYYYY = """(\d\d\d\d)""".r
+ verb match {
+ case "time" if a.isEmpty =>
+ case "time" =>
+ case reYYYY(y) =>
+ }
+ }
+}
diff --git a/test/files/pos/t9855b.scala b/test/files/pos/t9855b.scala
new file mode 100644
index 0000000000..30c58be3dc
--- /dev/null
+++ b/test/files/pos/t9855b.scala
@@ -0,0 +1,16 @@
+object Test {
+ var FALSE = false
+ def main(args: Array[String]): Unit = {
+ val SomeB = new B
+ new B() match {
+ case SomeB if FALSE =>
+ case SomeB =>
+ case Ext(_) =>
+ }
+ }
+}
+object Ext {
+ def unapply(s: A) = Some(())
+}
+class A
+class B extends A
diff --git a/test/files/pos/t9918/package.scala b/test/files/pos/t9918/package.scala
new file mode 100644
index 0000000000..9bd8ac9a69
--- /dev/null
+++ b/test/files/pos/t9918/package.scala
@@ -0,0 +1 @@
+package object pkg extends T
diff --git a/test/files/pos/t9918/t9918.scala b/test/files/pos/t9918/t9918.scala
new file mode 100644
index 0000000000..ec9a146579
--- /dev/null
+++ b/test/files/pos/t9918/t9918.scala
@@ -0,0 +1,3 @@
+package pkg
+
+trait T { object O }
diff --git a/test/files/pos/t9920.scala b/test/files/pos/t9920.scala
new file mode 100644
index 0000000000..8612618cc4
--- /dev/null
+++ b/test/files/pos/t9920.scala
@@ -0,0 +1,6 @@
+object Test {
+ def o = {
+ def i: Int = { i; 0 }
+ i
+ }
+}
diff --git a/test/files/pos/t9943.scala b/test/files/pos/t9943.scala
new file mode 100644
index 0000000000..0d4717ccbb
--- /dev/null
+++ b/test/files/pos/t9943.scala
@@ -0,0 +1,9 @@
+class Foo[T] {
+ def toMap[K, V](implicit ev: Foo[T] <:< Foo[(K, V)]): Foo[Map[K, V]] = null
+ def toMap[K](keySelector: T => K): Foo[Map[K, T]] = null
+}
+
+object Foo {
+ (??? : Foo[Int]) toMap (_ % 2)
+ (??? : Foo[(Int, String)]).toMap
+}
diff --git a/test/files/pos/tcpoly_bounds1.scala b/test/files/pos/tcpoly_bounds1.scala
index 63263cb152..4f52f55cb6 100644
--- a/test/files/pos/tcpoly_bounds1.scala
+++ b/test/files/pos/tcpoly_bounds1.scala
@@ -1,7 +1,9 @@
-class Foo[t[x]<: Tuple2[Int, x]]
+case class T2[+T1, +T2](_1: T1, _2: T2) extends Product2[T1, T2]
+
+class Foo[t[x]<: T2[Int, x]]
//
-class MyPair[z](a: Int, b: z) extends Tuple2[Int, z](a,b)
+class MyPair[z](a: Int, b: z) extends T2[Int, z](a,b)
object foo extends Foo[MyPair]
diff --git a/test/files/pos/trailing-commas.scala b/test/files/pos/trailing-commas.scala
new file mode 100644
index 0000000000..b9401fe49d
--- /dev/null
+++ b/test/files/pos/trailing-commas.scala
@@ -0,0 +1,155 @@
+package foo
+
+trait ArgumentExprs1 {
+ def f(foo: Int, bar: String)(implicit ev0: Ev0, ev1: Ev1) = 1
+ f(
+ 23,
+ "bar",
+ )(
+ Ev0,
+ Ev1,
+ )
+
+ // test arg exprs in the presence of varargs
+ def g(x: Int, y: Int*) = 1
+ g(1,2,
+ )
+ g(1,List(2, 3): _*,
+ )
+}
+
+trait ArgumentExprs2 {
+ class C(foo: Int, bar: String)(implicit ev0: Ev0, ev1: Ev1)
+ new C(
+ 23,
+ "bar",
+ )(
+ Ev0,
+ Ev1,
+ )
+}
+
+trait Params {
+ def f(
+ foo: Int,
+ bar: String,
+ )(implicit
+ ev0: Ev0,
+ ev1: Ev1,
+ )
+}
+
+trait ClassParams {
+ class C(
+ foo: Int,
+ bar: String,
+ )(implicit
+ ev0: Ev0,
+ ev1: Ev1,
+ )
+
+ // test class params in the precense of varargs
+ case class D(i: Int*,
+ )
+}
+
+trait SimpleExpr1 {
+ def f: (Int, String) = (
+ 23,
+ "bar",
+ )
+
+ // the Tuple1 value case, the trailing comma is ignored so the type is Int and the value 23
+ def g: Int = (
+ 23,
+ )
+}
+
+trait TypeArgs {
+ class C[A, B]
+ def f: C[
+ Int,
+ String,
+ ]
+}
+
+trait TypeParamClause {
+ class C[
+ A,
+ B,
+ ]
+}
+
+trait FunTypeParamClause {
+ def f[
+ A,
+ B,
+ ]
+}
+
+trait SimpleType {
+ def f: (
+ Int,
+ String,
+ )
+
+ // the Tuple1 type case, the trailing comma is ignored so the type is Int and the value 23
+ def g: (
+ Int,
+ ) = 23
+}
+
+trait FunctionArgTypes {
+ def f: (
+ Int,
+ String,
+ ) => Boolean
+}
+
+trait SimplePattern {
+ val (
+ foo,
+ bar,
+ ) = null: Any
+
+ // test '@' syntax in patterns
+ Some(1) match {
+ case Some(x @ 1,
+ ) => x
+ }
+
+ // test ': _*' syntax in patterns
+ List(1, 2, 3) match {
+ case List(1, 2, _ @ _*,
+ ) => 1
+ }
+
+ // test varargs in patterns
+ val List(x, y, _*,
+ ) = 42 :: 17 :: Nil
+}
+
+trait ImportSelectors {
+ import foo.{
+ Ev0,
+ Ev1,
+ }
+}
+
+trait Bindings {
+ def g(f: (Int, String) => Boolean)
+
+ g((
+ foo,
+ bar,
+ ) => true)
+}
+
+// Import, ids, ValDcl, VarDcl, VarDef, PatDef use commas, but not inside paren, bracket or brace,
+// so they don't support an optional trailing comma
+
+// test utilities
+object `package` {
+ sealed trait Ev0; implicit object Ev0 extends Ev0
+ sealed trait Ev1; implicit object Ev1 extends Ev1
+}
diff --git a/test/files/pos/trait-defaults-super.scala b/test/files/pos/trait-defaults-super.scala
new file mode 100644
index 0000000000..8f867ab563
--- /dev/null
+++ b/test/files/pos/trait-defaults-super.scala
@@ -0,0 +1,21 @@
+trait T extends java.lang.Iterable[String] {
+
+ override def spliterator(): java.util.Spliterator[String] = {
+ super[Iterable].spliterator
+ super.spliterator
+ null
+ }
+ def foo = {
+ super[Iterable].spliterator
+ super.spliterator
+ }
+ def iterator(): java.util.Iterator[String] = java.util.Collections.emptyList().iterator()
+}
+class C extends T with java.lang.Iterable[String] // super accessor is okay with Iterable as a direct parent
+object Test {
+ def main(args: Array[String]): Unit = {
+ val t: T = new C
+ t.spliterator
+ t.foo
+ }
+}
diff --git a/test/files/pos/trait-force-info.flags b/test/files/pos/trait-force-info.flags
deleted file mode 100644
index eb4d19bcb9..0000000000
--- a/test/files/pos/trait-force-info.flags
+++ /dev/null
@@ -1 +0,0 @@
--optimise \ No newline at end of file
diff --git a/test/files/pos/trait-force-info.scala b/test/files/pos/trait-force-info.scala
deleted file mode 100644
index c2b33869c3..0000000000
--- a/test/files/pos/trait-force-info.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-/** This does NOT crash unless it's in the interactive package.
- */
-
-package scala.tools.nsc
-package interactive
-
-trait MyContextTrees {
- val self: Global
- val NoContext = self.analyzer.NoContext
-}
-//
-// error: java.lang.AssertionError: assertion failed: trait Contexts.NoContext$ linkedModule: <none>List()
-// at scala.Predef$.assert(Predef.scala:160)
-// at scala.tools.nsc.symtab.classfile.ClassfileParser$innerClasses$.innerSymbol$1(ClassfileParser.scala:1211)
-// at scala.tools.nsc.symtab.classfile.ClassfileParser$innerClasses$.classSymbol(ClassfileParser.scala:1223)
-// at scala.tools.nsc.symtab.classfile.ClassfileParser.classNameToSymbol(ClassfileParser.scala:489)
-// at scala.tools.nsc.symtab.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:757)
-// at scala.tools.nsc.symtab.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:789)
diff --git a/test/files/pos/trait_fields_dependent_conflict.scala b/test/files/pos/trait_fields_dependent_conflict.scala
new file mode 100644
index 0000000000..afb6f4b0c5
--- /dev/null
+++ b/test/files/pos/trait_fields_dependent_conflict.scala
@@ -0,0 +1,20 @@
+// derived from test/files/pos/S5.scala
+
+// compile with -uniqid to see a hint of the trouble
+trait N {
+ // the symbol for self does not get rebound when synthesizing members in C
+ val self: N = ???
+ val n: self.type = self
+}
+
+abstract class M {
+ val self: N
+ val n: self.type
+}
+
+abstract class MConflict extends N {
+ val self: N
+ val n: self.type
+}
+
+class C extends M with N
diff --git a/test/files/pos/trait_fields_dependent_rebind.scala b/test/files/pos/trait_fields_dependent_rebind.scala
new file mode 100644
index 0000000000..e2cf4c43c3
--- /dev/null
+++ b/test/files/pos/trait_fields_dependent_rebind.scala
@@ -0,0 +1,15 @@
+// derived from test/files/pos/S5.scala
+
+// compile with -uniqid to see a hint of the trouble
+trait N {
+ // the symbol for self does not get rebound when synthesizing members in C
+ val self: N = ???
+ val n: self.type = self
+}
+
+abstract class M {
+ val self: N
+ val n: self.type
+}
+
+class C extends M with N
diff --git a/test/files/pos/trait_fields_inherit_double_def.scala b/test/files/pos/trait_fields_inherit_double_def.scala
new file mode 100644
index 0000000000..8703d6312c
--- /dev/null
+++ b/test/files/pos/trait_fields_inherit_double_def.scala
@@ -0,0 +1,20 @@
+// done
+// test/files/trait-defaults/fields.scala:24: error: double definition:
+// def signalDelegate_=(x$1: Signalling): Unit at line 24 and
+// def signalDelegate_=(x$1: Signalling): Unit at line 24
+// have same type
+// class SUB extends IterableSplitter
+// ^
+// one error found
+
+trait Signalling
+
+trait DelegatedSignalling extends Signalling {
+ var signalDelegate: Signalling
+}
+
+trait IterableSplitter extends DelegatedSignalling {
+ var signalDelegate: Signalling = ???
+}
+
+class SUB extends IterableSplitter \ No newline at end of file
diff --git a/test/files/pos/trait_fields_lambdalift.scala b/test/files/pos/trait_fields_lambdalift.scala
new file mode 100644
index 0000000000..62304a5268
--- /dev/null
+++ b/test/files/pos/trait_fields_lambdalift.scala
@@ -0,0 +1,22 @@
+class Lift {
+ def foo = {
+ // this will be captured by the MouseHandler trait,
+ // which gives rise to a new trait field during LambdaLift
+ var Clicked = "Clicked"
+
+ def bar = Clicked
+
+ trait MouseHandler {
+ def mouseClicked = Clicked + bar
+ }
+
+ class CC extends MouseHandler
+
+ // new C {}
+ (new CC).mouseClicked
+ }
+}
+
+object O extends Lift with App {
+ println(foo)
+}
diff --git a/test/files/pos/trait_fields_nested_private_object.scala b/test/files/pos/trait_fields_nested_private_object.scala
new file mode 100644
index 0000000000..8efc1cb3fa
--- /dev/null
+++ b/test/files/pos/trait_fields_nested_private_object.scala
@@ -0,0 +1,8 @@
+trait NestedObj {
+ private object O { println("NO") }
+}
+
+
+class C extends NestedObj {
+ def O = ???
+} \ No newline at end of file
diff --git a/test/files/pos/trait_fields_nested_public_object.scala b/test/files/pos/trait_fields_nested_public_object.scala
new file mode 100644
index 0000000000..016487fb8a
--- /dev/null
+++ b/test/files/pos/trait_fields_nested_public_object.scala
@@ -0,0 +1,5 @@
+trait NestedObj {
+ object O { println("NO") }
+}
+
+class C extends NestedObj \ No newline at end of file
diff --git a/test/files/pos/trait_fields_owners.scala b/test/files/pos/trait_fields_owners.scala
new file mode 100644
index 0000000000..6aa5572171
--- /dev/null
+++ b/test/files/pos/trait_fields_owners.scala
@@ -0,0 +1,19 @@
+trait V {
+ // ok
+ // error: java.lang.IllegalArgumentException: Could not find proxy for val f: Function1 in List(value f, value v, trait V, package <empty>, package <root>) (currentOwner= value <local V$class> )
+ val v = { val f = (x: Int) => x + 1; f(2) }
+
+ // ok
+ // assertion failed:
+ // Trying to access the this of another class: tree.symbol = trait V, class symbol = object V$class compilation unit: fields.scala
+ val developmentVersion =
+ for {
+ v <- scalaPropOrNone("maven.version.number")
+ if v endsWith "-SNAPSHOT"
+ ov <- scalaPropOrNone("version.number")
+ } yield ov
+
+ def scalaPropOrNone(name: String): Option[String] = ???
+}
+
+object O extends V \ No newline at end of file
diff --git a/test/files/pos/trait_fields_private_this.scala b/test/files/pos/trait_fields_private_this.scala
new file mode 100644
index 0000000000..8065cc89e6
--- /dev/null
+++ b/test/files/pos/trait_fields_private_this.scala
@@ -0,0 +1,5 @@
+trait Chars {
+ private[this] val char2uescapeArray: String = ???
+}
+
+object Chars extends Chars \ No newline at end of file
diff --git a/test/files/pos/trait_fields_static_fwd.scala b/test/files/pos/trait_fields_static_fwd.scala
new file mode 100644
index 0000000000..af2cdad9ff
--- /dev/null
+++ b/test/files/pos/trait_fields_static_fwd.scala
@@ -0,0 +1,10 @@
+trait T {
+ // Need to mark the synthesized member in the object's module class as notPROTECTED,
+ // since the trait member will receive this flag later.
+ // If we don't add notPROTECTED to the synthesized one, the member will not be seen as overriding the trait member.
+ // Therefore, addForwarders's call to membersBasedOnFlags would see the deferred member in the trait,
+ // instead of the concrete (desired) one in the class, and thus not create the static forwarder.
+ protected val propFilename: String = "/"
+}
+
+object P extends T
diff --git a/test/files/pos/trait_fields_var_override_deferred.scala b/test/files/pos/trait_fields_var_override_deferred.scala
new file mode 100644
index 0000000000..0205326506
--- /dev/null
+++ b/test/files/pos/trait_fields_var_override_deferred.scala
@@ -0,0 +1,2 @@
+trait SizeChangeEvent { protected var end: Int }
+class BackedUpListIterator[E](override protected var end: Int) extends SizeChangeEvent
diff --git a/test/files/pos/trait_fields_volatile.scala b/test/files/pos/trait_fields_volatile.scala
new file mode 100644
index 0000000000..030b24f187
--- /dev/null
+++ b/test/files/pos/trait_fields_volatile.scala
@@ -0,0 +1,13 @@
+// This test illustrates the intent of what should work (but didn't for a while during the fields refactoring),
+// but it does not actually defend against the regression seen in twitter-util's Scheduler, which I cannot reproduce
+// outside the project. The whole project consistently fails to build before, and compiles after the commit
+// that includes this test, but this single test file (as well as Scheduler.scala with external dependencies removed)
+// compiles both before and after....
+// (https://github.com/twitter/util/blob/6398a56923/util-core/src/main/scala/com/twitter/concurrent/Scheduler.scala#L260-L265)
+// There's also a run test that checks that the field in C is actually volatile.
+trait Vola {
+ @volatile private[this] var _vola = "tile"
+ @volatile var vola = "tile"
+}
+
+class C extends Vola
diff --git a/test/files/pos/trait_lazy_accessboundary.scala b/test/files/pos/trait_lazy_accessboundary.scala
new file mode 100644
index 0000000000..6529816ffb
--- /dev/null
+++ b/test/files/pos/trait_lazy_accessboundary.scala
@@ -0,0 +1,2 @@
+package foo { trait HasLazy { private[foo] lazy val myLazy = "my lady" } }
+package bar { class MixInSuperLazy extends foo.HasLazy }
diff --git a/test/files/pos/typevar-in-prefix.scala b/test/files/pos/typevar-in-prefix.scala
new file mode 100644
index 0000000000..929648b789
--- /dev/null
+++ b/test/files/pos/typevar-in-prefix.scala
@@ -0,0 +1,9 @@
+trait Test1 {
+ abstract class Setting
+ def Bool: Setting
+
+ class C[T <: Setting](val s: T)
+ val setting1 = null.asInstanceOf[_1.s.type forSome { val _1: C[Setting] }]
+ // the derived accessor for this val was not using an inferred type, as was
+ // the intention of the implementation in MethodSynthesis.
+}
diff --git a/test/files/pos/val_infer.scala b/test/files/pos/val_infer.scala
new file mode 100644
index 0000000000..5f82da8393
--- /dev/null
+++ b/test/files/pos/val_infer.scala
@@ -0,0 +1,5 @@
+class Test {
+ implicit def s2i(s: String): Int = s.length
+ trait Base { def foo: Int }
+ trait Sub extends Base { val foo = "" }
+}
diff --git a/test/files/pos/virtpatmat_exist1.scala b/test/files/pos/virtpatmat_exist1.scala
index 6cad017b0b..1f24892489 100644
--- a/test/files/pos/virtpatmat_exist1.scala
+++ b/test/files/pos/virtpatmat_exist1.scala
@@ -1,5 +1,6 @@
import annotation.unchecked.{ uncheckedVariance=> uV }
-import scala.collection.immutable.{ListMap, HashMap, ListSet, HashSet}
+import scala.collection.immutable.{ListMap, ListSet}
+import scala.collection.mutable.{HashMap, HashSet}
object Test {
class HashMapCollision1[A, +B](var hash: Int, var kvs: ListMap[A, B @uV]) extends HashMap[A, B @uV]