diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/macro-without-xmacros-a.check | 6 | ||||
-rw-r--r-- | test/files/neg/macro-without-xmacros-b.check | 6 | ||||
-rw-r--r-- | test/files/neg/t414.check | 2 | ||||
-rw-r--r-- | test/files/neg/t4879.check | 4 | ||||
-rw-r--r-- | test/files/neg/t6040.check | 2 | ||||
-rw-r--r-- | test/files/neg/t6952.check | 4 | ||||
-rw-r--r-- | test/files/neg/t7330.check | 5 | ||||
-rw-r--r-- | test/files/neg/t7330.scala | 5 | ||||
-rw-r--r-- | test/files/neg/t7388.check | 4 | ||||
-rw-r--r-- | test/files/neg/t7388.scala | 1 | ||||
-rwxr-xr-x | test/files/pos/spec-t6286.scala | 10 | ||||
-rw-r--r-- | test/files/pos/t7200b.scala | 50 | ||||
-rw-r--r-- | test/files/pos/t7329.scala | 1 | ||||
-rw-r--r-- | test/files/pos/t7377/Client_2.scala | 11 | ||||
-rw-r--r-- | test/files/pos/t7377/Macro_1.scala | 7 | ||||
-rw-r--r-- | test/files/pos/t7377b.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t7377b.scala | 13 | ||||
-rw-r--r-- | test/files/pos/xlint1.flags | 1 | ||||
-rw-r--r-- | test/files/pos/xlint1.scala | 13 | ||||
-rw-r--r-- | test/files/run/t7200.scala | 34 | ||||
-rw-r--r-- | test/files/run/t7319.check | 38 | ||||
-rw-r--r-- | test/files/run/t7319.scala | 13 |
22 files changed, 219 insertions, 12 deletions
diff --git a/test/files/neg/macro-without-xmacros-a.check b/test/files/neg/macro-without-xmacros-a.check index ae6c6c695a..ec194be3a9 100644 --- a/test/files/neg/macro-without-xmacros-a.check +++ b/test/files/neg/macro-without-xmacros-a.check @@ -1,5 +1,5 @@ Macros_2.scala:5: error: macro definition needs to be enabled -by making the implicit value language.experimental.macros visible. +by making the implicit value scala.language.experimental.macros visible. This can be achieved by adding the import clause 'import scala.language.experimental.macros' or by setting the compiler option -language:experimental.macros. See the Scala docs for value scala.language.experimental.macros for a discussion @@ -7,11 +7,11 @@ why the feature needs to be explicitly enabled. def foo(x: Int): Int = macro foo_impl ^ Macros_2.scala:7: error: macro definition needs to be enabled -by making the implicit value language.experimental.macros visible. +by making the implicit value scala.language.experimental.macros visible. def bar(x: Int): Int = macro bar_impl ^ Macros_2.scala:11: error: macro definition needs to be enabled -by making the implicit value language.experimental.macros visible. +by making the implicit value scala.language.experimental.macros visible. def quux(x: Int): Int = macro quux_impl ^ three errors found diff --git a/test/files/neg/macro-without-xmacros-b.check b/test/files/neg/macro-without-xmacros-b.check index c3cadcf36a..c97850f0a9 100644 --- a/test/files/neg/macro-without-xmacros-b.check +++ b/test/files/neg/macro-without-xmacros-b.check @@ -1,5 +1,5 @@ Macros_2.scala:3: error: macro definition needs to be enabled -by making the implicit value language.experimental.macros visible. +by making the implicit value scala.language.experimental.macros visible. This can be achieved by adding the import clause 'import scala.language.experimental.macros' or by setting the compiler option -language:experimental.macros. See the Scala docs for value scala.language.experimental.macros for a discussion @@ -7,11 +7,11 @@ why the feature needs to be explicitly enabled. def foo(x: Int): Int = macro Impls.foo_impl ^ Macros_2.scala:5: error: macro definition needs to be enabled -by making the implicit value language.experimental.macros visible. +by making the implicit value scala.language.experimental.macros visible. def bar(x: Int): Int = macro Impls.bar_impl ^ Macros_2.scala:9: error: macro definition needs to be enabled -by making the implicit value language.experimental.macros visible. +by making the implicit value scala.language.experimental.macros visible. def quux(x: Int): Int = macro Impls.quux_impl ^ three errors found diff --git a/test/files/neg/t414.check b/test/files/neg/t414.check index e15dbaea71..30211eef8e 100644 --- a/test/files/neg/t414.check +++ b/test/files/neg/t414.check @@ -1,7 +1,7 @@ t414.scala:5: error: pattern type is incompatible with expected type; found : Empty.type required: IntMap[a] -Note: if you intended to match against the class, try `case _: Empty[_]` or `case Empty()` +Note: if you intended to match against the class, try `case Empty()` case Empty => ^ t414.scala:7: error: type mismatch; diff --git a/test/files/neg/t4879.check b/test/files/neg/t4879.check index 21cd329640..c7edd583c8 100644 --- a/test/files/neg/t4879.check +++ b/test/files/neg/t4879.check @@ -1,13 +1,13 @@ t4879.scala:6: error: pattern type is incompatible with expected type; found : C.type required: C -Note: if you intended to match against the class, try `case _: C` or `case C(_)` +Note: if you intended to match against the class, try `case C(_)` case C => true ^ t4879.scala:10: error: pattern type is incompatible with expected type; found : D.type required: D[T,U,V] -Note: if you intended to match against the class, try `case _: D[_,_,_]` or `case D(_,_,_)` +Note: if you intended to match against the class, try `case D(_,_,_)` case D => true ^ two errors found diff --git a/test/files/neg/t6040.check b/test/files/neg/t6040.check index f91df0c46d..16c90ede7e 100644 --- a/test/files/neg/t6040.check +++ b/test/files/neg/t6040.check @@ -1,5 +1,5 @@ t6040.scala:1: error: extension of type scala.Dynamic needs to be enabled -by making the implicit value language.dynamics visible. +by making the implicit value scala.language.dynamics visible. This can be achieved by adding the import clause 'import scala.language.dynamics' or by setting the compiler option -language:dynamics. See the Scala docs for value scala.language.dynamics for a discussion diff --git a/test/files/neg/t6952.check b/test/files/neg/t6952.check index f1e1881404..1a591d02c6 100644 --- a/test/files/neg/t6952.check +++ b/test/files/neg/t6952.check @@ -1,5 +1,5 @@ t6952.scala:2: error: extension of type scala.Dynamic needs to be enabled -by making the implicit value language.dynamics visible. +by making the implicit value scala.language.dynamics visible. This can be achieved by adding the import clause 'import scala.language.dynamics' or by setting the compiler option -language:dynamics. See the Scala docs for value scala.language.dynamics for a discussion @@ -7,7 +7,7 @@ why the feature needs to be explicitly enabled. trait B extends Dynamic ^ t6952.scala:3: error: extension of type scala.Dynamic needs to be enabled -by making the implicit value language.dynamics visible. +by making the implicit value scala.language.dynamics visible. trait C extends A with Dynamic ^ two errors found diff --git a/test/files/neg/t7330.check b/test/files/neg/t7330.check new file mode 100644 index 0000000000..b96d656d2b --- /dev/null +++ b/test/files/neg/t7330.check @@ -0,0 +1,5 @@ +t7330.scala:4: error: pattern must be a value: Y[_] +Note: if you intended to match against the class, try `case _: Y[_]` + 0 match { case Y[_] => } + ^ +one error found diff --git a/test/files/neg/t7330.scala b/test/files/neg/t7330.scala new file mode 100644 index 0000000000..13a943a02b --- /dev/null +++ b/test/files/neg/t7330.scala @@ -0,0 +1,5 @@ +class Y[T] +class Test { + // TypeTree is not a valid tree for a pattern + 0 match { case Y[_] => } +}
\ No newline at end of file diff --git a/test/files/neg/t7388.check b/test/files/neg/t7388.check new file mode 100644 index 0000000000..0a29e04896 --- /dev/null +++ b/test/files/neg/t7388.check @@ -0,0 +1,4 @@ +t7388.scala:1: error: doesnotexist is not an enclosing class +class Test private[doesnotexist]() + ^ +one error found diff --git a/test/files/neg/t7388.scala b/test/files/neg/t7388.scala new file mode 100644 index 0000000000..9ce9ea11b3 --- /dev/null +++ b/test/files/neg/t7388.scala @@ -0,0 +1 @@ +class Test private[doesnotexist]() diff --git a/test/files/pos/spec-t6286.scala b/test/files/pos/spec-t6286.scala new file mode 100755 index 0000000000..4d87998ec6 --- /dev/null +++ b/test/files/pos/spec-t6286.scala @@ -0,0 +1,10 @@ +trait Foo[@specialized(Int) A] { + def fun[@specialized(Int) B](init: B)(f: (B, A) => B): B +} + +class Bar(values: Array[Int]) extends Foo[Int] { + def fun[@specialized(Int) C](init: C)(f: (C, Int) => C): C = { + val arr = values + f(init, arr(0)) + } +} diff --git a/test/files/pos/t7200b.scala b/test/files/pos/t7200b.scala new file mode 100644 index 0000000000..9d579c6ef9 --- /dev/null +++ b/test/files/pos/t7200b.scala @@ -0,0 +1,50 @@ +import language.higherKinds + +trait T { + def t = 0 +} +trait Foo { + def coflatMap[A <: T](f: A): A +} + +object O extends Foo { + def coflatMap[A <: T](f: A) = { + val f2 = coflatMap(f) // inferred in 2.9.2 / 2.10.0 as [Nothing] + f2.t // so this does't type check. + f2 + } +} + +// Why? When a return type is inherited, the derived method +// symbol first gets a preliminary type assigned, based on the +// 1) method type of a unique matching super member +// 2) viewed as a member type of the inheritor (to substitute, +// e.g. class type parameters) +// 3) substituted to replace the super-method's type parameters +// with those of the inheritor +// 4) dissected to take just the return type wrapped in thisMethodType(). +// +// In Scala 2.10.0 and earlier, this preliminary method type +// +// 1) [A#11329 <: <empty>#3.this.T#7068](<param> f#11333: A#11329)A#11329 +// 2) [A#11329 <: <empty>#3.this.T#7068](<param> f#11333: A#11329)A#11329 +// 3) (<param> f#12556: A#11336)A#11336 +// 4) [A#11336 <: <empty>#3.this.T#7068](<param> f#12552: A#11337&0)A#11336 +// +// The type #4 from the old version is problematic: the parameter is typed with +// a skolem for the type parameter `A`. It won't be considered to match the +// method it overrides, instead they are seen as being overloaded, and type inference +// goes awry (Nothing is inferred as the type argument for the recursive call +// to coflatMap. +// +// The Namers patch adds one step here: it subsitutes the type parameter symbols +// for the skolems: +// +// https://github.com/scala/scala/commit/b74c33eb#L2R1014 +// +// So we end up with a method symbol info: +// +// 5) [A#11336 <: <empty>#3.this.T#7068](<param> f#12505: A#11336)A#11336 +// +// This *does* match the method in the super class, and type inference +// chooses the correct type argument.
\ No newline at end of file diff --git a/test/files/pos/t7329.scala b/test/files/pos/t7329.scala new file mode 100644 index 0000000000..76bf1fb9f5 --- /dev/null +++ b/test/files/pos/t7329.scala @@ -0,0 +1 @@ +class TwoParamSpecializedWithDefault[@specialized A, @specialized B](a: A, b: B = (??? : B))
\ No newline at end of file diff --git a/test/files/pos/t7377/Client_2.scala b/test/files/pos/t7377/Client_2.scala new file mode 100644 index 0000000000..5728956cca --- /dev/null +++ b/test/files/pos/t7377/Client_2.scala @@ -0,0 +1,11 @@ +object Test { + M.noop(List(1) match { case Nil => 0; case (x::xs) => x }) + + case class Foo(a: Int) + val FooAlias: Foo.type = Foo + M.noop(Foo(0) match { case FooAlias(_) => 0 }) + + case class Bar() + val BarAlias: Bar.type = Bar + M.noop(Bar() match { case BarAlias() => 0 }) +} diff --git a/test/files/pos/t7377/Macro_1.scala b/test/files/pos/t7377/Macro_1.scala new file mode 100644 index 0000000000..a0ec1d84af --- /dev/null +++ b/test/files/pos/t7377/Macro_1.scala @@ -0,0 +1,7 @@ +import language.experimental._ +import reflect.macros.Context + +object M { + def noopImpl[A](c: Context)(expr: c.Expr[A]): c.Expr[A] = c.Expr(c.typeCheck(c.resetLocalAttrs(expr.tree))) + def noop[A](expr: A): A = macro noopImpl[A] +} diff --git a/test/files/pos/t7377b.flags b/test/files/pos/t7377b.flags new file mode 100644 index 0000000000..cb8324a345 --- /dev/null +++ b/test/files/pos/t7377b.flags @@ -0,0 +1 @@ +-Xoldpatmat
\ No newline at end of file diff --git a/test/files/pos/t7377b.scala b/test/files/pos/t7377b.scala new file mode 100644 index 0000000000..aeee800d57 --- /dev/null +++ b/test/files/pos/t7377b.scala @@ -0,0 +1,13 @@ +object Test { + List(1) match { case Nil => 0; case (x::xs) => x } + + case class Foo(a: Int) + val FooAlias: Foo.type = Foo + Foo(0) match { case FooAlias(_) => 0 } + Foo(0) match { case Foo(_) => 0 } + + case class Bar() + val BarAlias: Bar.type = Bar + Bar() match { case BarAlias() => 0 } + Bar() match { case Bar() => 0 } +} diff --git a/test/files/pos/xlint1.flags b/test/files/pos/xlint1.flags new file mode 100644 index 0000000000..7949c2afa2 --- /dev/null +++ b/test/files/pos/xlint1.flags @@ -0,0 +1 @@ +-Xlint -Xfatal-warnings diff --git a/test/files/pos/xlint1.scala b/test/files/pos/xlint1.scala new file mode 100644 index 0000000000..27936d8b14 --- /dev/null +++ b/test/files/pos/xlint1.scala @@ -0,0 +1,13 @@ +package object foo { + implicit class Bar[T](val x: T) extends AnyVal { + def bippy = 1 + } +} + +package foo { + object Baz { + def main(args: Array[String]): Unit = { + "abc".bippy + } + } +} diff --git a/test/files/run/t7200.scala b/test/files/run/t7200.scala new file mode 100644 index 0000000000..ba342df14d --- /dev/null +++ b/test/files/run/t7200.scala @@ -0,0 +1,34 @@ +import language.higherKinds + +object Test extends App { + + // Slice of comonad is where this came up + trait Foo[F[_]] { + def coflatMap[A, B](f: F[A] => B): F[A] => F[B] + } + + // A non-empty list + case class Nel[A](head: A, tail: List[A]) + + object NelFoo extends Foo[Nel] { + + // It appears that the return type for recursive calls is not inferred + // properly, yet no warning is issued. Providing a return type or + // type arguments for the recursive call fixes the problem. + + def coflatMap[A, B](f: Nel[A] => B) = // ok w/ return type + l => Nel(f(l), l.tail match { + case Nil => Nil + case h :: t => { + val r = coflatMap(f)(Nel(h, t)) // ok w/ type args + r.head :: r.tail + } + }) + } + + // Without a recursive call all is well, but with recursion we get a + // ClassCastException from Integer to Nothing + NelFoo.coflatMap[Int, Int](_.head + 1)(Nel(1, Nil)) // Ok + NelFoo.coflatMap[Int, Int](_.head + 1)(Nel(1, List(2))) // CCE + +} diff --git a/test/files/run/t7319.check b/test/files/run/t7319.check new file mode 100644 index 0000000000..966736915e --- /dev/null +++ b/test/files/run/t7319.check @@ -0,0 +1,38 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> + +scala> class M[A] +defined class M + +scala> implicit def ma0[A](a: A): M[A] = null +warning: there were 1 feature warning(s); re-run with -feature for details +ma0: [A](a: A)M[A] + +scala> implicit def ma1[A](a: A): M[A] = null +warning: there were 1 feature warning(s); re-run with -feature for details +ma1: [A](a: A)M[A] + +scala> def convert[F[X <: F[X]]](builder: F[_ <: F[_]]) = 0 +warning: there were 1 feature warning(s); re-run with -feature for details +convert: [F[X <: F[X]]](builder: F[_ <: F[_]])Int + +scala> convert(Some[Int](0)) +<console>:12: error: no type parameters for method convert: (builder: F[_ <: F[_]])Int exist so that it can be applied to arguments (Some[Int]) + --- because --- +argument expression's type is not compatible with formal parameter type; + found : Some[Int] + required: ?F forSome { type _$1 <: ?F forSome { type _$2 } } + convert(Some[Int](0)) + ^ +<console>:12: error: type mismatch; + found : Some[Int] + required: F[_ <: F[_]] + convert(Some[Int](0)) + ^ + +scala> 0 +res1: Int = 0 + +scala> diff --git a/test/files/run/t7319.scala b/test/files/run/t7319.scala new file mode 100644 index 0000000000..23ffeb977d --- /dev/null +++ b/test/files/run/t7319.scala @@ -0,0 +1,13 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + // so we can provide the ambiguities, rather than relying in Predef implicits + override def extraSettings = "-Yno-predef" + override def code = """ +class M[A] +implicit def ma0[A](a: A): M[A] = null +implicit def ma1[A](a: A): M[A] = null +def convert[F[X <: F[X]]](builder: F[_ <: F[_]]) = 0 +convert(Some[Int](0)) +0""" // before the fix, this line, and all that followed, re-issued the implicit ambiguity error. +} |