diff options
author | Samuel Gruetter <samuel.gruetter@epfl.ch> | 2014-03-19 17:53:49 +0100 |
---|---|---|
committer | Samuel Gruetter <samuel.gruetter@epfl.ch> | 2014-03-19 17:53:49 +0100 |
commit | d51d08b444e0ea4a2c13b4daf0ce14b53bfbad89 (patch) | |
tree | 1d3a66fc0f5f839a561a2987159cb5b841b89257 /tests/untried/neg | |
parent | 24ac35546c2c159403e91144e0e4add585ee9ae5 (diff) | |
download | dotty-d51d08b444e0ea4a2c13b4daf0ce14b53bfbad89.tar.gz dotty-d51d08b444e0ea4a2c13b4daf0ce14b53bfbad89.tar.bz2 dotty-d51d08b444e0ea4a2c13b4daf0ce14b53bfbad89.zip |
move all tests in tests/untried/neg which use implicits to tests/untried/neg-with-implicits
Diffstat (limited to 'tests/untried/neg')
113 files changed, 0 insertions, 2914 deletions
diff --git a/tests/untried/neg/classmanifests_new_deprecations.scala b/tests/untried/neg/classmanifests_new_deprecations.scala deleted file mode 100644 index 7aebf011f..000000000 --- a/tests/untried/neg/classmanifests_new_deprecations.scala +++ /dev/null @@ -1,37 +0,0 @@ -object Test extends App { - def cm1[T: ClassManifest] = ??? - def cm2[T](implicit evidence$1: ClassManifest[T]) = ??? - val cm3: ClassManifest[Int] = null - - def rcm1[T: scala.reflect.ClassManifest] = ??? - def rcm2[T](implicit evidence$1: scala.reflect.ClassManifest[T]) = ??? - val rcm3: scala.reflect.ClassManifest[Int] = null - - type CM[T] = ClassManifest[T] - def acm1[T: CM] = ??? - def acm2[T](implicit evidence$1: CM[T]) = ??? - val acm3: CM[Int] = null - - type RCM[T] = scala.reflect.ClassManifest[T] - def arcm1[T: RCM] = ??? - def arcm2[T](implicit evidence$1: RCM[T]) = ??? - val arcm3: RCM[Int] = null - - def m1[T: Manifest] = ??? - def m2[T](implicit evidence$1: Manifest[T]) = ??? - val m3: Manifest[Int] = null - - def rm1[T: scala.reflect.Manifest] = ??? - def rm2[T](implicit evidence$1: scala.reflect.Manifest[T]) = ??? - val rm3: scala.reflect.Manifest[Int] = null - - type M[T] = Manifest[T] - def am1[T: M] = ??? - def am2[T](implicit evidence$1: M[T]) = ??? - val am3: M[Int] = null - - type RM[T] = scala.reflect.Manifest[T] - def arm1[T: RM] = ??? - def arm2[T](implicit evidence$1: RM[T]) = ??? - val arm3: RM[Int] = null -} diff --git a/tests/untried/neg/compile-time-only-a.scala b/tests/untried/neg/compile-time-only-a.scala deleted file mode 100644 index 130a3c539..000000000 --- a/tests/untried/neg/compile-time-only-a.scala +++ /dev/null @@ -1,76 +0,0 @@ -import scala.annotation.compileTimeOnly -import scala.language.existentials - -@compileTimeOnly("C1") class C1 -object C1 - -class C2 -@compileTimeOnly("C2") object C2 - -@compileTimeOnly("C3") case class C3(x: Int) - -@compileTimeOnly("C4") case class C4(x: Int) -object C4 - -object pkg { - @compileTimeOnly("C5") - implicit class C5(val x: Int) { - def ext = ??? - } -} - -class C6(@compileTimeOnly("C6.x") val x: Int) { - @compileTimeOnly("C6.foo") def foo = 2 - @compileTimeOnly("C6.Foo") type Foo = Int - @compileTimeOnly("C6.y") var y = 3 -} - -@compileTimeOnly("C7") class C7 -@compileTimeOnly("C8") class C8[T] - -object Test extends App { - new C1() - C1 - - new C2() - C2 - - new C3(2) - C3(2) - - new C4(2) - C4(2) - - import pkg._ - 2.ext - C5(2) - - val c6 = new C6(2) - val _ = c6.x - c6.foo - type Foo = c6.Foo - c6.y = c6.y - - val c701: (C7, C7) = ??? - val c702: (C7 => C7) = ??? - val c703: { val x: C7 } = ??? - val c704: AnyRef with C7 = ??? - // https://groups.google.com/forum/#!topic/scala-internals/5n07TiCnBZU - // val c705: ({ @compileTimeOnly("C7") type C7[T] = List[T] })#C7[_] = ??? - val c706: C7 Either C7 = ??? - val c707a: List[C7] = ??? - val c707b = List[C7]() - val c708a: T forSome { type T <: C7 } = ??? - // https://groups.google.com/forum/#!topic/scala-internals/5n07TiCnBZU - // val c708b: T forSome { @compileTimeOnly("C7") type T } = ??? - val c709: (C8[Int], C8[C7]) = ??? - val c710: (C8[_] => C8[_]) = ??? -} - -@compileTimeOnly("placebo") -class placebo extends scala.annotation.StaticAnnotation - -@placebo -class Test { - @placebo def x = (2: @placebo) -} diff --git a/tests/untried/neg/divergent-implicit.scala b/tests/untried/neg/divergent-implicit.scala deleted file mode 100644 index 4a356d54f..000000000 --- a/tests/untried/neg/divergent-implicit.scala +++ /dev/null @@ -1,16 +0,0 @@ -object Test1 { - implicit def cast[A, B](x: A)(implicit c: A => B): B = c(x) - - val x1: String = 1 - val x2: String = cast[Int, String](1) -} -object Test2 { - class Foo - class Bar - class Baz - implicit def foo2bar(x: Foo)(implicit baz2bar: Baz => Bar): Bar = baz2bar(new Baz) - implicit def baz2bar(x: Baz)(implicit foo2bar: Foo => Bar): Bar = foo2bar(new Foo) - - val x: Bar = new Foo - val y: Bar = new Baz -} diff --git a/tests/untried/neg/forgot-interpolator.scala b/tests/untried/neg/forgot-interpolator.scala deleted file mode 100644 index a53054d89..000000000 --- a/tests/untried/neg/forgot-interpolator.scala +++ /dev/null @@ -1,93 +0,0 @@ -class A { - val bippy = 123 - - def f = "Put the $bippy in the $bippy!" // warn 1 -} - -class B { - val dingus = 123 - - def f = "Put the $bippy in the $bippy!" // no warn -} - -class C { - def f = """Put the ${println("bippy")} in the bippy!""" // warn 2 -} - -package object test { - def aleppo = 9 - def greppo(n: Int) = ??? - def zappos(n: Int)(implicit ord: math.Ordering[Int]) = ??? - def hippo(implicit n: Int) = ??? -} - -package test { - // not sure if overloading is kosher in pkg obj yet - class Doo { - def beppo(i: Int) = 8 * i - def beppo = 8 - class Dah extends Doo { - def f = "$beppo was a marx bros who saw dollars." // warn 3 - } - } - class E { - def f = "$aleppo is a pepper and a city." // warn 4 - def k = s"Just an interpolation of $aleppo" // no warn - } - class Bar { - private def bar = 8 - if (bar > 8) ??? // use it to avoid extra warning - } - class Baz extends Bar { - def f = "$bar is private, shall we warn just in case?" // no longer a warning, private members aren't inherited! - } - class G { - def g = "$greppo takes an arg" // no warn - def z = "$zappos takes an arg too" // no warn - def h = "$hippo takes an implicit" // warn 6 - } - class J { - def j = 8 - class J2 { - def j(i: Int) = 2 * i - def jj = "shadowed $j" // no warn - } - } - import annotation._ - @implicitNotFound("No Z in ${A}") // no warn - class Z[A] -} - - -package inf1 { - import scala.annotation.implicitNotFound - - @implicitNotFound(msg = "Cannot construct a collection of type ${To} with elements of type ${Elem} based on a collection of type ${From}.") // no warn - trait CannotBuildFrom[-From, -Elem, +To] -} - -package inf2 { - @scala.annotation.implicitNotFound(msg = "Cannot construct a collection of type ${To} with elements of type ${Elem} based on a collection of type ${From}.") // no warn - trait CannotBuildFrom[-From, -Elem, +To] -} - -package inf3 { - @scala.annotation.implicitNotFound("Cannot construct a collection of type ${To} with elements of type ${Elem} based on a collection of type ${From}.") // no warn - trait CannotBuildFrom[-From, -Elem, +To] -} - -package curry { - class A { - def bunko()(x: Int): Int = 5 - def groucho(): Int = 5 - def dingo()()()()()(): Int = 5 // kind of nuts this can be evaluated with just 'dingo', but okay - def calico[T1, T2]()()(): Int = 5 // even nutsier - def palomino[T1, T2]()(y: Int = 5)(): Int = 5 // even nutsier - - def f1 = "I was picked up by the $bunko squad" // no warn - def f2 = "I salute $groucho" // warn 7 - def f3 = "I even salute $dingo" // warn 8 - def f4 = "I also salute $calico" // warn 9 - def f5 = "I draw the line at $palomino" // no warn - } -} diff --git a/tests/untried/neg/implicit-shadow.scala b/tests/untried/neg/implicit-shadow.scala deleted file mode 100644 index ec7f70b6d..000000000 --- a/tests/untried/neg/implicit-shadow.scala +++ /dev/null @@ -1,13 +0,0 @@ -object Test { - import B._, C._ - - 1.isEmpty -} - -trait A { - implicit def i2s(i: Int): String = "" -} - -object B extends A - -object C extends A diff --git a/tests/untried/neg/implicits.scala b/tests/untried/neg/implicits.scala deleted file mode 100644 index 22633a1f3..000000000 --- a/tests/untried/neg/implicits.scala +++ /dev/null @@ -1,74 +0,0 @@ -class Pos - -class Super - -object Super { - implicit def pos2int(p: Pos): Int = 0 -} - -object Sub extends Super { - class Plus(x: Any) { - def +(y: String): String = x.toString + y - } - implicit def any2plus(x: Any): Plus = new Plus(x) -} - -object Test { - import Super._ - import Sub._ - val p = new Pos - def f(x: Int): Int = x - f(p+1) -} - -object test2 { - sealed trait HMap { - def +[T](v: T) = HSome(v,this) - } - - final case class HSome[T, L <: HMap](head: T, tail: L) extends HMap - - final object HEmpty extends HMap - - val set = HEmpty + 3 + "3" - implicit def select[T](t: HSome[T,_]) = t.head - implicit def selectTail[L](t: HSome[_,L]) = t.tail - - def foo(x: Int) = 3 - foo(set) -} - -// #2180 -class Mxml { - - private def processChildren( children:Seq[Any] ):List[Mxml] = { - - children.toList.flatMap ( e => { - - e match { - - case s:scala.collection.Traversable[_] => s case a => List(a) - - } - - }) - - } - -} - -// SI-5316 -class Test3 { - def foo(p: => Any)(implicit x: Nothing): Unit = () - - object X - - foo { - val a = 0 - - { - import X._ - a - } - } -} diff --git a/tests/untried/neg/logImplicits.scala b/tests/untried/neg/logImplicits.scala deleted file mode 100644 index ecb4cbb31..000000000 --- a/tests/untried/neg/logImplicits.scala +++ /dev/null @@ -1,25 +0,0 @@ -class A { - def f(xs: Array[Byte]) = xs.size - def g(xs: Array[Byte]) = xs.length -} - -class B { - def f = "abc" map (_ + 1) -} - -object C { - final val x = "abc" - - implicit def convert(p: x.type): Int = 123 - - math.max(122, x: Int) -} - -class D { - def f = (1 -> 2) + "c" -} - -class Un { - // forcing post-typer failure, since we're only interested in the output from the above - def unimplemented: Int -} diff --git a/tests/untried/neg/macro-blackbox-dynamic-materialization/Macros_1.scala b/tests/untried/neg/macro-blackbox-dynamic-materialization/Macros_1.scala deleted file mode 100644 index 16a379ea5..000000000 --- a/tests/untried/neg/macro-blackbox-dynamic-materialization/Macros_1.scala +++ /dev/null @@ -1,25 +0,0 @@ -import scala.reflect.macros.blackbox.Context -import scala.language.experimental.macros - -trait Foo[T] - -class C1(val x: Int) -class C2(val x: String) - -trait LowPriority { - implicit def lessSpecific[T]: Foo[T] = null -} - -object Foo extends LowPriority { - implicit def moreSpecific[T]: Foo[T] = macro Macros.impl[T] -} - -object Macros { - def impl[T: c.WeakTypeTag](c: Context) = { - import c.universe._ - val tpe = weakTypeOf[T] - if (tpe.members.exists(_.info =:= typeOf[Int])) - c.abort(c.enclosingPosition, "I don't like classes that contain integers") - q"new Foo[$tpe]{ override def toString = ${tpe.toString} }" - } -} diff --git a/tests/untried/neg/macro-blackbox-dynamic-materialization/Test_2.scala b/tests/untried/neg/macro-blackbox-dynamic-materialization/Test_2.scala deleted file mode 100644 index abb5229bd..000000000 --- a/tests/untried/neg/macro-blackbox-dynamic-materialization/Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends App { - println(implicitly[Foo[C1]]) - println(implicitly[Foo[C2]]) -} diff --git a/tests/untried/neg/macro-blackbox-fundep-materialization/Macros_1.scala b/tests/untried/neg/macro-blackbox-fundep-materialization/Macros_1.scala deleted file mode 100644 index 8d776388e..000000000 --- a/tests/untried/neg/macro-blackbox-fundep-materialization/Macros_1.scala +++ /dev/null @@ -1,39 +0,0 @@ -import scala.language.experimental.macros -import scala.reflect.macros.blackbox.Context - -trait Iso[T, U] { - def to(t : T) : U - // def from(u : U) : T -} - -object Iso { - implicit def materializeIso[T, U]: Iso[T, U] = macro impl[T, U] - def impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context): c.Expr[Iso[T, U]] = { - import c.universe._ - import definitions._ - import Flag._ - - val sym = c.weakTypeOf[T].typeSymbol - if (!sym.isClass || !sym.asClass.isCaseClass) c.abort(c.enclosingPosition, s"$sym is not a case class") - val fields = sym.info.decls.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x } - - def mkTpt() = { - val core = Ident(TupleClass(fields.length) orElse UnitClass) - if (fields.length == 0) core - else AppliedTypeTree(core, fields map (f => TypeTree(f.info))) - } - - def mkFrom() = { - if (fields.length == 0) Literal(Constant(Unit)) - else Apply(Ident(newTermName("Tuple" + fields.length)), fields map (f => Select(Ident(newTermName("f")), newTermName(f.name.toString.trim)))) - } - - val evidenceClass = ClassDef(Modifiers(FINAL), newTypeName("$anon"), List(), Template( - List(AppliedTypeTree(Ident(newTypeName("Iso")), List(Ident(sym), mkTpt()))), - emptyValDef, - List( - DefDef(Modifiers(), termNames.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(typeNames.EMPTY), typeNames.EMPTY), termNames.CONSTRUCTOR), List())), Literal(Constant(())))), - DefDef(Modifiers(), newTermName("to"), List(), List(List(ValDef(Modifiers(PARAM), newTermName("f"), Ident(sym), EmptyTree))), TypeTree(), mkFrom())))) - c.Expr[Iso[T, U]](Block(List(evidenceClass), Apply(Select(New(Ident(newTypeName("$anon"))), termNames.CONSTRUCTOR), List()))) - } -} diff --git a/tests/untried/neg/macro-blackbox-fundep-materialization/Test_2.scala b/tests/untried/neg/macro-blackbox-fundep-materialization/Test_2.scala deleted file mode 100644 index 8b60943cf..000000000 --- a/tests/untried/neg/macro-blackbox-fundep-materialization/Test_2.scala +++ /dev/null @@ -1,12 +0,0 @@ -// see the comments for macroExpand.onDelayed for an explanation of what's tested here -object Test extends App { - case class Foo(i: Int, s: String, b: Boolean) - def foo[C, L](c: C)(implicit iso: Iso[C, L]): L = iso.to(c) - - { - val equiv = foo(Foo(23, "foo", true)) - def typed[T](t: => T): Unit = {} - typed[(Int, String, Boolean)](equiv) - println(equiv) - } -} diff --git a/tests/untried/neg/macro-bundle-whitebox-use-raw/Macros_1.scala b/tests/untried/neg/macro-bundle-whitebox-use-raw/Macros_1.scala deleted file mode 100644 index 61bf73e48..000000000 --- a/tests/untried/neg/macro-bundle-whitebox-use-raw/Macros_1.scala +++ /dev/null @@ -1,108 +0,0 @@ -import scala.reflect.macros.blackbox.Context -import scala.language.experimental.macros - -// whitebox use case #1: return type refinement - -class ReturnTypeRefinementBundle(val c: Context) { - import c.universe._ - def impl = { - q""" - trait Foo { - def x = 2 - } - new Foo {} - """ - } -} - -object ReturnTypeRefinement { - def foo: Any = macro ReturnTypeRefinementBundle.impl -} - -// whitebox use case #2: fundep materialization - -trait FundepMaterialization[T, U] { - def to(t : T) : U - // def from(u : U) : T -} - -class FundepMaterializationBundle(val c: Context) { - import c.universe._ - import definitions._ - import Flag._ - - def impl[T: c.WeakTypeTag, U: c.WeakTypeTag]: c.Expr[FundepMaterialization[T, U]] = { - val sym = c.weakTypeOf[T].typeSymbol - if (!sym.isClass || !sym.asClass.isCaseClass) c.abort(c.enclosingPosition, s"$sym is not a case class") - val fields = sym.info.decls.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x } - - def mkTpt() = { - val core = Ident(TupleClass(fields.length) orElse UnitClass) - if (fields.length == 0) core - else AppliedTypeTree(core, fields map (f => TypeTree(f.info))) - } - - def mkFrom() = { - if (fields.length == 0) Literal(Constant(Unit)) - else Apply(Ident(newTermName("Tuple" + fields.length)), fields map (f => Select(Ident(newTermName("f")), newTermName(f.name.toString.trim)))) - } - - val evidenceClass = ClassDef(Modifiers(FINAL), newTypeName("$anon"), List(), Template( - List(AppliedTypeTree(Ident(newTypeName("FundepMaterialization")), List(Ident(sym), mkTpt()))), - emptyValDef, - List( - DefDef(Modifiers(), termNames.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(typeNames.EMPTY), typeNames.EMPTY), termNames.CONSTRUCTOR), List())), Literal(Constant(())))), - DefDef(Modifiers(), newTermName("to"), List(), List(List(ValDef(Modifiers(PARAM), newTermName("f"), Ident(sym), EmptyTree))), TypeTree(), mkFrom())))) - c.Expr[FundepMaterialization[T, U]](Block(List(evidenceClass), Apply(Select(New(Ident(newTypeName("$anon"))), termNames.CONSTRUCTOR), List()))) - } -} - -object FundepMaterialization { - implicit def materializeIso[T, U]: FundepMaterialization[T, U] = macro FundepMaterializationBundle.impl[T, U] -} - -// whitebox use case #3: dynamic materialization - -trait DynamicMaterialization[T] - -class C1(val x: Int) -class C2(val x: String) - -trait LowPriority { - implicit def lessSpecific[T]: DynamicMaterialization[T] = null -} - -object DynamicMaterialization extends LowPriority { - implicit def moreSpecific[T]: DynamicMaterialization[T] = macro DynamicMaterializationBundle.impl[T] -} - -class DynamicMaterializationBundle(val c: Context) { - import c.universe._ - def impl[T: c.WeakTypeTag] = { - val tpe = weakTypeOf[T] - if (tpe.members.exists(_.info =:= typeOf[Int])) - c.abort(c.enclosingPosition, "I don't like classes that contain integers") - q"new DynamicMaterialization[$tpe]{ override def toString = ${tpe.toString} }" - } -} - -// whitebox use case #4: extractor macros - -object ExtractorMacro { - def unapply(x: Int): Any = macro ExtractorBundle.unapplyImpl -} - -class ExtractorBundle(val c: Context) { - import c.universe._ - def unapplyImpl(x: Tree) = { - q""" - new { - class Match(x: Int) { - def isEmpty = false - def get = x - } - def unapply(x: Int) = new Match(x) - }.unapply($x) - """ - } -} diff --git a/tests/untried/neg/macro-bundle-whitebox-use-raw/Test_2.scala b/tests/untried/neg/macro-bundle-whitebox-use-raw/Test_2.scala deleted file mode 100644 index 995da737c..000000000 --- a/tests/untried/neg/macro-bundle-whitebox-use-raw/Test_2.scala +++ /dev/null @@ -1,19 +0,0 @@ -object Test extends App { - println(ReturnTypeRefinement.foo.x) - - case class Foo(i: Int, s: String, b: Boolean) - def foo[C, L](c: C)(implicit iso: FundepMaterialization[C, L]): L = iso.to(c) - locally { - val equiv = foo(Foo(23, "foo", true)) - def typed[T](t: => T): Unit = {} - typed[(Int, String, Boolean)](equiv) - println(equiv) - } - - println(implicitly[DynamicMaterialization[C1]]) - println(implicitly[DynamicMaterialization[C2]]) - - 42 match { - case ExtractorMacro(x) => println(x) - } -} diff --git a/tests/untried/neg/macro-bundle-whitebox-use-refined/Macros_1.scala b/tests/untried/neg/macro-bundle-whitebox-use-refined/Macros_1.scala deleted file mode 100644 index 186604422..000000000 --- a/tests/untried/neg/macro-bundle-whitebox-use-refined/Macros_1.scala +++ /dev/null @@ -1,108 +0,0 @@ -import scala.reflect.macros.blackbox.Context -import scala.language.experimental.macros - -// whitebox use case #1: return type refinement - -class ReturnTypeRefinementBundle(val c: Context { type PrefixType = Nothing }) { - import c.universe._ - def impl = { - q""" - trait Foo { - def x = 2 - } - new Foo {} - """ - } -} - -object ReturnTypeRefinement { - def foo: Any = macro ReturnTypeRefinementBundle.impl -} - -// whitebox use case #2: fundep materialization - -trait FundepMaterialization[T, U] { - def to(t : T) : U - // def from(u : U) : T -} - -class FundepMaterializationBundle(val c: Context { type PrefixType = Nothing }) { - import c.universe._ - import definitions._ - import Flag._ - - def impl[T: c.WeakTypeTag, U: c.WeakTypeTag]: c.Expr[FundepMaterialization[T, U]] = { - val sym = c.weakTypeOf[T].typeSymbol - if (!sym.isClass || !sym.asClass.isCaseClass) c.abort(c.enclosingPosition, s"$sym is not a case class") - val fields = sym.info.decls.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x } - - def mkTpt() = { - val core = Ident(TupleClass(fields.length) orElse UnitClass) - if (fields.length == 0) core - else AppliedTypeTree(core, fields map (f => TypeTree(f.info))) - } - - def mkFrom() = { - if (fields.length == 0) Literal(Constant(Unit)) - else Apply(Ident(newTermName("Tuple" + fields.length)), fields map (f => Select(Ident(newTermName("f")), newTermName(f.name.toString.trim)))) - } - - val evidenceClass = ClassDef(Modifiers(FINAL), newTypeName("$anon"), List(), Template( - List(AppliedTypeTree(Ident(newTypeName("FundepMaterialization")), List(Ident(sym), mkTpt()))), - emptyValDef, - List( - DefDef(Modifiers(), termNames.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(typeNames.EMPTY), typeNames.EMPTY), termNames.CONSTRUCTOR), List())), Literal(Constant(())))), - DefDef(Modifiers(), newTermName("to"), List(), List(List(ValDef(Modifiers(PARAM), newTermName("f"), Ident(sym), EmptyTree))), TypeTree(), mkFrom())))) - c.Expr[FundepMaterialization[T, U]](Block(List(evidenceClass), Apply(Select(New(Ident(newTypeName("$anon"))), termNames.CONSTRUCTOR), List()))) - } -} - -object FundepMaterialization { - implicit def materializeIso[T, U]: FundepMaterialization[T, U] = macro FundepMaterializationBundle.impl[T, U] -} - -// whitebox use case #3: dynamic materialization - -trait DynamicMaterialization[T] - -class C1(val x: Int) -class C2(val x: String) - -trait LowPriority { - implicit def lessSpecific[T]: DynamicMaterialization[T] = null -} - -object DynamicMaterialization extends LowPriority { - implicit def moreSpecific[T]: DynamicMaterialization[T] = macro DynamicMaterializationBundle.impl[T] -} - -class DynamicMaterializationBundle(val c: Context { type PrefixType = Nothing }) { - import c.universe._ - def impl[T: c.WeakTypeTag] = { - val tpe = weakTypeOf[T] - if (tpe.members.exists(_.info =:= typeOf[Int])) - c.abort(c.enclosingPosition, "I don't like classes that contain integers") - q"new DynamicMaterialization[$tpe]{ override def toString = ${tpe.toString} }" - } -} - -// whitebox use case #4: extractor macros - -object ExtractorMacro { - def unapply(x: Int): Any = macro ExtractorBundle.unapplyImpl -} - -class ExtractorBundle(val c: Context { type PrefixType = Nothing }) { - import c.universe._ - def unapplyImpl(x: Tree) = { - q""" - new { - class Match(x: Int) { - def isEmpty = false - def get = x - } - def unapply(x: Int) = new Match(x) - }.unapply($x) - """ - } -} diff --git a/tests/untried/neg/macro-bundle-whitebox-use-refined/Test_2.scala b/tests/untried/neg/macro-bundle-whitebox-use-refined/Test_2.scala deleted file mode 100644 index 995da737c..000000000 --- a/tests/untried/neg/macro-bundle-whitebox-use-refined/Test_2.scala +++ /dev/null @@ -1,19 +0,0 @@ -object Test extends App { - println(ReturnTypeRefinement.foo.x) - - case class Foo(i: Int, s: String, b: Boolean) - def foo[C, L](c: C)(implicit iso: FundepMaterialization[C, L]): L = iso.to(c) - locally { - val equiv = foo(Foo(23, "foo", true)) - def typed[T](t: => T): Unit = {} - typed[(Int, String, Boolean)](equiv) - println(equiv) - } - - println(implicitly[DynamicMaterialization[C1]]) - println(implicitly[DynamicMaterialization[C2]]) - - 42 match { - case ExtractorMacro(x) => println(x) - } -} diff --git a/tests/untried/neg/macro-cyclic/Impls_Macros_1.scala b/tests/untried/neg/macro-cyclic/Impls_Macros_1.scala deleted file mode 100644 index ad6890144..000000000 --- a/tests/untried/neg/macro-cyclic/Impls_Macros_1.scala +++ /dev/null @@ -1,25 +0,0 @@ -import scala.reflect.macros.blackbox.Context - -object Macros { - def impl(c: Context) = { - c.universe.reify { implicitly[SourceLocation] } - } - - implicit def sourceLocation: SourceLocation1 = macro impl -} - -trait SourceLocation { - /** Source location of the outermost call */ - val outer: SourceLocation - - /** The name of the source file */ - val fileName: String - - /** The line number */ - val line: Int - - /** The character offset */ - val charOffset: Int -} - -case class SourceLocation1(val outer: SourceLocation, val fileName: String, val line: Int, val charOffset: Int) extends SourceLocation diff --git a/tests/untried/neg/macro-divergence-controlled/Impls_Macros_1.scala b/tests/untried/neg/macro-divergence-controlled/Impls_Macros_1.scala deleted file mode 100644 index 5c0450326..000000000 --- a/tests/untried/neg/macro-divergence-controlled/Impls_Macros_1.scala +++ /dev/null @@ -1,23 +0,0 @@ -import scala.reflect.macros.whitebox.Context -import language.experimental.macros - -trait Complex[T] - -class Foo(val foo: Foo) - -object Complex { - def impl[T: c.WeakTypeTag](c: Context): c.Expr[Complex[T]] = { - import c.universe._ - val tpe = weakTypeOf[T] - for (f <- tpe.decls.collect{case f: TermSymbol if f.isParamAccessor && !f.isMethod => f}) { - val trecur = appliedType(typeOf[Complex[_]], List(f.info)) - if (c.openImplicits.tail.exists(ic => ic.pt =:= trecur)) c.abort(c.enclosingPosition, "diverging implicit expansion. reported by a macro!") - val recur = c.inferImplicitValue(trecur, silent = true) - if (recur == EmptyTree) c.abort(c.enclosingPosition, s"couldn't synthesize $trecur") - } - c.Expr[Null](q"null") - } - - implicit object ComplexString extends Complex[String] - implicit def genComplex[T]: Complex[T] = macro impl[T] -} diff --git a/tests/untried/neg/macro-divergence-controlled/Test_2.scala b/tests/untried/neg/macro-divergence-controlled/Test_2.scala deleted file mode 100644 index e06175f30..000000000 --- a/tests/untried/neg/macro-divergence-controlled/Test_2.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test extends App { - println(implicitly[Complex[Foo]]) -} diff --git a/tests/untried/neg/macro-invalidsig/Impls_1.scala b/tests/untried/neg/macro-invalidsig/Impls_1.scala deleted file mode 100644 index 2816c4ddf..000000000 --- a/tests/untried/neg/macro-invalidsig/Impls_1.scala +++ /dev/null @@ -1,86 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.macros.blackbox.Context - -object Impls1 { - def foo[U: c.WeakTypeTag: Numeric](c: Context) = { import c.universe._; q"42" } -} - -object Impls2 { - def foo = ??? -} - -object Impls3 { - def foo(c: scala.reflect.api.Universe) = ??? -} - -object Impls4 { - def foo(cs: Context*) = ??? -} - -object Impls5 { - def foo(c: Context) = ??? -} - -object Impls6 { - def foo[T, U: c.WeakTypeTag](c: Context)(implicit x: c.Expr[Int]) = { - import c.{prefix => prefix} - import c.universe._ - c.Expr[Unit](q""" - println("invoking foo_targs...") - println("type of prefix is: " + ${prefix.staticType.toString}) - println("U is: " + ${implicitly[c.WeakTypeTag[U]].tpe.toString}) - """) - } -} - -object Impls7 { - def foo(c: Context)(x: c.Expr[Int], y: c.Expr[Int]) = ??? -} - -object Impls8 { - def foo(c: Context)(x: c.universe.Symbol) = ??? -} - -object Impls9 { - def foo(c: Context)(xs: c.Expr[Int]*) = ??? -} - -object Impls10 { - def foo(c: Context)(y: c.Expr[Int], x: c.Expr[Int]) = ??? -} - -object Impls11 { - def foo[U](c: Context)(U: c.universe.Type) = ??? -} - -object Impls12 { - def foo[U <: String](c: Context) = ??? -} - -object Impls13 { - def foo[U <: String](c: Context) = ??? -} - -object Impls14 { - def foo[U: c.WeakTypeTag](c: Context) = ??? -} - -object Impls15 { - def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Context)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { - import c.universe._ - println(implicitly[c.WeakTypeTag[T]]) - println(implicitly[c.WeakTypeTag[U]]) - println(V) - c.Expr[Unit](q"()") - } -} - -object Impls16 { - def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Context)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { - import c.universe._ - println(implicitly[c.WeakTypeTag[T]]) - println(implicitly[c.WeakTypeTag[U]]) - println(V) - c.Expr[Unit](q"()") - } -} diff --git a/tests/untried/neg/macro-invalidsig/Macros_Test_2.scala b/tests/untried/neg/macro-invalidsig/Macros_Test_2.scala deleted file mode 100644 index d662a029e..000000000 --- a/tests/untried/neg/macro-invalidsig/Macros_Test_2.scala +++ /dev/null @@ -1,83 +0,0 @@ -object Macros1 { - def foo[U]: Int = macro Impls1.foo[U] -} - -object Macros2 { - def foo = macro Impls2.foo -} - -object Macros3 { - def foo = macro Impls3.foo -} - -object Macros4 { - def foo = macro Impls4.foo -} - -object Macros5 { - def foo(x: Any) = macro Impls5.foo -} - -class Macros6[T] { - def foo[U](x: Int) = macro Impls6.foo[T, U] -} - -object Macros7 { - def foo(x: Int) = macro Impls7.foo -} - -object Macros8 { - def foo(x: Int) = macro Impls8.foo -} - -object Macros9 { - def foo(x: Int, y: Int) = macro Impls9.foo -} - -object Macros10 { - def foo(x: Int, y: Int) = macro Impls10.foo -} - -object Macros11 { - def foo[U] = macro Impls11.foo[U] -} - -object Macros12 { - def foo[U] = macro Impls12.foo[U] -} - -object Macros13 { - def foo[U <: Int] = macro Impls13.foo[U] -} - -object Macros14 { - def foo = macro Impls14.foo -} - -class D[T] { - class C[U] { - def foo15[V]: Unit = macro Impls15.foo - def foo16[V]: Unit = macro Impls16.foo[V] - } -} - -object Test extends App { - println(Macros1.foo[String]) - println(Macros2.foo) - println(Macros3.foo) - println(Macros4.foo) - println(Macros5.foo(42)) - println(new Macros6[Int]().foo[String](42)) - println(Macros7.foo(42)) - println(Macros8.foo) - println(Macros9.foo(4, 2)) - println(Macros10.foo(4, 2)) - println(Macros11.foo[Int]) - println(Macros12.foo[Int]) - println(Macros13.foo[Int]) - println(Macros14.foo) - val outer1 = new D[Int] - val outer2 = new outer1.C[String] - outer2.foo15[Boolean] - outer2.foo16[Boolean] -} diff --git a/tests/untried/neg/overloaded-implicit.scala b/tests/untried/neg/overloaded-implicit.scala deleted file mode 100644 index 68b1ceaa3..000000000 --- a/tests/untried/neg/overloaded-implicit.scala +++ /dev/null @@ -1,17 +0,0 @@ -object Test { - implicit def imp1[T](x: List[T]): Map[T, T] = Map() - implicit def imp1[T](x: Set[T]): Map[T, T] = Map() - - def f[T <% Map[Int, Int]](x: T): Double = 1.0d - - // not parameterized, no warning - implicit def imp2(x: List[Int]): String = "a" - implicit def imp2(x: Set[Int]): String = "b" - - def g[T <% String](x: T): Double = 2.0d - - def main(args: Array[String]): Unit = { - // println(f(List(1))) - println(g(List(1))) - } -} diff --git a/tests/untried/neg/patmat-classtag-compound.scala b/tests/untried/neg/patmat-classtag-compound.scala deleted file mode 100644 index e2d0df0a0..000000000 --- a/tests/untried/neg/patmat-classtag-compound.scala +++ /dev/null @@ -1,17 +0,0 @@ -object Test extends App{ - trait Bar - trait Foo - // Failed to give an unchecked warning pre: https://github.com/scala/scala/pull/2848 - // - // Features interacting: - // - implicit class tags to enable type patterns on abstract types - // - type tests on compound types. - // - // We could try make these work together, but an unchecked warning is okay for now. - def x[A: reflect.ClassTag](a: Any): Boolean = a match{ - case b: A with Bar => true - case _ => false - } - println(x[Foo](new Bar{})) - println(x[String]("")) -} diff --git a/tests/untried/neg/sammy_restrictions.scala b/tests/untried/neg/sammy_restrictions.scala deleted file mode 100644 index 5f1a04cd2..000000000 --- a/tests/untried/neg/sammy_restrictions.scala +++ /dev/null @@ -1,45 +0,0 @@ -class NoAbstract - -class TwoAbstract { def ap(a: Int): Int; def pa(a: Int): Int } - -class Base // check that the super class constructor isn't considered. -class NoEmptyConstructor(a: Int) extends Base { def this(a: String) = this(0); def ap(a: Int): Int } - -class OneEmptyConstructor() { def this(a: Int) = this(); def ap(a: Int): Int } - -class OneEmptySecondaryConstructor(a: Int) { def this() = this(0); def ap(a: Int): Int } - -class MultipleConstructorLists()() { def ap(a: Int): Int } - -class MultipleMethodLists()() { def ap(a: Int)(): Int } - -class ImplicitConstructorParam()(implicit a: String) { def ap(a: Int): Int } - -class ImplicitMethodParam() { def ap(a: Int)(implicit b: String): Int } - -class PolyClass[T] { def ap(a: T): T } - -class PolyMethod { def ap[T](a: T): T } - -class OneAbstract { def ap(a: Any): Any } -class DerivedOneAbstract extends OneAbstract - -object Test { - implicit val s: String = "" - type NonClassType = DerivedOneAbstract with OneAbstract - - (() => 0) : NoAbstract - ((x: Int) => 0): TwoAbstract - ((x: Int) => 0): DerivedOneAbstract // okay - ((x: Int) => 0): NonClassType // "class type required". I think we should avoid SAM translation here. - ((x: Int) => 0): NoEmptyConstructor - ((x: Int) => 0): OneEmptyConstructor // okay - ((x: Int) => 0): OneEmptySecondaryConstructor // derived class must have an empty *primary* to call. - ((x: Int) => 0): MultipleConstructorLists - ((x: Int) => 0): MultipleMethodLists - ((x: Int) => 0): ImplicitConstructorParam - ((x: Int) => 0): ImplicitMethodParam - - ((x: Int) => 0): PolyClass[Int] // okay - ((x: Int) => 0): PolyMethod -} diff --git a/tests/untried/neg/sensitive2.scala b/tests/untried/neg/sensitive2.scala deleted file mode 100644 index e0cf515bd..000000000 --- a/tests/untried/neg/sensitive2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test { - class Foo[A](z: A) - implicit def foo1[A](a: A): Foo[A] = new Foo(a) - implicit def foo2(a: Any): Foo[String] = new Foo("123") - - val a: Foo[_] = "abc" - -} diff --git a/tests/untried/neg/stringinterpolation_macro-neg.scala b/tests/untried/neg/stringinterpolation_macro-neg.scala deleted file mode 100644 index 3869d42d6..000000000 --- a/tests/untried/neg/stringinterpolation_macro-neg.scala +++ /dev/null @@ -1,76 +0,0 @@ -object Test extends App { - val s = "Scala" - val d = 8 - val b = false - val f = 3.14159 - val c = 'c' - val t = new java.util.Date - val x = new java.util.Formattable { - def formatTo(ff: java.util.Formatter, g: Int, w: Int, p: Int): Unit = ff format "xxx" - } - - // 1) number of arguments - new StringContext().f() - new StringContext("", " is ", "%2d years old").f(s) - new StringContext("", " is ", "%2d years old").f(s, d, d) - new StringContext("", "").f() - - // 2) Interpolation mismatches - f"$s%b" - f"$s%c" - f"$f%c" - f"$s%x" - f"$b%d" - f"$s%d" - f"$f%o" - f"$s%e" - f"$b%f" - - { - implicit val strToInt1 = (s: String) => 1 - implicit val strToInt2 = (s: String) => 2 - f"$s%d" - } - - f"$s%i" - - // 3) flag mismatches - f"$s%+ 0,(s" - f"$c%#+ 0,(c" - f"$d%#d" - f"$d%,x" - f"$d%+ (x" - f"$f%,(a" - f"$t%#+ 0,(tT" - - // 4) bad precisions - f"$c%.2c" - f"$d%.2d" - f"%.2%" - f"%.2n" - f"$f%.2a" - f"$t%.2tT" - - // 5) bad indexes - f"%<s" - f"%<c" - f"%<tT" - f"${8}%d ${9}%d%3$$d" - f"${8}%d ${9}%d%0$$d" - - // warnings - f"${8}%d ${9}%1$$d" - f"$s%s $s%s %1$$<s" - f"$s%s $s%1$$s" - - // 6) bad arg types - f"$s%#s" - - // 7) misunderstood conversions - f"$t%tG" - f"$t%t" - f"$s%10.5" - - // 8) other brain failures - f"${d}random-leading-junk%d" -} diff --git a/tests/untried/neg/t0226.scala b/tests/untried/neg/t0226.scala deleted file mode 100644 index beca3cd64..000000000 --- a/tests/untried/neg/t0226.scala +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - def foo[A](x: A)(implicit rep: Foo[A]): Foo[A] = rep - abstract class Foo[A] - implicit def list2Foo[List[A1], A2] - (implicit _1: Foo[List[A1]], _2: Foo[A2]): Foo[Tuple2[List[A1], A2]] = - null //dummy - - foo(((List('b'), 3), (Nil, 4))) -} diff --git a/tests/untried/neg/t0590.scala b/tests/untried/neg/t0590.scala deleted file mode 100644 index 3416ade35..000000000 --- a/tests/untried/neg/t0590.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test { - implicit def foo[T] : T = null -} diff --git a/tests/untried/neg/t1038.scala b/tests/untried/neg/t1038.scala deleted file mode 100644 index 367022965..000000000 --- a/tests/untried/neg/t1038.scala +++ /dev/null @@ -1,8 +0,0 @@ -class X(x : Int) - -object Y { - val a = new X - import a._ - implicit val b : Int = 1 - implicit val c = 2 -} diff --git a/tests/untried/neg/t2206.scala b/tests/untried/neg/t2206.scala deleted file mode 100644 index 529f5030b..000000000 --- a/tests/untried/neg/t2206.scala +++ /dev/null @@ -1,15 +0,0 @@ -object o { - class A - - class AX { - def f(): Unit = { } - } - - import Implicits._ - val a = new A - a.f() - - object Implicits { - implicit def ax(a: A) = new AX - } -} diff --git a/tests/untried/neg/t2316.scala b/tests/untried/neg/t2316.scala deleted file mode 100644 index bf4bb0ec6..000000000 --- a/tests/untried/neg/t2316.scala +++ /dev/null @@ -1,43 +0,0 @@ -object test { - case class T1(val source: String) - - - object T1 { - implicit def T1FromT2(implicit t2: T2): T1 = T1("implicit def T1FromT2") - implicit def T1FromT3(implicit t3: T3): T1 = T1("implicit def T1FromT3") - } - - trait T2 { - } - - object T2 { - implicit val t2: T2 = new T2 {} - } - - trait T3 - - def requireT1(implicit t1: T1) = t1 - - { - val t1 = requireT1 - assert(t1.source == "implicit def T1FromT2") - } - - { - implicit def t3: T3 = new T3 {} - val t1 = requireT1 - assert(t1.source == "implicit def T1FromT2") - - // Expected a compile error here, but because T1.T1FromT2(T2.t2) was cached as a non-local implicit - // expression for type T1, this is not checked! - // - // (fragment of implicit-cache-error2.scala):26: error: ambiguous implicit values: - // both method T1FromT3 in object T1 of type (implicit t3: this.T3)this.T1 - // and method T1FromT2 in object T1 of type (implicit t2: this.T2)this.T1 - // match expected type this.T1 - // val t1 = requireT1 - // ^ - // one error found - - } -} diff --git a/tests/untried/neg/t2405.scala b/tests/untried/neg/t2405.scala deleted file mode 100644 index 6982285b9..000000000 --- a/tests/untried/neg/t2405.scala +++ /dev/null @@ -1,10 +0,0 @@ -object A { implicit val x: Int = 1 } - -// Expecting shadowing #1 -object Test2 { - { - import A.{x => y} - def y: Int = 0 - implicitly[Int] - } -} diff --git a/tests/untried/neg/t2421b.scala b/tests/untried/neg/t2421b.scala deleted file mode 100644 index 4e23a74e8..000000000 --- a/tests/untried/neg/t2421b.scala +++ /dev/null @@ -1,17 +0,0 @@ -object Test { - class A - class B - class C - class F[X] - - def f(implicit aa: F[A]) = println(aa) - - // implicit def a : F[A] = new F[A]() - implicit def b[X <: B] = new F[X]() - - f -} - -/* bug: -error: type arguments [Test2.A] do not conform to method b's type parameter bounds [X <: Test2.B] -*/ diff --git a/tests/untried/neg/t3006.scala b/tests/untried/neg/t3006.scala deleted file mode 100755 index a84b69c84..000000000 --- a/tests/untried/neg/t3006.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test extends App { - case class A(x: Int); - - class Foo(a: A) { println("Foo created!"); def +(x: Int) = new A(this.a.x + x); } - - implicit def aToFoo(x: A) = new Foo(x); - - println(A(3) + "H") - -} diff --git a/tests/untried/neg/t3224.scala b/tests/untried/neg/t3224.scala deleted file mode 100755 index b7af8a67b..000000000 --- a/tests/untried/neg/t3224.scala +++ /dev/null @@ -1,50 +0,0 @@ -object Texts{ - def textL[T](list: List[T]) = { - list match{ - case List() => "Empty" - case List(_) => "One" - case List(_*) => "Many" - } - } - - def textA[T](array: Array[T]) = { - array match{ - case Array() => "Empty" - case Array(_) => "One" - case Array(_*) => "Many" - } - } -} - -object Test extends App { - { - implicit def array2list[T](array: Array[T]) = { - println(array.toList.size) - array.toList - } - - println(Texts textL List()) - println(Texts textL List(1)) - println(Texts textL List(1, 1)); - - println(Texts textL Array()) - println(Texts textL Array(1)) - println(Texts textL Array(1, 1)) - - println(Texts textA List()) - println(Texts textA List(1)) - println(Texts textA List(1, 1)); - - println(Texts textA Array()) - println(Texts textA Array(1)) - println(Texts textA Array(1, 1)) - } - - { - implicit def array2list[T](array: Array[T]) = array.toList - def size[T](list: List[T]) = list.size - - assert(size(array2list(Array())) == 0) - assert(size(Array()) == 0) - } -} diff --git a/tests/untried/neg/t3346b.scala b/tests/untried/neg/t3346b.scala deleted file mode 100644 index f28ee8ba3..000000000 --- a/tests/untried/neg/t3346b.scala +++ /dev/null @@ -1,15 +0,0 @@ -import scala.language.implicitConversions - -trait T[X] -trait U[X] -trait TC[M[_]] - -object Test extends App { - def foo[M[_]: TC, A](ma: M[A]) = () - implicit val TCofT: TC[T] = new TC[T] {} - implicit def any2T[A](a: A): T[A] = new T[A] {} - implicit def any2U[A](a: A): U[A] = new U[A] {} - - val x = foo[T, Int](1) - val y = foo(1) -} diff --git a/tests/untried/neg/t3346c.scala b/tests/untried/neg/t3346c.scala deleted file mode 100644 index a5ac166b2..000000000 --- a/tests/untried/neg/t3346c.scala +++ /dev/null @@ -1,61 +0,0 @@ -object Test extends App { - // - // An attempt to workaround SI-2712, foiled by SI-3346 - // - trait TC[M[_]] - - type EitherInt[A] = Either[Int, A] - - implicit object EitherTC extends TC[EitherInt] - - def foo[M[_]: TC, A](ma: M[A]) = () - - val eii: Either[Int, String] = Right("") - - foo[EitherInt, String](eii) - - // This one needs SI-2712 Higher Order Unification - //foo(eii) // not inferred - - // A workaround is to provide a set of implicit conversions that take values - // based on type constructors of various shapes, and search for the - // type class instances. - // - // This is the approach taken by scalaz7. - - trait TCValue[M[_], A] { - implicit def self: M[A] - def M: TC[M] - - // instead of `foo(eii)`, we'll try `eii.foo` - def foo[M[_], A] = () - } - - - implicit def ToTCValue[M[_], A](ma: M[A])(implicit M0: TC[M]) = new TCValue[M, A] { - implicit val M = M0 - val self = ma - } - implicit def ToTCValueBin1[M[_, _], A, B](ma: M[A, B])(implicit M0: TC[({type λ[α]=M[A, α]})#λ]): TCValue[({type λ[α] = M[A, α]})#λ, B] = new TCValue[({type λ[α]=M[A, α]})#λ, B] { - implicit val M = M0 - val self = ma - } - implicit def ToTCValueBin2[M[_, _], A, B](ma: M[A, B])(implicit M0: TC[({type λ[α]=M[α, B]})#λ]): TCValue[({type λ[α]=M[α, B]})#λ, A] = new TCValue[({type λ[α]=M[α, B]})#λ, A] { - implicit val M = M0 - val self = ma - } - - - ToTCValueBin1(eii).foo - - // as expected, could not find implicit parameter - // ToTCValueBin2(eii).bar - - // error: implicit conversions are not applicable because they are ambiguous, both method ToTCValueBin1 ... and method ToTCValueBin2 - // annoying!! - // https://issues.scala-lang.org/browse/SI-3346 - // - // Works if we remove ToTCValueBin2 - // - eii.bar -} diff --git a/tests/untried/neg/t3346i.scala b/tests/untried/neg/t3346i.scala deleted file mode 100644 index 9ad254453..000000000 --- a/tests/untried/neg/t3346i.scala +++ /dev/null @@ -1,30 +0,0 @@ -import scala.language.implicitConversions - -// the classes involved -case class Z[U](a: U) -case class Intermediate[T, U](t: T, u: U) -class Implicit1[T](b: Implicit2[T]) -class Implicit2[T](c: Implicit3[T]) -class Implicit3[T](/* and so on */) - -object Test extends App { - // the base conversion - implicit def convertToZ[T](a: A[T])(implicit b: Implicit1[T]): Z[A[T]] = Z(a) - - // and the implicit chaining, don't you just love it? :D - // implicit1, with one alternative - implicit def implicit1[T <: Intermediate[_, _]](implicit b: Implicit2[T]) = new Implicit1[T](b) - // implicit2, with two alternatives - implicit def implicit2alt1[T <: Intermediate[_ <: String, _]](implicit c: Implicit3[T]) = new Implicit2[T](c) - implicit def implicit2alt2[T <: Intermediate[_ <: Double, _]](implicit c: Implicit3[T]) = new Implicit2[T](c) - // implicit3, with two alternatives - implicit def implicit3alt1[T <: Intermediate[_, _ <: Int]] = new Implicit3[T]() - implicit def implicit3alt2[T <: Intermediate[_ <: Double, _ <: AnyRef],X] = new Implicit3[T]() - - // and our targets - /** conversion here, with constraints */ - class A[T]() - - (new A).a - (new A[Nothing]).a -} diff --git a/tests/untried/neg/t3453.scala b/tests/untried/neg/t3453.scala deleted file mode 100644 index af7781894..000000000 --- a/tests/untried/neg/t3453.scala +++ /dev/null @@ -1,66 +0,0 @@ -// test shadowing of implicits by synonymous non-implicit symbols -// whether they be inherited, imported (explicitly or using a wildcard) or defined directly -class A -class B - -trait S { - implicit def aToB(a: A): B = new B -} - -class T1 extends S { - def x: B = { - val aToB = 3 - // ok: doesn't compile, because aToB method requires 'T.this.' prefix - //aToB(new A) - - // bug: compiles, using T.this.aToB, - // despite it not being accessible without a prefix - new A - } -} - -object O { - implicit def aToB(a: A): B = new B -} - -class T2a { - import O._ - - def x: B = { - val aToB = 3 - // ok: doesn't compile, because aToB method requires 'T.this.' prefix - //aToB(new A) - - // bug: compiles, using T.this.aToB, - // despite it not being accessible without a prefix - new A - } -} - -class T2b { - import O.aToB - - def x: B = { - val aToB = 3 - // ok: doesn't compile, because aToB method requires 'T.this.' prefix - //aToB(new A) - - // bug: compiles, using T.this.aToB, - // despite it not being accessible without a prefix - new A - } -} - -class T3 { - implicit def aToB(a: A): B = new B - - def x: B = { - val aToB = 3 - // ok: doesn't compile, because aToB method requires 'T.this.' prefix - //aToB(new A) - - // bug: compiles, using T.this.aToB, - // despite it not being accessible without a prefix - new A - } -} diff --git a/tests/untried/neg/t3653.scala b/tests/untried/neg/t3653.scala deleted file mode 100644 index 0bedc4fdc..000000000 --- a/tests/untried/neg/t3653.scala +++ /dev/null @@ -1,4 +0,0 @@ -class B { - def x(i: Int) = 3 - def x(implicit x: Int) = 5 -} diff --git a/tests/untried/neg/t3692-new.scala b/tests/untried/neg/t3692-new.scala deleted file mode 100644 index 6ecf4acb8..000000000 --- a/tests/untried/neg/t3692-new.scala +++ /dev/null @@ -1,20 +0,0 @@ -import scala.reflect.{ClassTag, classTag} -import java.lang.Integer - -object Tester { - def main(args: Array[String]) = { - val map = Map("John" -> 1, "Josh" -> 2) - new Tester().toJavaMap(map) - } -} - -class Tester { - private final def toJavaMap[T, V](map: Map[T, V])(implicit m1: ClassTag[T], m2: ClassTag[V]): java.util.Map[_, _] = { - map match { - case m0: Map[Int, Int] => new java.util.HashMap[Integer, Integer] - case m1: Map[Int, V] => new java.util.HashMap[Integer, V] - case m2: Map[T, Int] => new java.util.HashMap[T, Integer] - case _ => new java.util.HashMap[T, V] - } - } -} diff --git a/tests/untried/neg/t3776.scala b/tests/untried/neg/t3776.scala deleted file mode 100644 index e24b2fea6..000000000 --- a/tests/untried/neg/t3776.scala +++ /dev/null @@ -1,10 +0,0 @@ -object MyParser { - implicit def literal(s: String): Parser[String] = ??? - trait Parser[+T] - def parse[T](p: Parser[T], in: java.lang.CharSequence): Option[T] = ??? -} -object Test { - class ParsedAs(a: String) (implicit pattern: MyParser.Parser[_]) { - def parsedAs[T](v: T) = MyParser.parse(pattern, a).get someOperation v - } -} diff --git a/tests/untried/neg/t3854.scala b/tests/untried/neg/t3854.scala deleted file mode 100644 index e8db76c0a..000000000 --- a/tests/untried/neg/t3854.scala +++ /dev/null @@ -1,15 +0,0 @@ -class Bar[F[_]] extends Foo[F] { - def foo[G[_[_], _]](implicit M: M[G]): X[({type λ[α] = G[F, α] })#λ] = null -} -// vim: set ts=4 sw=4 et: - -trait M[F[_[_], _]] -trait N[F[_], G[_]] - -trait X[F[_]] { - def apply[A]: F[A] -} - -trait Foo[F[_]] { - def foo[G[_]](implicit n: N[G, F]): X[F] -} diff --git a/tests/untried/neg/t3977.scala b/tests/untried/neg/t3977.scala deleted file mode 100644 index 11a8cdba4..000000000 --- a/tests/untried/neg/t3977.scala +++ /dev/null @@ -1,13 +0,0 @@ -trait Bool { - type If[T] -} - -trait False extends Bool { - type If[F] = F -} - -class Field[E, N <: Bool](implicit val w: N#If[E]) { - type NoNull = Field[E, False] - - new NoNull -} diff --git a/tests/untried/neg/t3995.scala b/tests/untried/neg/t3995.scala deleted file mode 100644 index be169639d..000000000 --- a/tests/untried/neg/t3995.scala +++ /dev/null @@ -1,32 +0,0 @@ -class Lift { - def apply(f: F0): Unit = {} - - class F0 - object F0 { - implicit def f2f0(fn: String): F0 = ??? - } -} - -object Test { - val l = new Lift - val f = "" - - "": l.F0 // okay - - l.apply("") // okay - - { - val l = new Lift - l.apply("") // okay - } - - // fails trying to mkAttributedQualifier for pre = Skolem(_1 <: Lift with Singletom).F0 - // should this even have shown up in `companionImplicitMap`? It says that: - // - // "@return For those parts that refer to classes with companion objects that - // can be accessed with unambiguous stable prefixes, the implicits infos - // which are members of these companion objects." - // - // The skolem is stable, but it doen't seem much good to us - (new Lift).apply("") -} diff --git a/tests/untried/neg/t4079/t4079_1.scala b/tests/untried/neg/t4079/t4079_1.scala deleted file mode 100644 index cbae86478..000000000 --- a/tests/untried/neg/t4079/t4079_1.scala +++ /dev/null @@ -1,33 +0,0 @@ -trait Functor[F[_]] { - def map[A,B](fa: F[A], f: A => B): F[B] -} - -trait ComposeT[F[_],G[_]] { - type Apply[A] = F[G[A]] -} - -case class Compose[F[_],G[_]]() { - def Functor(implicit f: Functor[F], g: Functor[G]): Functor[ComposeT[F,G]#Apply] = - new Functor[ComposeT[F,G]#Apply] { - def map[A,B](c: ComposeT[F,G]#Apply[A], h: A => B) = - f.map(c, (x:G[A]) => g.map(x,h)) - } -} - -object Cat { - def compose[F[_],G[_]] = Compose[F,G]() -} - -object Functors { - implicit val List = new Functor[List] { - def map[A,B](fa: List[A], f: A => B): List[B] = fa map f - } - implicit val Option = new Functor[Option] { - def map[A,B](fa: Option[A], f: A => B): Option[B] = fa map f - } -} - -object Main { - import Functors._ - val cf = Cat.compose[List,Option].Functor -} diff --git a/tests/untried/neg/t4079/t4079_2.scala b/tests/untried/neg/t4079/t4079_2.scala deleted file mode 100644 index 9069f0ab4..000000000 --- a/tests/untried/neg/t4079/t4079_2.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test { - Cat.compose[List,Option].Functor -} diff --git a/tests/untried/neg/t4270.scala b/tests/untried/neg/t4270.scala deleted file mode 100644 index 2c7c71d8c..000000000 --- a/tests/untried/neg/t4270.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test1 { - object A { implicit val x: Int = 1 } - import A.x - def x: Int = 0 - implicitly[Int] -} diff --git a/tests/untried/neg/t4271.scala b/tests/untried/neg/t4271.scala deleted file mode 100644 index 46ae3ad9e..000000000 --- a/tests/untried/neg/t4271.scala +++ /dev/null @@ -1,12 +0,0 @@ -object foo { - object Donotuseme - implicit def Ensuring[A](x: A) = Donotuseme - implicit def doubleWrapper(x: Int) = Donotuseme - implicit def floatWrapper(x: Int) = Donotuseme - implicit def intWrapper(x: Int) = Donotuseme - implicit def longWrapper(x: Int) = Donotuseme - implicit def ArrowAssoc[A](x: A) = Donotuseme - 3 to 5 - 5 ensuring true - 3 -> 5 -} diff --git a/tests/untried/neg/t4457_1.scala b/tests/untried/neg/t4457_1.scala deleted file mode 100644 index 11dae1097..000000000 --- a/tests/untried/neg/t4457_1.scala +++ /dev/null @@ -1,33 +0,0 @@ -object ImplicitConvAmbiguity2 { - - class N[T] - class NE[T] extends N[T] - class NN[T] extends N[T] - class NQ[T] extends N[T] - class NZ[T] extends N[T] - class AA[A] - class BB[A] - - implicit def conv1(i: Float) = new NE[Float] - implicit def conv3(op: AA[java.util.TooManyListenersException]) = new N[java.util.TooManyListenersException] - implicit def conv4(op: AA[Float]) = new N[Float] - implicit def conv7(i: Float) = new NZ[Float] - implicit def conv5(e: BB[java.util.GregorianCalendar]) = new N[java.util.GregorianCalendar] - - // These two will be in conflict in typeMe1 - def aFunc[A](a: NE[A]) = new AA[A] - def aFunc[A](a: NZ[A]) = new AA[Float] - - def aFunc[A](a: NN[A]) = new BB[A] - def aFunc[A](a: NQ[A]) = new BB[A] - - def bFunc[T](e1: N[T]) = {} - - def typeMe1: Unit = { - val x = aFunc(4F) - bFunc(x) - } - def typeMe2: Unit = { - bFunc(aFunc(4F)) - } -} diff --git a/tests/untried/neg/t4457_2.scala b/tests/untried/neg/t4457_2.scala deleted file mode 100644 index f2664cc14..000000000 --- a/tests/untried/neg/t4457_2.scala +++ /dev/null @@ -1,33 +0,0 @@ -object ImplicitConvAmbiguity2 { - - class N[T] - class NE[T] extends N[T] - class NN[T] extends N[T] - class NQ[T] extends N[T] - class NZ[T] extends N[T] - class AA[A] - class BB[A] - - implicit def conv1(i: Float) = new NE[Float] - implicit def conv3(op: AA[java.util.TooManyListenersException]) = new N[java.util.TooManyListenersException] - implicit def conv4(op: AA[Float]) = new N[Float] - implicit def conv7(i: Float) = new NZ[Float] - implicit def conv5(e: BB[java.util.GregorianCalendar]) = new N[java.util.GregorianCalendar] - - def aFunc[A](a: NE[A]) = new AA[A] - def aFunc[A](a: NZ[A]) = new AA[A] - - def aFunc[A](a: NN[A]) = new BB[A] - - def aFunc[A](a: NQ[A]) = new BB[A] - - def bFunc[T](e1: N[T]) = {} - - def typeMe2: Unit = { - val x = aFunc(4F) - bFunc(x) - } - def typeMe1: Unit = { - bFunc(aFunc(4F)) - } -} diff --git a/tests/untried/neg/t4568.scala b/tests/untried/neg/t4568.scala deleted file mode 100644 index 6fda28736..000000000 --- a/tests/untried/neg/t4568.scala +++ /dev/null @@ -1,13 +0,0 @@ -object SubList { - implicit def sublistable[A](x: List[A]) = new SubListable(x) - - class SubListable[A](x: List[A]) { - def isSubListOf(y: List[A]) = { - x match { - case Nil => true - case h :: t => y.contains(h) && (t.isSubListOf(y.drop(y.indexOf(h) + 1))) - } - } - } - -} diff --git a/tests/untried/neg/t4882.scala b/tests/untried/neg/t4882.scala deleted file mode 100644 index 4e58ef787..000000000 --- a/tests/untried/neg/t4882.scala +++ /dev/null @@ -1,3 +0,0 @@ -class Foo(value: Int) { - implicit def this(a: String) = this(a.toInt) -} diff --git a/tests/untried/neg/t5318.scala b/tests/untried/neg/t5318.scala deleted file mode 100644 index 5be82a02a..000000000 --- a/tests/untried/neg/t5318.scala +++ /dev/null @@ -1,8 +0,0 @@ -class CompilerHang { - trait TC[M[_]] - trait S[A] - - implicit def tc[M[_]](implicit M0: TC[M]): TC[S] = null - def breakage[F[_] : TC] = 0 - breakage // type checker doesn't terminate, should report inference failure -} diff --git a/tests/untried/neg/t5318b.scala b/tests/untried/neg/t5318b.scala deleted file mode 100644 index a2d55b1e4..000000000 --- a/tests/untried/neg/t5318b.scala +++ /dev/null @@ -1,8 +0,0 @@ -class DivergingImplicitReported { - trait TC[M] - trait S - - implicit def tc[M](implicit M0: TC[M]): TC[S] = null - def breakage[F: TC] = 0 - breakage // correct: diverging implicit expansion -} diff --git a/tests/untried/neg/t5318c.scala b/tests/untried/neg/t5318c.scala deleted file mode 100644 index 477a9874a..000000000 --- a/tests/untried/neg/t5318c.scala +++ /dev/null @@ -1,14 +0,0 @@ -class CompilerHang { - trait TC[M[_]] - trait S[A] - - class C[M[_]] { - type TCM = TC[M] - } - - // A nefarious implicit, to motivate the removal of `&& sym.owner.isTerm` from - // `isFreeTypeParamNoSkolem`. - implicit def tc[x[_], CC[x[_]] <: C[x]](implicit M0: CC[x]#TCM): CC[x]#TCM = null - def breakage[F[_] : TC] = 0 - breakage // type checker doesn't terminate, should report inference failure -} diff --git a/tests/untried/neg/t5340.scala b/tests/untried/neg/t5340.scala deleted file mode 100644 index b283f1333..000000000 --- a/tests/untried/neg/t5340.scala +++ /dev/null @@ -1,29 +0,0 @@ -class Poly { - class E - object E { - implicit def conv(value: Any): E = sys.error("") - } -} - -object MyApp { - val r: Poly = sys.error("") - val s: Poly = sys.error("") - val b: r.E = sys.error("") - - // okay - s.E.conv(b): s.E - - // compilation fails with error below - println(b: s.E) - - // amb prefix: MyApp.s.type#class E MyApp.r.type#class E - // amb prefix: MyApp.s.type#class E MyApp.r.type#class E - // ../test/pending/run/t5310.scala:17: error: type mismatch; - // found : MyApp.r.E - // required: MyApp.s.E - // println(b: s.E) - // ^ - - // The type error is as expected, but the `amb prefix` should be logged, - // rather than printed to standard out. -} diff --git a/tests/untried/neg/t5354.scala b/tests/untried/neg/t5354.scala deleted file mode 100644 index 99b565015..000000000 --- a/tests/untried/neg/t5354.scala +++ /dev/null @@ -1,15 +0,0 @@ -package object foo { - implicit def x123: Bippy = new Bippy("x") -} -package foo { - class Bippy(override val toString: String){ } - class Dingus { - def f1 = { - implicit def z: Bippy = new Bippy("z") - implicitly[Bippy] - } - } - object Test extends App { - println(new Dingus().f1) - } -} diff --git a/tests/untried/neg/t5376.scala b/tests/untried/neg/t5376.scala deleted file mode 100644 index 9dcaccbf1..000000000 --- a/tests/untried/neg/t5376.scala +++ /dev/null @@ -1,24 +0,0 @@ -object Test { - object O1 { implicit def f(s: String): Int = 1 } - object O2 { implicit def f(s: String): Int = 2 } - object O3 { def f(s: String): Int = 3 } - - // Import two implicits with the same name in the same scope. - def m1 = { - import O1._ - import O2._ - - // Implicit usage compiles. - "a": Int - } - - // Import one implict and one non-implicit method with the - // same name in the same scope. - def m2 = { - import O1._ - import O3._ - - // Implicit usage compiles. - "a": Int - } -} diff --git a/tests/untried/neg/t550.scala b/tests/untried/neg/t550.scala deleted file mode 100644 index 5212a2658..000000000 --- a/tests/untried/neg/t550.scala +++ /dev/null @@ -1,9 +0,0 @@ -abstract class Monoid[a] { - def unit: a -} - -object test { - def sum[a](xs: List)(implicit m: Monoid[a]): a = - if (xs.isEmpty) m.unit else xs.head - sum(List(1,2,3)) -} diff --git a/tests/untried/neg/t5553_2.scala b/tests/untried/neg/t5553_2.scala deleted file mode 100644 index 16958aec8..000000000 --- a/tests/untried/neg/t5553_2.scala +++ /dev/null @@ -1,59 +0,0 @@ -class Base[T] - -object Foo1 { - def apply[T](x: Int): Base[T] = new Base[T] - def apply[T](x: Int, z: String="abc"): String = z -} - -object Foo2 { - def apply[T](a: Int): Base[T] = new Base[T] - def apply[T]: String = "abc" -} - -object Foo3 { - def apply[T](x: Int): Base[T] = new Base[T] - def apply[T](implicit z: String): String = z -} - -object Foo4 { - def apply[T](x: Int): Base[T] = new Base[T] - def apply[T](x: Int)(implicit z: String): Base[T] = new Base[T] -} - -object Test1 { - def test1[T] = Foo1[T](1) - def test2[T]: String = Foo1[T](1) - def test3[T]: Base[T] = Foo1[T](1) - def test4[T]: Int = Foo1[T](1) - -} - -object Test2 { - def test5[T] = Foo2[T] - def test6[T]: String = Foo2[T] - def test7[T]: Base[T] = Foo2[T] - def test8[T]: Int = Foo2[T] -} - -object Test3 { - implicit val v: String = "abc" - def test9[T]: Int = Foo3[T] - def test10[T]: Base[T] = Foo3[T] - def test11[T]: String = Foo3[T] - def test12[T] = Foo3[T] -} - -object Test4 { - def test13[T]: Int = Foo3[T] - def test14[T]: Base[T] = Foo3[T] - def test15[T]: String = Foo3[T] - def test16[T] = Foo3[T] -} - -object Test5 { - def test17[T] = Foo4[T](1) - def test18[T]: Base[T] = Foo4[T](1) - //def test19[T]: String = Foo4[T](1) // #5554 -} - - diff --git a/tests/untried/neg/t5554.scala b/tests/untried/neg/t5554.scala deleted file mode 100644 index d279abea7..000000000 --- a/tests/untried/neg/t5554.scala +++ /dev/null @@ -1,39 +0,0 @@ -class Base[T] - -object Foo1 { - def apply[T](x: Int): Base[T] = new Base[T] - def apply[T](x: Int)(implicit z: String): String = z -} - -object Foo2 { - def apply[T](x: Int): Base[T] = new Base[T] - def apply[T](x: Int)(implicit z: String): Base[T] = new Base[T] -} - -object Test1 { - def test1[T]: Int = Foo1[T](1) - def test2[T]: Base[T] = Foo1[T](1) - def test3[T]: String = Foo1[T](1) - def test4[T] = Foo1[T](1) -} - -object Test2 { - implicit val v: String = "foo" - def test5[T]: Int = Foo1[T](1) - def test6[T]: Base[T] = Foo1[T](1) - def test7[T]: String = Foo1[T](1) - def test8[T] = Foo1[T](1) -} - -object Test3 { - def test9[T]: String = Foo2[T](1) - def test10[T]: Base[T] = Foo2[T](1) - def test11[T] = Foo2[T](1) -} - -object Test4 { - implicit val v: String = "foo" - def test12[T]: String = Foo2[T](1) - def test13[T]: Base[T] = Foo2[T](1) - def test14[T] = Foo2[T](1) -} diff --git a/tests/untried/neg/t5578.scala b/tests/untried/neg/t5578.scala deleted file mode 100644 index ce72f32d5..000000000 --- a/tests/untried/neg/t5578.scala +++ /dev/null @@ -1,39 +0,0 @@ -trait Base { - type Rep[T] -} - -trait Expressions { - // constants/symbols (atomic) - abstract class Exp[T] - // ... - case class Sym[T](n: Int) extends Exp[T] - - // operations (composite, defined in subtraits) - abstract class Def[T] - - // additional members for managing encountered definitions - def findOrCreateDefinition[T](rhs: Def[T]): Sym[T] - implicit def toExp[T:Manifest](d: Def[T]): Exp[T] = findOrCreateDefinition(d) -} - -trait BaseExp extends Base with Expressions { - type Rep[T] = Exp[T] - - def findOrCreateDefinition[T](rhs: Def[T]): Sym[T] = null // stub -} - -trait NumericOps extends Base { - def plus[T](x: Rep[T], y: Rep[T]): Rep[T] -} - -trait NumericOpsExp extends BaseExp { - case class Plus[T:Numeric](x: Rep[T], y: Rep[T]) - extends Def[T] - - def plus[T: Numeric](x: Rep[T], y: Rep[T]): Rep[T] = Plus[T](x,y) - - // Possible solutions: -// def plus[T: Numeric: Manifest](x: Rep[T], y: Rep[T]): Rep[T] = Plus[T](x, y) -// def plus[T](x: Rep[T], y: Rep[T])(implicit num: Numeric[T], man: Manifest[T]): Rep[T] = Plus(x,y) - -} diff --git a/tests/untried/neg/t5728.scala b/tests/untried/neg/t5728.scala deleted file mode 100644 index 99337d06d..000000000 --- a/tests/untried/neg/t5728.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Test { - - implicit class Foo - - implicit def Foo = new Foo - -} diff --git a/tests/untried/neg/t5801.scala b/tests/untried/neg/t5801.scala deleted file mode 100644 index d452222ac..000000000 --- a/tests/untried/neg/t5801.scala +++ /dev/null @@ -1,16 +0,0 @@ -import scala.sth - -object Test extends App { - def foo(a: Int)(implicit b: sth.Sth): Unit = {} - foo(1) - - def bar(x: Int)(implicit y: Int): sth.Sth = null - bar(1) - - def meh(x: Int)(implicit a: sth.Sth, b: Int): Unit = {} - meh(1) - - def meh2(x: Int)(implicit b: Int, a: sth.Sth): Unit = {} - meh2(1) -} - diff --git a/tests/untried/neg/t5803.scala b/tests/untried/neg/t5803.scala deleted file mode 100644 index f818272f8..000000000 --- a/tests/untried/neg/t5803.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test { - class Foo()(implicit ev: Nothing) - new Foo(): String -} diff --git a/tests/untried/neg/t5839.scala b/tests/untried/neg/t5839.scala deleted file mode 100644 index d3a5d4b25..000000000 --- a/tests/untried/neg/t5839.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Test { - def goo[T](x: Int => T): T = x(1) - implicit def f(x: Int): String = "" - def foo(x: Int): Int = x + 1 - val x: String = goo(foo _) - def foo(x: String => String) = 1 -} diff --git a/tests/untried/neg/t5892.scala b/tests/untried/neg/t5892.scala deleted file mode 100644 index 5e3b2f313..000000000 --- a/tests/untried/neg/t5892.scala +++ /dev/null @@ -1,25 +0,0 @@ -import language.implicitConversions - -class annot(a: String) extends annotation.StaticAnnotation - -class C[@annot(false) X] { - implicit def b2s(b: Boolean): String = "" -} - -class D[@annot(b2s(false)) X] { - implicit def b2s(b: Boolean): String = "" -} - -@annot(false) class E { - implicit def b2s(b: Boolean): String = "" -} - -@annot(b2s(false)) class F { - implicit def b2s(b: Boolean): String = "" -} - -object T { - implicit def b2s(b: Boolean): String = "" - @annot(false) val x = 0 - @annot(b2s(false)) val y = 0 -} diff --git a/tests/untried/neg/t5903a/Macros_1.scala b/tests/untried/neg/t5903a/Macros_1.scala deleted file mode 100644 index 5d084ceed..000000000 --- a/tests/untried/neg/t5903a/Macros_1.scala +++ /dev/null @@ -1,28 +0,0 @@ -import scala.reflect.macros.whitebox.Context -import language.experimental.macros - -trait Tree -case object SomeTree extends Tree - -object NewQuasiquotes { - implicit class QuasiquoteInterpolation(c: StringContext) { - object nq { - def unapply(t: Tree): Any = macro QuasiquoteMacros.unapplyImpl - } - } -} - -object QuasiquoteMacros { - def unapplyImpl(c: Context)(t: c.Tree) = { - import c.universe._ - q""" - new { - def isEmpty = false - def get = this - def _1 = SomeTree - def _2 = SomeTree - def unapply(t: Tree) = this - }.unapply($t) - """ - } -} diff --git a/tests/untried/neg/t5903a/Test_2.scala b/tests/untried/neg/t5903a/Test_2.scala deleted file mode 100644 index 4d78dfb5e..000000000 --- a/tests/untried/neg/t5903a/Test_2.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test extends App { - import NewQuasiquotes._ - SomeTree match { - case nq"$x + $y + $z" => println((x, y)) - } -} diff --git a/tests/untried/neg/t5903b/Macros_1.scala b/tests/untried/neg/t5903b/Macros_1.scala deleted file mode 100644 index 6ce49c022..000000000 --- a/tests/untried/neg/t5903b/Macros_1.scala +++ /dev/null @@ -1,23 +0,0 @@ -import scala.reflect.macros.blackbox.Context -import language.experimental.macros - -object Interpolation { - implicit class TestInterpolation(c: StringContext) { - object t { - def unapply[T](x: T): Any = macro Macros.unapplyImpl[T] - } - } -} - -object Macros { - def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = { - import c.universe._ - q""" - new { - def isEmpty = false - def get = "2" - def unapply(x: String) = this - }.unapply($x) - """ - } -} diff --git a/tests/untried/neg/t5903b/Test_2.scala b/tests/untried/neg/t5903b/Test_2.scala deleted file mode 100644 index 0f6f80d32..000000000 --- a/tests/untried/neg/t5903b/Test_2.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test extends App { - import Interpolation._ - 2 match { - case t"$x" => println(x) - } -} diff --git a/tests/untried/neg/t5903c/Macros_1.scala b/tests/untried/neg/t5903c/Macros_1.scala deleted file mode 100644 index 4792f0045..000000000 --- a/tests/untried/neg/t5903c/Macros_1.scala +++ /dev/null @@ -1,26 +0,0 @@ -import scala.reflect.macros.blackbox.Context -import language.experimental.macros - -object Interpolation { - implicit class TestInterpolation(c: StringContext) { - object t { - def unapply[T](x: T): Any = macro Macros.unapplyImpl[T] - } - } -} - -object Macros { - def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = { - import c.universe._ - if (!(c.weakTypeOf[Int] =:= c.weakTypeOf[T])) c.abort(c.enclosingPosition, s"${c.weakTypeOf[T]} is not supported") - else { - q""" - new { - def isEmpty = false - def get = 2 - def unapply(x: Int) = this - }.unapply($x) - """ - } - } -} diff --git a/tests/untried/neg/t5903c/Test_2.scala b/tests/untried/neg/t5903c/Test_2.scala deleted file mode 100644 index a1fd31dd4..000000000 --- a/tests/untried/neg/t5903c/Test_2.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test extends App { - import Interpolation._ - "2" match { - case t"$x" => println(x) - } -} diff --git a/tests/untried/neg/t5903d/Macros_1.scala b/tests/untried/neg/t5903d/Macros_1.scala deleted file mode 100644 index 3500c2a78..000000000 --- a/tests/untried/neg/t5903d/Macros_1.scala +++ /dev/null @@ -1,23 +0,0 @@ -import scala.reflect.macros.blackbox.Context -import language.experimental.macros - -object Interpolation { - implicit class TestInterpolation(c: StringContext) { - object t { - def unapply(x: Int): Any = macro Macros.unapplyImpl - } - } -} - -object Macros { - def unapplyImpl(c: Context)(x: c.Tree) = { - import c.universe._ - q""" - class Match(x: Int) { - def isEmpty = false - def get = x - } - new { def unapply(x: Int) = new Match(x) }.unapply($x) - """ - } -} diff --git a/tests/untried/neg/t5903d/Test_2.scala b/tests/untried/neg/t5903d/Test_2.scala deleted file mode 100644 index 95c717a9d..000000000 --- a/tests/untried/neg/t5903d/Test_2.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test extends App { - import Interpolation._ - 42 match { - case t"$x" => println(x) - } -} diff --git a/tests/untried/neg/t5903e/Macros_1.scala b/tests/untried/neg/t5903e/Macros_1.scala deleted file mode 100644 index a64ff7e0b..000000000 --- a/tests/untried/neg/t5903e/Macros_1.scala +++ /dev/null @@ -1,25 +0,0 @@ -import scala.reflect.macros.whitebox.Context -import language.experimental.macros - -object Interpolation { - implicit class TestInterpolation(c: StringContext) { - object t { - def unapply(x: Int): Any = macro Macros.unapplyImpl - } - } -} - -object Macros { - def unapplyImpl(c: Context)(x: c.Tree) = { - import c.universe._ - q""" - new { - class Match(x: Int) extends AnyVal { - def isEmpty = false - def get = x - } - def unapply(x: Int) = new Match(x) - }.unapply($x) - """ - } -} diff --git a/tests/untried/neg/t5903e/Test_2.scala b/tests/untried/neg/t5903e/Test_2.scala deleted file mode 100644 index d69d47243..000000000 --- a/tests/untried/neg/t5903e/Test_2.scala +++ /dev/null @@ -1,6 +0,0 @@ -class C { - import Interpolation._ - 42 match { - case t"$x" => println(x) - } -} diff --git a/tests/untried/neg/t591.scala b/tests/untried/neg/t591.scala deleted file mode 100644 index 0f0b02395..000000000 --- a/tests/untried/neg/t591.scala +++ /dev/null @@ -1,41 +0,0 @@ -abstract class BaseList { - type Node <: BaseNode; - - - abstract class BaseNode { - protected def self : Node; - private[BaseList] def self00 = self; - def dirty : Unit = {} - def replaceWith(node : Node) = {} - } - - implicit def baseNode2Node(bnode : BaseNode): Node = bnode.self00; - - -} - - -trait BaseFlow extends BaseList { - type Node <: BFNode; - type Flow <: FlowBase; - type Output <: OutputBase; - type Input <: InputBase; - - abstract class FlowBase { - - } - trait OutputBase extends FlowBase { - - } - trait InputBase extends FlowBase { - - } - - trait BFNode extends BaseNode { - private var input : Input = _; - private var output : Output = _; - - def input_=(in : Input) = {} - - } -} diff --git a/tests/untried/neg/t6074.scala b/tests/untried/neg/t6074.scala deleted file mode 100644 index 8c14f00f1..000000000 --- a/tests/untried/neg/t6074.scala +++ /dev/null @@ -1,6 +0,0 @@ -class A private () { } -class B { } -object T { - implicit def a2b(a: A): B = null - def t = new A() -} diff --git a/tests/untried/neg/t6083.scala b/tests/untried/neg/t6083.scala deleted file mode 100644 index 1de18e652..000000000 --- a/tests/untried/neg/t6083.scala +++ /dev/null @@ -1,7 +0,0 @@ -object conv { - implicit def i2s(i: Int): String = "" -} -import conv._ - -class annot(value: String) extends annotation.ClassfileAnnotation -@annot(101) class C diff --git a/tests/untried/neg/t6120.scala b/tests/untried/neg/t6120.scala deleted file mode 100644 index 425f09db4..000000000 --- a/tests/untried/neg/t6120.scala +++ /dev/null @@ -1,7 +0,0 @@ -class A { - implicit class BooleanOps(val b: Boolean) { - @deprecated("bobo", "2.11.0") def bippy() = 5 - } - def f = null == null bippy - def g = true.bippy -} diff --git a/tests/untried/neg/t6227.scala b/tests/untried/neg/t6227.scala deleted file mode 100644 index 46416839d..000000000 --- a/tests/untried/neg/t6227.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test { - implicit case class IntOps( i: Int ) { - def twice = i * 2 - } -} - diff --git a/tests/untried/neg/t6263.scala b/tests/untried/neg/t6263.scala deleted file mode 100644 index 6575185b5..000000000 --- a/tests/untried/neg/t6263.scala +++ /dev/null @@ -1,6 +0,0 @@ -class C(val a: Any) extends AnyVal -class A { - implicit def c2AnyRef(c: C): AnyRef = new {} - val c = new C(0) - type t = c.type -} diff --git a/tests/untried/neg/t631.scala b/tests/untried/neg/t631.scala deleted file mode 100644 index 631db3eb1..000000000 --- a/tests/untried/neg/t631.scala +++ /dev/null @@ -1,3 +0,0 @@ -implicit object Test { - Console.println("foo") -} diff --git a/tests/untried/neg/t6335.scala b/tests/untried/neg/t6335.scala deleted file mode 100644 index 6c898af5b..000000000 --- a/tests/untried/neg/t6335.scala +++ /dev/null @@ -1,7 +0,0 @@ -object ImplicitClass { - def X(i: Int): Unit = {} - implicit class X(val x: Int) { def xx = x } - - def Z[A](i: A): Unit = {} - implicit class Z[A](val i: A) { def zz = i } -} diff --git a/tests/untried/neg/t6436.scala b/tests/untried/neg/t6436.scala deleted file mode 100644 index 2c4050253..000000000 --- a/tests/untried/neg/t6436.scala +++ /dev/null @@ -1,9 +0,0 @@ -object quasiquotes { - implicit def foo1(ctx: StringContext) = new { def q = ??? } - implicit def foo2(ctx: StringContext) = new { def q = ??? } -} - -object Test extends App { - import quasiquotes._ - println(q"a") -} diff --git a/tests/untried/neg/t6436b.scala b/tests/untried/neg/t6436b.scala deleted file mode 100644 index 8023329e9..000000000 --- a/tests/untried/neg/t6436b.scala +++ /dev/null @@ -1,9 +0,0 @@ -object quasiquotes { - implicit def foo1(ctx: StringContext) = new { def q = ??? } - implicit def foo2(ctx: StringContext) = new { def q = ??? } -} - -object Test extends App { - import quasiquotes._ - println(StringContext("a").q()) -} diff --git a/tests/untried/neg/t6567.scala b/tests/untried/neg/t6567.scala deleted file mode 100644 index 650e5e39a..000000000 --- a/tests/untried/neg/t6567.scala +++ /dev/null @@ -1,11 +0,0 @@ -class A -class B - -object Test { - val a: A = null - implicit def a2b(a: A) = new B - - Option[B](a) - - val b: Option[B] = Option(a) -} diff --git a/tests/untried/neg/t6597.scala b/tests/untried/neg/t6597.scala deleted file mode 100644 index dde53bcc8..000000000 --- a/tests/untried/neg/t6597.scala +++ /dev/null @@ -1,5 +0,0 @@ -object Test { - trait T extends Any - implicit case class Quux(value: Int) extends AnyVal with T - object Quux -} diff --git a/tests/untried/neg/t6666d.scala b/tests/untried/neg/t6666d.scala deleted file mode 100644 index 49a688f91..000000000 --- a/tests/untried/neg/t6666d.scala +++ /dev/null @@ -1,18 +0,0 @@ - -import scala.collection.immutable.TreeMap -import scala.math.Ordering - -class Test[K](param:TreeMap[K,Int]){ - def this() = this({ - implicit object TreeOrd extends Ordering[K](){ - def compare(a: K, b: K) = { - -1 - } - } - new TreeMap[K, Int]() - }) -} - -object Test extends App { - new Test() -} diff --git a/tests/untried/neg/t6667.scala b/tests/untried/neg/t6667.scala deleted file mode 100644 index fb857ebd3..000000000 --- a/tests/untried/neg/t6667.scala +++ /dev/null @@ -1,10 +0,0 @@ -class C -object C { - implicit def companion = new C -} - -object Test { - implicit val inScope1, inScope2 = new C - implicitly[C]: Unit // C.companion was used; whereas the ambiguity should abort the implicit search. - implicitly[C] // ambiguity reported, rather than falling back to C.companion -} diff --git a/tests/untried/neg/t6667b.scala b/tests/untried/neg/t6667b.scala deleted file mode 100644 index db31c0a9b..000000000 --- a/tests/untried/neg/t6667b.scala +++ /dev/null @@ -1,25 +0,0 @@ -object Test { - abstract class Box { - val value: Int - } - - implicit val a: Box = new Box { - val value= 1 - } - - def main(args: Array[String]): Unit = { - implicit val b: Box= new Box { - val value= 2 - } - - new Object { - new Test() - } - // compare with: - new Test() - } -} - -class Test()(implicit x: Test.Box) { - println(x.value) -} diff --git a/tests/untried/neg/t6889.scala b/tests/untried/neg/t6889.scala deleted file mode 100644 index ef1963669..000000000 --- a/tests/untried/neg/t6889.scala +++ /dev/null @@ -1,18 +0,0 @@ -package bippy { - trait Bippy[A] extends Any -} -package foo { - package object unrelated { - implicit def bippyDingo[A](x: bippy.Bippy[A]): AnyRef = Nil - } - package unrelated { - trait Unrelated - } -} - -object Test { - trait Dingo extends Any with bippy.Bippy[foo.unrelated.Unrelated] - - def f(x: Dingo): AnyRef = x // fail - no conversion to AnyRef - var x: Int = null // fail - no conversion from Null -} diff --git a/tests/untried/neg/t692.scala b/tests/untried/neg/t692.scala deleted file mode 100644 index 24e1d2fea..000000000 --- a/tests/untried/neg/t692.scala +++ /dev/null @@ -1,20 +0,0 @@ -abstract class test3 { - trait Type0[+T0]; - trait Type[T0] extends Type0[T]; - trait ClassType0[+C <: AnyRef] extends Type0[C]; - abstract class RefType[C <: AnyRef] extends Type[C]; - case class ObjectType() extends RefType[AnyRef]; - abstract class ClassType[C <: Z, Z <: AnyRef](zuper : RefType[Z]) extends RefType[C]; - - - case class FooType() extends ClassType[Foo,AnyRef](ObjectType()); - implicit def typeOfFoo = FooType(); - - case class BarType[T3 <: Foo](tpeT : RefType[T3]) extends ClassType[Bar[T3],Foo](FooType); - implicit def typeOfBar[T4 <: Foo](implicit elem : RefType[T4]) : RefType[Bar[T4]] = - BarType(elem); - - - class Foo[A <: AnyRef]; - class Bar[A <: Foo](implicit tpeA : Type[A]) extends Foo; -} diff --git a/tests/untried/neg/t6931/Macros_1.scala b/tests/untried/neg/t6931/Macros_1.scala deleted file mode 100644 index 9e167e61d..000000000 --- a/tests/untried/neg/t6931/Macros_1.scala +++ /dev/null @@ -1,15 +0,0 @@ -import scala.language.experimental.macros -import scala.reflect.macros.blackbox.Context - -object Macros { - implicit class Error(ctx: StringContext) { - def err(args: Any*): Unit = macro impl - } - - def impl(c: Context)(args: c.Tree*): c.Tree = { - import c.universe._ - val q"Macros.Error(scala.StringContext.apply($arg)).err()" = c.macroApplication - for (i <- 1 to 3) c.error(arg.pos.withPoint(arg.pos.point + i - 1), i.toString) - q"()" - } -} diff --git a/tests/untried/neg/t6931/Test_2.scala b/tests/untried/neg/t6931/Test_2.scala deleted file mode 100644 index dbd7fc260..000000000 --- a/tests/untried/neg/t6931/Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends App { - import Macros._ - err"123" -} diff --git a/tests/untried/neg/t696.scala b/tests/untried/neg/t696.scala deleted file mode 100644 index ca76f7ef6..000000000 --- a/tests/untried/neg/t696.scala +++ /dev/null @@ -1,7 +0,0 @@ -object TypeUtil0 { - trait Type[+T] - implicit def WithType[S,T](implicit tpeS : Type[S], tpeT : Type[T]) : Type[S with T] = null - def as[T](x : Any)(implicit tpe : Type[T]) = null - as[Any](null) - def foo[X]() = as[X](null) -} diff --git a/tests/untried/neg/t712.scala b/tests/untried/neg/t712.scala deleted file mode 100644 index 6f2627743..000000000 --- a/tests/untried/neg/t712.scala +++ /dev/null @@ -1,19 +0,0 @@ -trait A { - type Node <: NodeImpl; - implicit def coerce(n : NodeImpl) = n.self; - trait NodeImpl { - def self : Node; - } -} -trait B extends A { - type Parent <: ParentImpl; - implicit def coerce(p : ParentImpl) = p.self; - trait ParentImpl; - type Symbol; - trait SymbolImpl { - def scope : Int; - } - implicit def coerceSym(sym : Symbol) : SymbolImpl; - var s : Symbol = _; - val s_scope = s.scope; -} diff --git a/tests/untried/neg/t7289.scala b/tests/untried/neg/t7289.scala deleted file mode 100644 index ad9340055..000000000 --- a/tests/untried/neg/t7289.scala +++ /dev/null @@ -1,39 +0,0 @@ -object Test extends App { - trait Schtroumpf[T] - - implicit def schtroumpf[T, U <: Coll[T], Coll[X] <: Traversable[X]] - (implicit minorSchtroumpf: Schtroumpf[T]): Schtroumpf[U] = ??? - - implicit val qoo: Schtroumpf[Int] = new Schtroumpf[Int]{} - implicitly[Schtroumpf[Nil.type]] -} - -/* -info1 = {scala.tools.nsc.typechecker.Implicits$ImplicitInfo@3468}"qoo: => Test.Schtroumpf[Int]" -info2 = {scala.tools.nsc.typechecker.Implicits$ImplicitInfo@3469}"schtroumpf: [T, U <: Coll[T], Coll[_] <: Traversable[_]](implicit minorSchtroumpf: Test.Schtroumpf[T])Test.Schtroumpf[U]" -isStrictlyMoreSpecific(info1, info2) - isSubType(Test.Schtroumpf[Int], Test.Schtroumpf[U] forSome { T; U <: Coll[T]; Coll[_] <: Traversable[_] }) - isAsSpecificValueType(Test.Schtroumpf[Int], Test.Schtroumpf[U], undef2 = List(type T, type U, type Coll)) - - val et: ExistentialType = Test.Schtroumpf[U] forSome { T; U <: Coll[T]; Coll[_] <: Traversable[_] } - val tp1 = Test.Schtroumpf[Int] - et.withTypeVars(isSubType(tp1, _, depth)) - solve() - tvars = tList(=?Nothing, =?Int, =?=?Int) - - -[ create] ?T ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] ) -[ create] ?U ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] ) -[ create] ?Coll ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] ) -[ setInst] Nothing ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], T=Nothing ) -[ setInst] scala.collection.immutable.Nil.type( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], U=scala.collection.immutable.Nil.type ) -[ setInst] =?scala.collection.immutable.Nil.type( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], Coll==?scala.collection.immutable.Nil.type ) -[ create] ?T ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] ) -[ setInst] Int ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], T=Int ) -[ create] ?T ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] ) -[ create] ?U ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] ) -[ create] ?Coll ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] ) -[ setInst] Nothing ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], T=Nothing ) -[ setInst] Int ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], U=Int ) -[ setInst] =?Int ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], Coll==?Int ) -*/ diff --git a/tests/untried/neg/t7289_status_quo.scala b/tests/untried/neg/t7289_status_quo.scala deleted file mode 100644 index e1f9a9f8a..000000000 --- a/tests/untried/neg/t7289_status_quo.scala +++ /dev/null @@ -1,23 +0,0 @@ -// record the status quo after this fix -// not clear to @adriaanm why an upper-bounded existential in an invariant position -// is different from putting that upper bound in a covariant position -object Test1 { - trait Ext[T] - implicit def f[A, Coll <: CC[A], CC[X] <: Traversable[X]](implicit xi: Ext[A]): Ext[Coll] = ??? - implicit val m: Ext[List[List[Int]]] = new Ext[List[List[Int]]]{} - - implicitly[Ext[List[Int]]] // fails - not found - implicitly[Ext[List[List[Int]]]] // compiles - implicitly[Ext[List[List[List[Int]]]]] // fails - not found - - // Making Ext[+T] should incur the same behavior as these. (so says @paulp) - implicitly[Ext[_ <: List[Int]]] // compiles - implicitly[Ext[_ <: List[List[Int]]]] // fails - ambiguous - implicitly[Ext[_ <: List[List[List[Int]]]]] // compiles - - // But, we currently get: - trait ExtCov[+T] - implicitly[ExtCov[List[Int]]] // fails - not found - implicitly[ExtCov[List[List[Int]]]] // fails - not found - implicitly[ExtCov[List[List[List[Int]]]]] // fails - not found -} diff --git a/tests/untried/neg/t729.scala b/tests/untried/neg/t729.scala deleted file mode 100644 index 83e7f4cd1..000000000 --- a/tests/untried/neg/t729.scala +++ /dev/null @@ -1,23 +0,0 @@ -trait Parser { - type Node <: NodeImpl; - implicit def coerce(n : NodeImpl) = n.self; - trait NodeImpl { - def self : Node; - } - trait Link { - def from : NodeImpl; - } -} - -trait ScalaParserAutoEdit extends Parser { - type Node <: NodeImpl; - implicit def coerce(node : NodeImpl) = node.self; - trait NodeImpl extends super[Parser].NodeImpl { - def self : Node; - def foo = { - var link : Link = null; - val xxx : NodeImpl = coerce(link.from); - val yyy : NodeImpl = link.from; - } - } -} diff --git a/tests/untried/neg/t7509.scala b/tests/untried/neg/t7509.scala deleted file mode 100644 index 3cba801ea..000000000 --- a/tests/untried/neg/t7509.scala +++ /dev/null @@ -1,4 +0,0 @@ -object NMWE { - def crash[R <: AnyRef](f: R)(implicit ev: R): Any = ??? - crash(42) -} diff --git a/tests/untried/neg/t7519-b/Mac_1.scala b/tests/untried/neg/t7519-b/Mac_1.scala deleted file mode 100644 index 55b583d24..000000000 --- a/tests/untried/neg/t7519-b/Mac_1.scala +++ /dev/null @@ -1,14 +0,0 @@ -// get expected error message without package declaration -package ex - -import scala.language.experimental.macros -import scala.reflect.macros._ - -object IW { - def foo(a: String): String = ??? -} -object Mac { - def mac(s: String): String = macro macImpl - def macImpl(c: Context)(s: c.Expr[String]): c.Expr[String] = - c.universe.reify(IW.foo(s.splice)) -} diff --git a/tests/untried/neg/t7519-b/Use_2.scala b/tests/untried/neg/t7519-b/Use_2.scala deleted file mode 100644 index 0d63eeed5..000000000 --- a/tests/untried/neg/t7519-b/Use_2.scala +++ /dev/null @@ -1,10 +0,0 @@ -import scala.language.implicitConversions - -trait Q -trait K - -object Use { - implicit def cd[T](p: T)(implicit ev: T => K): Q = ??? - val x: Q = ex.Mac.mac("asdf") -} - diff --git a/tests/untried/neg/t7519.scala b/tests/untried/neg/t7519.scala deleted file mode 100644 index aea0f35d8..000000000 --- a/tests/untried/neg/t7519.scala +++ /dev/null @@ -1,18 +0,0 @@ -class C { - implicit def conversion(m: Int)(implicit nada: Nothing): String = ??? - - class C { // rename class to get correct error, can't find implicit: Nothing. - locally(0 : String) // was: "value conversion is not a member of C.this.C" - } -} - -object Test2 { - trait T; trait U - new T { - implicit def conversion(m: Int)(implicit nada: Nothing): String = ??? - - new U { // nested anonymous classes also share a name. - locally(0 : String) // was: "value conversion is not a member of U" - } - } -} diff --git a/tests/untried/neg/t7721.scala b/tests/untried/neg/t7721.scala deleted file mode 100644 index 9ac7b60f0..000000000 --- a/tests/untried/neg/t7721.scala +++ /dev/null @@ -1,140 +0,0 @@ -import scala.language.reflectiveCalls - -trait A { - trait Concrete { def conco: Int = 1 } - type Foo <: { def bippy: Int } - type Bar <: { def barry: Int } - - implicit def barTag: scala.reflect.ClassTag[Bar] - - def f1(x: Any) = x match { - case x: Foo with Concrete => x.bippy + x.conco - case _ => -1 - } - def f2(x: Any) = x match { - case x: Concrete with Foo => x.bippy + x.conco - case _ => -1 - } - def f3(x: Any) = x match { - case x: Foo with Bar => x.bippy + x.barry - case _ => -1 - } - def f4(x: Any) = x match { - case x: (Foo @unchecked) => x.bippy // warns, suppressed - case _ => -1 - } - def f5(x: Any) = x match { - case x: (Bar @unchecked) => x.barry // warns (but about the "outer reference"), suppressed - case _ => -1 - } -} - -trait B extends A { - type Foo <: { def bippy: Int ; def dingo: Int } - type Bar <: { def barry: Int ; def bongo: Int } - - override implicit def barTag: scala.reflect.ClassTag[Bar] - - override def f1(x: Any) = x match { - case x: Foo with Concrete => x.bippy + x.dingo + x.conco - case _ => -1 - } - override def f2(x: Any) = x match { - case x: Concrete with Foo => x.bippy + x.dingo + x.conco - case _ => -1 - } - override def f3(x: Any) = x match { - case x: Foo with Bar with Concrete => x.bippy + x.barry + x.dingo + x.conco + x.bongo - case _ => -1 - } - override def f4(x: Any) = x match { - case x: (Foo @unchecked) => x.bippy + x.dingo // warns, suppressed - case _ => -1 - } - override def f5(x: Any) = x match { - case x: (Bar @unchecked) => x.barry + x.bongo // warns (but about the "outer reference"), suppressed - case _ => -1 - } -} - -object Test { - abstract class Base extends A { - trait Foo { - def bippy = 2 - def dingo = 3 - } - trait Bar { - def barry = 2 - def bongo = 3 - } - implicit def barTag: scala.reflect.ClassTag[Bar] = scala.reflect.ClassTag(classOf[Bar]) - - def run(): Unit = { - println("f1") - wrap(f1(new Concrete {})) - wrap(f1(new Foo {})) - wrap(f1(new Bar {})) - wrap(f1(new Foo with Concrete {})) - wrap(f1(new Concrete with Foo {})) - - println("\nf2") - wrap(f2(new Concrete {})) - wrap(f2(new Foo {})) - wrap(f2(new Bar {})) - wrap(f2(new Foo with Concrete {})) - wrap(f2(new Concrete with Foo {})) - wrap(f2(new Bar with Concrete {})) - wrap(f2(new Concrete with Bar {})) - wrap(f2(new Concrete with Foo with Bar {})) - wrap(f2(new Foo with Bar with Concrete {})) - - println("\nf3") - wrap(f3(new Concrete {})) - wrap(f3(new Foo {})) - wrap(f3(new Bar {})) - wrap(f3(new Foo with Concrete {})) - wrap(f3(new Concrete with Foo {})) - wrap(f3(new Bar with Concrete {})) - wrap(f3(new Concrete with Bar {})) - wrap(f3(new Concrete with Foo with Bar {})) - wrap(f3(new Foo with Bar with Concrete {})) - - println("\nf4") - wrap(f4(new Concrete {})) - wrap(f4(new Foo {})) - wrap(f4(new Bar {})) - wrap(f4(new Foo with Concrete {})) - wrap(f4(new Concrete with Foo {})) - wrap(f4(new Bar with Concrete {})) - wrap(f4(new Concrete with Bar {})) - wrap(f4(new Concrete with Foo with Bar {})) - wrap(f4(new Foo with Bar with Concrete {})) - - println("\nf5") - wrap(f5(new Concrete {})) - wrap(f5(new Foo {})) - wrap(f5(new Bar {})) - wrap(f5(new Foo with Concrete {})) - wrap(f5(new Concrete with Foo {})) - wrap(f5(new Bar with Concrete {})) - wrap(f5(new Concrete with Bar {})) - wrap(f5(new Concrete with Foo with Bar {})) - wrap(f5(new Foo with Bar with Concrete {})) - } - } - - object ao extends Base - object bo extends Base with B - - private def wrap(body: => Any): Unit = { - try println(body) - catch { case ex: NoSuchMethodException => println(ex) } - } - - def main(args: Array[String]): Unit = { - ao.run() - bo.run() - } -} - -// java.lang.NoSuchMethodException: Test$$anon$1.bippy() diff --git a/tests/untried/neg/t8024.scala b/tests/untried/neg/t8024.scala deleted file mode 100644 index b4c2c5ebb..000000000 --- a/tests/untried/neg/t8024.scala +++ /dev/null @@ -1,14 +0,0 @@ -package p - -trait NRoot[A] - -object `package` { - final def sqrt(x: Double): Double = Math.sqrt(x) - final def sqrt[A](a: A)(implicit ev: NRoot[A]): A = ??? -} - -object FastComplex { - import java.lang.Math.sqrt - - sqrt(0d) -} diff --git a/tests/untried/neg/t8024b.scala b/tests/untried/neg/t8024b.scala deleted file mode 100644 index cf3d49636..000000000 --- a/tests/untried/neg/t8024b.scala +++ /dev/null @@ -1,17 +0,0 @@ -package p - -trait NRoot[A] - -object FastComplex { - final def sqrt(x: Double): Double = Math.sqrt(x) - final def sqrt[A](a: A)(implicit ev: NRoot[A]): A = ??? - - object Inner { - import java.lang.Math.sqrt - - // wrong message: - // error: reference to sqrt is ambiguous; - // it is both defined in object FastComplex and imported subsequently by - sqrt(0d) - } -} diff --git a/tests/untried/neg/t8104/Macros_1.scala b/tests/untried/neg/t8104/Macros_1.scala deleted file mode 100644 index 129c8db16..000000000 --- a/tests/untried/neg/t8104/Macros_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.whitebox.Context - -object Macros { - def impl[T](c: Context)(implicit T: c.WeakTypeTag[T]) = { - import c.universe._ - import definitions._ - val fields = T.tpe.decls.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x } - val Repr = appliedType(TupleClass(fields.length).asType.toType, fields.map(_.info)) - q"new Generic[$T]{ type Repr = $Repr }" - } -} diff --git a/tests/untried/neg/t8104/Test_2.scala b/tests/untried/neg/t8104/Test_2.scala deleted file mode 100644 index a3bd94018..000000000 --- a/tests/untried/neg/t8104/Test_2.scala +++ /dev/null @@ -1,21 +0,0 @@ -trait Generic[T] { type Repr } -object Generic { - type Aux[T, Repr0] = Generic[T] { type Repr = Repr0 } - import scala.language.experimental.macros - implicit def materializeGeneric[T]: Generic[T] = macro Macros.impl[T] -} - -object Test extends App { - case class C(x: Int, y: Int) - - import scala.reflect.runtime.universe._ - def reprify[T, Repr](x: T)(implicit generic: Generic.Aux[T, Repr], tag: WeakTypeTag[Repr]) = println(tag) - reprify(C(40, 2)) - - // this is a compilation error at the moment as explained in SI-8104 - // because matchesPt in implicit search says that depoly(<type of materializeGeneric>) isn't a subtype of Generic.Aux[C, (Int, Int)] - // which is rightfully so, because depoly only replaces type parameters, not type members with wildcard types - // however in the future we might want to relax the matchesPt check, so this might start compiling - // therefore, if you've broken this test, then you should be happy, because most likely you've just enabled an interesting use case! - implicitly[Generic.Aux[C, (Int, Int)]] -} diff --git a/tests/untried/neg/t8372.scala b/tests/untried/neg/t8372.scala deleted file mode 100644 index 60a674f4d..000000000 --- a/tests/untried/neg/t8372.scala +++ /dev/null @@ -1,10 +0,0 @@ -class t8372 { - // failed with "error: tpe T1 is an unresolved spliceable type"; that was caused by - // misguided type inference of type parameters in ArrayOps.unzip - // the type inference failed because the order of implicit arguments was wrong - // the evidence that T <: (T1, T2) came as last argument so it couldn't guide the - // type inference early enough - def unzip[T1, T2](a: Array[(T1, T2)]) = a.unzip - // the same as above - def unzip3[T1, T2, T3](a: Array[(T1, T2, T3)]): (Array[T1], Array[T2], Array[T3]) = a.unzip3 -} diff --git a/tests/untried/neg/viewtest.scala b/tests/untried/neg/viewtest.scala deleted file mode 100644 index 5e7d624d2..000000000 --- a/tests/untried/neg/viewtest.scala +++ /dev/null @@ -1,116 +0,0 @@ -package test - -/** A trait for totally ordered data. - */ -trait Ordered[+a] { - - /** Result of comparing `this' with operand `that'. - * returns `x' where - * x < 0 iff this < that - * x == 0 iff this == that - * x > 0 iff this > that - */ - def compareTo [b >: a <% Ordered[b]](that: b): Int - - def < [b >: a <% Ordered[b]](that: b): Boolean = (this compareTo that) < 0 - - def > [b >: a <% Ordered[b]](that: b): Boolean = (this compareTo that) > 0 - - def <= [b >: a <% Ordered[b]](that: b): Boolean = (this compareTo that) <= 0 - - def >= [b >: a <% Ordered[b]](that: b): Boolean = (this compareTo that) >= 0 -} - - -object O { - - implicit def view1(x: String): Ordered[String] = new Ordered[String] { - def compareTo [b >: String <% Ordered[b]](y: b): Int = y match { - case y1: String => x compareTo y1 - case _ => -(y compareTo x) - } - } - implicit def view2(x: Char): Ordered[Char] = new Ordered[Char] { - def compareTo [b >: Char <% Ordered[b]](y: b): Int = y match { - case y1: Char => x - y1 - case _ => -(y compareTo x) - } - } - - implicit def view3[a <% Ordered[a]](x: List[a]): Ordered[List[a]] = - new Ordered[List[a]] { - def compareTo [b >: List[a] <% Ordered[b]](y: b): Int = y match { - case y1: List[a] => compareLists(x, y1) - case _ => -(y compareTo x) - } - private def compareLists(xs: List[a], ys: List[a]): Int = { - if (xs.isEmpty && ys.isEmpty) 0 - else if (xs.isEmpty) -1 - else if (ys.isEmpty) 1 - else { - val s = xs.head compareTo ys.head - if (s != 0) s - else compareLists(xs.tail, ys.tail) - } - } - } - implicit def view4[a](x: a): a = x -} - -abstract class Tree[+a <% Ordered[a]] { - def insert[b >: a <% Ordered[b]](x: b): Tree[b] - def elements: List[a] -} - -object Empty extends Tree[Nothing] { - def insert[b >: Nothing <% Ordered[b]](x: b): Tree[b] = new Node(x, Empty, Empty) - def elements: List[Nothing] = List() -} - -class Node[a <% Ordered[a]](elem: a, l: Tree[a], r: Tree[a]) extends Tree[a] { - def insert[b >: a <% Ordered[b]](x: b): Tree[b] = - if (x == elem) this - else if (x < elem) new Node(elem, l insert x, r) - else new Node(elem, l, r insert x) - def elements: List[a] = - l.elements ::: List(elem) ::: r.elements -} - -case class Str(elem: String) extends Ordered[Str] { - def compareTo[b >: Str <% Ordered[b]](that: b): Int = that match { - case that1: Str => this.elem compareTo that1.elem - case _ => -(that compareTo this) - } -} - -object Test { - import O._ - - private def toCharList(s: String): List[Char] = - if (s.length() == 0) List() - else s.charAt(0) :: toCharList(s.substring(1)) - - def main(args: Array[String]) = { - { - var t: Tree[String] = Empty - for (s <- args) { - t = t insert s - } - Console.println(t.elements) - } - { - var t: Tree[Str] = Empty - for (s <- args) { - t = t insert Str(s) - } - Console.println(t.elements) - } - { - var t: Tree[List[Char]] = Empty - for (s <- args) { - t = t insert toCharList(s) - } - Console.println(t.elements) - } - } -} diff --git a/tests/untried/neg/warn-unused-imports.scala b/tests/untried/neg/warn-unused-imports.scala deleted file mode 100644 index b7a2f1c41..000000000 --- a/tests/untried/neg/warn-unused-imports.scala +++ /dev/null @@ -1,125 +0,0 @@ -class Bippo { - def length: Int = 123 - class Tree -} - -package object p1 { - class A - implicit class B(val s: String) { def bippy = s } - val c: Bippo = new Bippo - type D = String -} -package object p2 { - class A - implicit class B(val s: String) { def bippy = s } - val c: Bippo = new Bippo - type D = Int -} - -trait NoWarn { - { - import p1._ // no warn - println("abc".bippy) - } - - { - import p1._ // no warn - println(new A) - } - - { - import p1.B // no warn - println("abc".bippy) - } - - { - import p1._ // no warn - import c._ // no warn - println(length) - } - - { - import p1._ // no warn - import c._ // no warn - val x: Tree = null - println(x) - } - - { - import p1.D // no warn - val x: D = null - println(x) - } -} - -trait Warn { - { - import p1.A // warn - println(123) - } - - { - import p1.{ A, B } // warn on A - println("abc".bippy) - } - - { - import p1.{ A, B } // warn on both - println(123) - } - - { - import p1._ // no warn (technically this could warn, but not worth the effort to unroll unusedness transitively) - import c._ // warn - println(123) - } - - { - import p1._ // warn - println(123) - } - - { - class Tree - import p1._ // no warn - import c._ // warn - val x: Tree = null - println(x) - } - - { - import p1.c._ // warn - println(123) - } -} - -trait Nested { - { - import p1._ // warn - trait Warn { // warn about unused local trait for good measure - import p2._ - println(new A) - println("abc".bippy) - } - println("") - } - - { - import p1._ // no warn - trait NoWarn { - import p2.B // no warn - println("abc".bippy) - println(new A) - } - println(new NoWarn { }) - } - - { - import p1.A // warn - trait Warn { - import p2.A - println(new A) - } - println(new Warn { }) - } -} |