diff options
Diffstat (limited to 'test/files/pos')
46 files changed, 646 insertions, 14 deletions
diff --git a/test/files/pos/sammy_exist.flags b/test/files/pos/sammy_exist.flags new file mode 100644 index 0000000000..48fd867160 --- /dev/null +++ b/test/files/pos/sammy_exist.flags @@ -0,0 +1 @@ +-Xexperimental diff --git a/test/files/pos/sammy_exist.scala b/test/files/pos/sammy_exist.scala new file mode 100644 index 0000000000..f05ae20463 --- /dev/null +++ b/test/files/pos/sammy_exist.scala @@ -0,0 +1,17 @@ +// scala> typeOf[java.util.stream.Stream[_]].nonPrivateMember(TermName("map")).info +// [R](x$1: java.util.function.Function[_ >: T, _ <: R])java.util.stream.Stream[R] + +// java.util.function.Function +trait Fun[A, B] { def apply(x: A): B } + +// java.util.stream.Stream +class S[T](x: T) { def map[R](f: Fun[_ >: T, _ <: R]): R = f(x) } + +class Bla { def foo: Bla = this } + +// NOTE: inferred types show unmoored skolems, should pack them to display properly as bounded wildcards +object T { + val aBlaSAM = (new S(new Bla)).map(_.foo) + val fun: Fun[Bla, Bla] = (x: Bla) => x + val aBlaSAMX = (new S(new Bla)).map(fun) +} diff --git a/test/files/pos/sammy_overload.flags b/test/files/pos/sammy_overload.flags new file mode 100644 index 0000000000..48fd867160 --- /dev/null +++ b/test/files/pos/sammy_overload.flags @@ -0,0 +1 @@ +-Xexperimental diff --git a/test/files/pos/sammy_overload.scala b/test/files/pos/sammy_overload.scala new file mode 100644 index 0000000000..5472248f4d --- /dev/null +++ b/test/files/pos/sammy_overload.scala @@ -0,0 +1,9 @@ +trait Consumer[T] { + def consume(x: T): Unit +} + +object Test { + def foo(x: String): Unit = ??? + def foo(): Unit = ??? + val f: Consumer[_ >: String] = foo +}
\ No newline at end of file diff --git a/test/files/pos/sammy_override.flags b/test/files/pos/sammy_override.flags new file mode 100644 index 0000000000..48fd867160 --- /dev/null +++ b/test/files/pos/sammy_override.flags @@ -0,0 +1 @@ +-Xexperimental diff --git a/test/files/pos/sammy_override.scala b/test/files/pos/sammy_override.scala new file mode 100644 index 0000000000..a1d0651c39 --- /dev/null +++ b/test/files/pos/sammy_override.scala @@ -0,0 +1,8 @@ +trait IntConsumer { + def consume(x: Int): Unit +} + +object Test { + def anyConsumer(x: Any): Unit = ??? + val f: IntConsumer = anyConsumer +}
\ No newline at end of file diff --git a/test/files/pos/t3439.scala b/test/files/pos/t3439.scala new file mode 100644 index 0000000000..ccc75cc4cf --- /dev/null +++ b/test/files/pos/t3439.scala @@ -0,0 +1,26 @@ +class Base[M](i: Int) + +// was "implicit modifier not allowed on top level objects" +class D1()(implicit i: Int) extends Base({println(i); 0}) + +// what "no implicit value of type Int found" +class D2()(implicit i: Int) extends Base(implicitly[Int]) + + +abstract class ParametricMessage[M: Manifest](msg: M) { def message = msg } +case class ParametricMessage1[M: Manifest](msg: M, p1: Class[_]) extends ParametricMessage(msg) + + +class Wrap { + class Base[M](i: Int) + + // was "implicit modifier not allowed on top level objects" + class D1()(implicit i: Int) extends Base({println(i); 0}) + + // what "no implicit value of type Int found" + class D2()(implicit i: Int) extends Base(implicitly[Int]) + + + abstract class ParametricMessage[M: Manifest](msg: M) { def message = msg } + case class ParametricMessage1[M: Manifest](msg: M, p1: Class[_]) extends ParametricMessage(msg) +} diff --git a/test/files/pos/t5217.scala b/test/files/pos/t5217.scala new file mode 100644 index 0000000000..1fe3f5696f --- /dev/null +++ b/test/files/pos/t5217.scala @@ -0,0 +1,17 @@ +// private types and terms of companion module are +// available in scope of ctor params. +// before 2.10.1, class B in object A cannot be accessed in object A +object A { + private class B + private val b: B = new B + private type C = Int + def apply(): A = new A() +} +// if not private, then default arg results in: +// private class B escapes its defining scope as part of type A.B +class A private (b: A.B = A.b, c: A.C = 42) + +object C { + private class B +} +class C(b: C.B) diff --git a/test/files/pos/t5413.scala b/test/files/pos/t5413.scala new file mode 100644 index 0000000000..47af514a14 --- /dev/null +++ b/test/files/pos/t5413.scala @@ -0,0 +1,9 @@ +object Fail { + def nom (guard : => Boolean) (something : => Unit) { } + def main(args: Array[String]) { + nom { + val i = 0 + (i != 3) + }() + } +} diff --git a/test/files/pos/t5454.scala b/test/files/pos/t5454.scala new file mode 100644 index 0000000000..4045f3b57b --- /dev/null +++ b/test/files/pos/t5454.scala @@ -0,0 +1,10 @@ +object IllegalInheritance { + trait A + implicit def a = new A {} // def => val + //val r = implicitly[A] // uncomment + + class B[T](t : T)(implicit a : A) // remove implicit param block + + class C extends B/*[Int]*/(23) // uncomment + val c = new C // comment +} diff --git a/test/files/pos/t5639.flags b/test/files/pos/t5639.flags new file mode 100644 index 0000000000..0acce1e7ce --- /dev/null +++ b/test/files/pos/t5639.flags @@ -0,0 +1 @@ +-Xsource:2.12 diff --git a/test/files/pos/t5639/A_1.scala b/test/files/pos/t5639/A_1.scala new file mode 100644 index 0000000000..c5da10eae4 --- /dev/null +++ b/test/files/pos/t5639/A_1.scala @@ -0,0 +1,17 @@ +import Implicits._ + +class Baz + +object Test { + implicitly[Int] +} + +object Implicits { + implicit val Baz: Int = 0 + // This implicit was being ignored by `isQualifyingImplicit` + // if the classpath contained a class file for `class Baz`. + // This is because the package scope contains a speculative + // symbol for `object Baz` which is entered by `SymbolLoaders` + // before looking inside the class file. (A Java originated + // classfile results in the class/module symbol pair.) +} diff --git a/test/files/pos/t5639/A_2.scala b/test/files/pos/t5639/A_2.scala new file mode 100644 index 0000000000..2bb36273e0 --- /dev/null +++ b/test/files/pos/t5639/A_2.scala @@ -0,0 +1,11 @@ +import Implicits._ + +class Baz + +object Test { + implicitly[Int] +} + +object Implicits { + implicit val Baz: Int = 0 +} diff --git a/test/files/pos/t5639/Bar.scala b/test/files/pos/t5639/Bar.scala deleted file mode 100644 index f577500acd..0000000000 --- a/test/files/pos/t5639/Bar.scala +++ /dev/null @@ -1,7 +0,0 @@ -package pack.age - -import pack.age.Implicits._ - -object Quux { - def baz : Baz = 1 -} diff --git a/test/files/pos/t5639/Foo.scala b/test/files/pos/t5639/Foo.scala deleted file mode 100644 index 1a07734a8e..0000000000 --- a/test/files/pos/t5639/Foo.scala +++ /dev/null @@ -1,7 +0,0 @@ -package pack.age - -class Baz - -object Implicits { - implicit def Baz(n: Int): Baz = new Baz -} diff --git a/test/files/pos/t6051.scala b/test/files/pos/t6051.scala new file mode 100644 index 0000000000..854524feb9 --- /dev/null +++ b/test/files/pos/t6051.scala @@ -0,0 +1,19 @@ +object Foo1 { + def foo(x: Int, y: Int = 10) = x*y + lazy val y = foo(x = 20) +} + +object Foo2 { + def foo(x: Int, y: Int = 10) = x*y + val y = foo(x = 20) +} + +object Foo3 { + def foo(x: Int, y: Int = 10) = x*y + def y = foo(x = 20) +} + +object Foo4 { + def foo(x: Int, y: Int = 10) = x*y + var y = foo(x = 20) +} diff --git a/test/files/pos/t6582_exhaust_big.scala b/test/files/pos/t6582_exhaust_big.scala new file mode 100644 index 0000000000..7bb8879805 --- /dev/null +++ b/test/files/pos/t6582_exhaust_big.scala @@ -0,0 +1,33 @@ +sealed abstract class Z +object Z { + object Z0 extends Z + case class Z1() extends Z + object Z2 extends Z + case class Z3() extends Z + object Z4 extends Z + case class Z5() extends Z + object Z6 extends Z + case class Z7() extends Z + object Z8 extends Z + case class Z9() extends Z + object Z10 extends Z + case class Z11() extends Z + object Z12 extends Z + case class Z13() extends Z + object Z14 extends Z + case class Z15() extends Z + object Z16 extends Z + case class Z17() extends Z + object Z18 extends Z + case class Z19() extends Z +} + +// drop any case and it will report an error +object Test { + import Z._ + def foo(z: Z) = z match { + case Z0 | Z1() | Z2 | Z3() | Z4 | Z5() | Z6 | Z7() | Z8 | Z9() | + Z10 | Z11() | Z12 | Z13() | Z14 | Z15() | Z16 | Z17() | Z18 | Z19() + => + } +} diff --git a/test/files/pos/t7596/A_1.scala b/test/files/pos/t7596/A_1.scala new file mode 100644 index 0000000000..6303c6d132 --- /dev/null +++ b/test/files/pos/t7596/A_1.scala @@ -0,0 +1,10 @@ +trait Driver { + abstract class Table +} + +object Config { + val driver : Driver = ??? + def driver(a: Any) = ??? +} + +object Sites extends Config.driver.Table diff --git a/test/files/pos/t7596/B_2.scala b/test/files/pos/t7596/B_2.scala new file mode 100644 index 0000000000..977e5c8bd1 --- /dev/null +++ b/test/files/pos/t7596/B_2.scala @@ -0,0 +1,19 @@ +object Test { + locally { + Sites: Config.driver.Table + } +} + +// Under separate compilation, the pickler is foiled by the +// overloaded term `Config.driver`, and results in: + +// qbin/scalac test/files/pos/t7596/A_1.scala && qbin/scalac -explaintypes test/files/pos/t7596/B_2.scala +// test/files/pos/t7596/B_2.scala:3: error: type mismatch; +// found : Sites.type +// required: Config.driver.Table +// Sites: Config.driver.Table +// ^ +// Sites.type <: Config.driver.Table? +// Driver.this.type = Config.driver.type? +// false +// false
\ No newline at end of file diff --git a/test/files/pos/t7596b/A.scala b/test/files/pos/t7596b/A.scala new file mode 100644 index 0000000000..65c1bc56ef --- /dev/null +++ b/test/files/pos/t7596b/A.scala @@ -0,0 +1,10 @@ +trait H2Driver{ + abstract class Table[T] +} + +object Config { + val driver : H2Driver = ??? + def driver(app: Any): H2Driver = ??? +} + +class Sites extends Config.driver.Table[String] diff --git a/test/files/pos/t7596b/B.scala b/test/files/pos/t7596b/B.scala new file mode 100644 index 0000000000..cbcf149c23 --- /dev/null +++ b/test/files/pos/t7596b/B.scala @@ -0,0 +1,6 @@ +class DAOBase[E]{ + type TableType <: Config.driver.Table[E] +} +class SitesDAO extends DAOBase[String]{ + type TableType = Sites +} diff --git a/test/files/pos/t7596c/A_1.scala b/test/files/pos/t7596c/A_1.scala new file mode 100644 index 0000000000..3e366df477 --- /dev/null +++ b/test/files/pos/t7596c/A_1.scala @@ -0,0 +1,11 @@ +trait Driver { + abstract class Table +} + +object Config { + val driver : Driver = ??? + val driverUniqueName: driver.type = driver + def driver(a: Any) = ??? +} + +object Sites extends Config.driver.Table diff --git a/test/files/pos/t7596c/B_2.scala b/test/files/pos/t7596c/B_2.scala new file mode 100644 index 0000000000..33da68c1ff --- /dev/null +++ b/test/files/pos/t7596c/B_2.scala @@ -0,0 +1,9 @@ +object Test { + locally { + Sites: Config.driver.Table + } +} + +// This variation worked by avoiding referring to the +// overloaded term `Config.driver` in the parent type of +// Sites
\ No newline at end of file diff --git a/test/files/pos/t7683-stop-after-parser/ThePlugin.scala b/test/files/pos/t7683-stop-after-parser/ThePlugin.scala new file mode 100644 index 0000000000..cd800781dc --- /dev/null +++ b/test/files/pos/t7683-stop-after-parser/ThePlugin.scala @@ -0,0 +1,31 @@ +package scala.test.plugins + +import scala.tools.nsc +import nsc.Global +import nsc.Phase +import nsc.plugins.Plugin +import nsc.plugins.PluginComponent + +class ThePlugin(val global: Global) extends Plugin { + import global._ + + val name = "timebomb" + val description = "Explodes if run. Maybe I haven't implemented it yet." + val components = List[PluginComponent](thePhase1) + + private object thePhase1 extends PluginComponent { + val global = ThePlugin.this.global + + val runsAfter = List[String]("parser") + override val runsBefore = List[String]("namer") + val phaseName = ThePlugin.this.name + + def newPhase(prev: Phase) = new ThePhase(prev) + } + + private class ThePhase(prev: Phase) extends Phase(prev) { + override def name = ThePlugin.this.name + override def run = ??? + } +} + diff --git a/test/files/pos/t7683-stop-after-parser/sample_2.flags b/test/files/pos/t7683-stop-after-parser/sample_2.flags new file mode 100644 index 0000000000..99672cdfd3 --- /dev/null +++ b/test/files/pos/t7683-stop-after-parser/sample_2.flags @@ -0,0 +1 @@ +-Xplugin:. -Xplugin-require:timebomb -Ystop-after:parser diff --git a/test/files/pos/t7683-stop-after-parser/sample_2.scala b/test/files/pos/t7683-stop-after-parser/sample_2.scala new file mode 100644 index 0000000000..7eb11b8204 --- /dev/null +++ b/test/files/pos/t7683-stop-after-parser/sample_2.scala @@ -0,0 +1,6 @@ + +package sample + +// just a sample that is compiled with the explosive plugin disabled +object Sample extends App { +} diff --git a/test/files/pos/t7683-stop-after-parser/scalac-plugin.xml b/test/files/pos/t7683-stop-after-parser/scalac-plugin.xml new file mode 100644 index 0000000000..2558d6fd03 --- /dev/null +++ b/test/files/pos/t7683-stop-after-parser/scalac-plugin.xml @@ -0,0 +1,5 @@ +<plugin> + <name>ignored</name> + <classname>scala.test.plugins.ThePlugin</classname> +</plugin> + diff --git a/test/files/pos/t7750.flags b/test/files/pos/t7750.flags new file mode 100644 index 0000000000..b216e74c97 --- /dev/null +++ b/test/files/pos/t7750.flags @@ -0,0 +1 @@ +-Xfatal-warnings -feature diff --git a/test/files/pos/t7750.scala b/test/files/pos/t7750.scala new file mode 100644 index 0000000000..befec76949 --- /dev/null +++ b/test/files/pos/t7750.scala @@ -0,0 +1,8 @@ +trait LazyCombiner[Elem, +To, Buff <: Growable[Elem] with Sizing] +trait Growable[T] +trait Sizing + + +object Test { + null.isInstanceOf[LazyCombiner[_, _, _]] // issued an existential feature warning +} diff --git a/test/files/pos/t8310.flags b/test/files/pos/t8310.flags new file mode 100644 index 0000000000..48fd867160 --- /dev/null +++ b/test/files/pos/t8310.flags @@ -0,0 +1 @@ +-Xexperimental diff --git a/test/files/pos/t8310.scala b/test/files/pos/t8310.scala new file mode 100644 index 0000000000..874caf4d3b --- /dev/null +++ b/test/files/pos/t8310.scala @@ -0,0 +1,22 @@ +trait Comparinator[T] { def compare(a: T, b: T): Int } + +object TestOkay { + def sort(x: Comparinator[_ >: String]) = () + sort((a: String, b: String) => a.compareToIgnoreCase(b)) +} + +object TestOkay2 { + def sort[T](x: Comparinator[_ >: T]) = () + sort((a: String, b: String) => a.compareToIgnoreCase(b)) +} + +object TestOkay3 { + def sort[T](xs: Option[T], x: Comparinator[_ >: T]) = () + sort(Some(""), (a: String, b: String) => a.compareToIgnoreCase(b)) +} + +object TestKoOverloaded { + def sort[T](xs: Option[T]) = () + def sort[T](xs: Option[T], x: Comparinator[_ >: T]) = () + sort(Some(""), (a: String, b: String) => a.compareToIgnoreCase(b)) +} diff --git a/test/files/pos/t8893.scala b/test/files/pos/t8893.scala new file mode 100644 index 0000000000..b87c8bdd3c --- /dev/null +++ b/test/files/pos/t8893.scala @@ -0,0 +1,129 @@ +// Took > 10 minutes to run the tail call phase. +object Test { + def a(): Option[String] = Some("a") + + def main(args: Array[String]) { + a() match { + case Some(b1) => + a() match { + case Some(b2) => + a() match { + case Some(b3) => + a() match { + case Some(b4) => + a() match { + case Some(b5) => + a() match { + case Some(b6) => + a() match { + case Some(b7) => + a() match { + case Some(b8) => + a() match { + case Some(b9) => + a() match { + case Some(b10) => + a() match { + case Some(b11) => + a() match { + case Some(b12) => + a() match { + case Some(b13) => + a() match { + case Some(b14) => + a() match { + case Some(b15) => + a() match { + case Some(b16) => + a() match { + case Some(b17) => + a() match { + case Some(b18) => + a() match { + case Some(b19) => + a() match { + case Some(b20) => + a() match { + case Some(b21) => + a() match { + case Some(b22) => + a() match { + case Some(b23) => + a() match { + case Some(b24) => + a() match { + case Some(b25) => + a() match { + case Some(b26) => + a() match { + case Some(b27) => + a() match { + case Some(b28) => + a() match { + case Some(b29) => + a() match { + case Some(b30) => + println("yay") + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + case None => None + } + } +} + diff --git a/test/files/pos/t8900.scala b/test/files/pos/t8900.scala new file mode 100644 index 0000000000..376bd786f2 --- /dev/null +++ b/test/files/pos/t8900.scala @@ -0,0 +1,11 @@ +package foo +package lambdaking + +class Test { + def byname(b: => Any) = ??? + def foo: Any = { + def bar: Any = { + byname(bar) + } + } +} diff --git a/test/files/pos/t8934a/A_1.scala b/test/files/pos/t8934a/A_1.scala new file mode 100644 index 0000000000..6c1f29d030 --- /dev/null +++ b/test/files/pos/t8934a/A_1.scala @@ -0,0 +1,18 @@ +import language.experimental.macros +import reflect.macros.whitebox.Context + +object Unapply { + def impl1(c: Context)(a: c.Tree): c.Tree = { + import c.universe._ + q"(new { def unapply[T](a: String): Option[(Int, String)] = ??? }).unapply($a)" + } + def unapply(a: Any): Any = macro impl1 +} + +object UnapplySeq { + def impl1(c: Context)(a: c.Tree): c.Tree = { + import c.universe._ + q"(new { def unapplySeq[T](a: String): Option[(Int, Seq[String])] = ??? }).unapplySeq($a)" + } + def unapplySeq(a: Any): Any = macro impl1 +} diff --git a/test/files/pos/t8934a/Test_2.flags b/test/files/pos/t8934a/Test_2.flags new file mode 100644 index 0000000000..618dfe2b75 --- /dev/null +++ b/test/files/pos/t8934a/Test_2.flags @@ -0,0 +1 @@ +-Ystop-after:typer -Ymacro-expand:discard -nowarn diff --git a/test/files/pos/t8934a/Test_2.scala b/test/files/pos/t8934a/Test_2.scala new file mode 100644 index 0000000000..e1792ed3c5 --- /dev/null +++ b/test/files/pos/t8934a/Test_2.scala @@ -0,0 +1,12 @@ +object Test { + "" match { + case Unapply(a, b) => + a: Int + b: String + case UnapplySeq(a, b1, b2) => + a: Int + b1: String + b2: String + } +} +// These used to fail `too many patterns` under -Ymacro-expand:discard diff --git a/test/files/pos/t8947/Client_2.scala b/test/files/pos/t8947/Client_2.scala new file mode 100644 index 0000000000..1a5082a2f9 --- /dev/null +++ b/test/files/pos/t8947/Client_2.scala @@ -0,0 +1 @@ +object Test { X.extractor }
\ No newline at end of file diff --git a/test/files/pos/t8947/Macro_1.scala b/test/files/pos/t8947/Macro_1.scala new file mode 100644 index 0000000000..4a5de3decb --- /dev/null +++ b/test/files/pos/t8947/Macro_1.scala @@ -0,0 +1,41 @@ +import language.experimental.macros +import scala.reflect.macros._ +import blackbox.Context + +object X { + + def classTagOrNull[T](implicit t: reflect.ClassTag[T] = null) = t + // the failed search for ClassTag[T] does not issue a visible + // error as we fall back to the default argument. But, the + // macro engine things we have expanded the macro `materializeClassTag[D]()` + // to `EmptyTree`, and then attaches a backreference from the expansion + // to the expandee. This is the `MacroExpansionAttachment` tree attachment. + def foo[D] = classTagOrNull[D] + + def extractor: Any = macro X.extractorMacro + def extractorMacro(c: Context): c.Expr[Any] = { + // Later, in reify, an unrelated use of `EmptyTree` in the AST representing + // the argument is now treated as a macro expansion which should be rolled + // back in the tree we reify! This ends up generating a call to `implicitly` + // which leads to an ambiguous error. + // + // Any macro call that expands to EmptyTree could have triggered this problem. + c.universe.reify(new { def something(data: Any) = ??? }) + } + + // Workarounds: + // + // 1. Use quasiquotes rather than `reify`. (But, beware to fully qualify all references, e.g. `_root_.scala.Predef.???`) + // 2. Avoid failed ClassTag lookups (e.g. in the original bug report, annotate the type argument to `map`) + // 3. In the macro implementation, just before calling the `reify` macro, you could call another macro + // + // def prepareReify = macro prepareReifyImpl + // def prepareReifyImpl(c: Context) = { + // val symtab = c.universe.asInstanceOf[reflect.internal.SymbolTable] + // symtab.EmptyTree.setAttachments(symtab.NoPosition) + // } + // + // To make this visible to the macro implementaiton, it will need to be compiled in an earlier stage, + // e.g a separate SBT sub-project. + +} diff --git a/test/files/pos/t8954.flags b/test/files/pos/t8954.flags new file mode 100644 index 0000000000..7de3c0f3ee --- /dev/null +++ b/test/files/pos/t8954.flags @@ -0,0 +1 @@ +-Xfatal-warnings -deprecation diff --git a/test/files/pos/t8954/t1.scala b/test/files/pos/t8954/t1.scala new file mode 100644 index 0000000000..3986d9f3b5 --- /dev/null +++ b/test/files/pos/t8954/t1.scala @@ -0,0 +1,13 @@ +package scala.foo + +// 1. a class about to be made final +@deprecatedInheritance class A { + def foo(): Unit = ??? +} + +// 1.1: +// - no inheritance warning because same file +// - no "override non-deprecated member" because @deprecatedInheritance +class B2 extends A { + @deprecated("","") override def foo(): Unit = ??? +} diff --git a/test/files/pos/t8954/t2.scala b/test/files/pos/t8954/t2.scala new file mode 100644 index 0000000000..4def127832 --- /dev/null +++ b/test/files/pos/t8954/t2.scala @@ -0,0 +1,39 @@ +package scala.foo + +// 1.2 deprecated children should be fine... +@deprecated("", "") class B extends A { + + // 1.3 and shouldn't trigger the + // "overriding non-deprecated parent" warning + override def foo(): Unit = ??? +} + +@deprecated("","") class F { + // 1.4 a class inside a deprecated class should work too + class G extends A +} + +// 2. a method about to be made final +class C { + @deprecatedOverriding def foo(): Unit = ??? +} + +// 2.1 overriding with a deprecated def should be fine +// and also shoudln't trigger the "deprecation is useless" +// warning +class D extends C { + @deprecated("","") override def foo(): Unit = ??? +} + +// 2.2 overriding from a deprecated class should be fine +@deprecated("","") class E extends C { + override def foo(): Unit = ??? +} + +// 2.3 overriding from deeper inside a deprecated class +// should work too +@deprecated("","") class H { + class I extends C { + override def foo(): Unit = ??? + } +} diff --git a/test/files/pos/t8962.scala b/test/files/pos/t8962.scala new file mode 100644 index 0000000000..4331c154ba --- /dev/null +++ b/test/files/pos/t8962.scala @@ -0,0 +1,31 @@ +package test.nestedcov + +sealed abstract class Outer[+A] +case class Let[+A](expr: Outer[Inner[A]]) extends Outer[A] + +sealed abstract class Inner[+A] + +sealed abstract class Outer2[+A, +B] +case class Let2[+A](expr: Outer2[Inner2[A], A]) extends Outer2[A, A] + +sealed abstract class Inner2[+A] + +sealed abstract class Outer3[+A, +B] +case class Let3[+A](expr: Outer3[A, A]) extends Outer3[A, A] + +object NestedCov { + def run[A](nc: Outer[A]) = nc match { + case Let(expr) => + expr : Outer[Inner[A]] + } + + def run2[A](nc: Outer2[A, A]) = nc match { + case Let2(expr) => + expr : Outer2[Inner2[A], A] + } + + def run3[A](nc: Outer3[A, A]) = nc match { + case Let3(expr) => + expr : Outer3[A, A] + } +} diff --git a/test/files/pos/t8965.flags b/test/files/pos/t8965.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/t8965.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t8965.scala b/test/files/pos/t8965.scala new file mode 100644 index 0000000000..4f39330f4e --- /dev/null +++ b/test/files/pos/t8965.scala @@ -0,0 +1,7 @@ +class A { + def f(x: Any with AnyRef, y: Any with AnyRef) = x eq y + // a.scala:2: warning: Any and Any are unrelated: they will most likely never compare equal + // def f(x: Any with AnyRef, y: Any with AnyRef) = x eq y + // ^ + // one warning found +} diff --git a/test/files/pos/t9008.scala b/test/files/pos/t9008.scala new file mode 100644 index 0000000000..d11b8604f2 --- /dev/null +++ b/test/files/pos/t9008.scala @@ -0,0 +1,5 @@ +trait Monad[M[_]] + +object Test { + def x: Monad[M forSome { type M[_] }] = ??? +} diff --git a/test/files/pos/t9018.scala b/test/files/pos/t9018.scala new file mode 100644 index 0000000000..7fb4cf21b3 --- /dev/null +++ b/test/files/pos/t9018.scala @@ -0,0 +1,16 @@ +object TestObject { + + def m(i: Int): AnyRef = i match { + case 0 => new C() + case 1 => Some(E.A).getOrElse("") + } + + class C extends Ordered[C] { + def compare(that: C): Int = ??? + } + + object E extends Enumeration { + type CharacterClass = Value + val A = Value + } +} |