diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/pos/t5330.scala | 22 | ||||
-rw-r--r-- | test/files/pos/t5330b.scala | 6 | ||||
-rw-r--r-- | test/files/pos/t5330c.scala | 5 | ||||
-rw-r--r-- | test/files/pos/t6014.scala | 13 | ||||
-rw-r--r-- | test/files/run/showraw_aliases.check | 2 | ||||
-rw-r--r-- | test/files/run/showraw_aliases.scala | 15 | ||||
-rw-r--r-- | test/files/run/t6150.scala | 44 |
7 files changed, 107 insertions, 0 deletions
diff --git a/test/files/pos/t5330.scala b/test/files/pos/t5330.scala new file mode 100644 index 0000000000..813acd4b83 --- /dev/null +++ b/test/files/pos/t5330.scala @@ -0,0 +1,22 @@ +trait FM[A] { + def map(f: A => Any) +} + +trait M[A] extends FM[A] { + def map(f: A => Any) +} + +trait N[A] extends FM[A] + +object test { + def kaboom(xs: M[_]) = xs map (x => ()) // missing parameter type. + + def okay1[A](xs: M[A]) = xs map (x => ()) + def okay2(xs: FM[_]) = xs map (x => ()) + def okay3(xs: N[_]) = xs map (x => ()) +} + +class CC2(xs: List[_]) { + def f(x1: Any, x2: Any) = null + def g = xs map (x => f(x, x)) +} diff --git a/test/files/pos/t5330b.scala b/test/files/pos/t5330b.scala new file mode 100644 index 0000000000..dbeb165cd8 --- /dev/null +++ b/test/files/pos/t5330b.scala @@ -0,0 +1,6 @@ +abstract trait Base { + def foo: this.type +}; +class Derived[T] extends Base { + def foo: Nothing = sys.error("!!!") +} diff --git a/test/files/pos/t5330c.scala b/test/files/pos/t5330c.scala new file mode 100644 index 0000000000..af31f3dfd1 --- /dev/null +++ b/test/files/pos/t5330c.scala @@ -0,0 +1,5 @@ +object t5330c { + val s: Set[_ >: Char] = Set('A') + s forall ("ABC" contains _) + s.forall( c => "ABC".toSeq.contains( c )) +} diff --git a/test/files/pos/t6014.scala b/test/files/pos/t6014.scala new file mode 100644 index 0000000000..46e03bb552 --- /dev/null +++ b/test/files/pos/t6014.scala @@ -0,0 +1,13 @@ +object Test { + case class CC[T](key: T) + type Alias[T] = Seq[CC[T]] + + def f(xs: Seq[CC[_]]) = xs map { case CC(x) => CC(x) } // ok + def g(xs: Alias[_]) = xs map { case CC(x) => CC(x) } // fails + // ./a.scala:11: error: missing parameter type for expanded function + // The argument types of an anonymous function must be fully known. (SLS 8.5) + // Expected type was: ? + // def g(xs: Alias[_]) = xs map { case CC(x) => CC(x) } // fails + // ^ + // one error found +}
\ No newline at end of file diff --git a/test/files/run/showraw_aliases.check b/test/files/run/showraw_aliases.check new file mode 100644 index 0000000000..1838bf9bec --- /dev/null +++ b/test/files/run/showraw_aliases.check @@ -0,0 +1,2 @@ +Block(List(Import(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), List(ImportSelector(newTermName("universe"), 52, newTermName("ru"), 64)))), Select(Select(Select(Select(Ident(scala), scala.reflect), scala.reflect.runtime), scala.reflect.runtime.package), [newTermName("universe") aka newTermName("ru")])) +Block(List(Import(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), List(ImportSelector(newTermName("universe"), 52, newTermName("ru"), 64)))), Select(Select(Select(Select(Ident(scala#<id>), scala.reflect#<id>), scala.reflect.runtime#<id>), scala.reflect.runtime.package#<id>), [newTermName("universe")#<id> aka newTermName("ru")])) diff --git a/test/files/run/showraw_aliases.scala b/test/files/run/showraw_aliases.scala new file mode 100644 index 0000000000..3a68ca37b2 --- /dev/null +++ b/test/files/run/showraw_aliases.scala @@ -0,0 +1,15 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.ToolBox + +object Test extends App { + val tb = runtimeMirror(getClass.getClassLoader).mkToolBox() + val tree = tb.parse(""" + import scala.reflect.runtime.{universe => ru} + ru + """) + val ttree = tb.typeCheck(tree) + + def stabilize(s: String) = """#\d+""".r.replaceAllIn(s, "#<id>") + println(showRaw(ttree)) + println(stabilize(showRaw(ttree, printIds = true))) +}
\ No newline at end of file diff --git a/test/files/run/t6150.scala b/test/files/run/t6150.scala new file mode 100644 index 0000000000..bd8af5d460 --- /dev/null +++ b/test/files/run/t6150.scala @@ -0,0 +1,44 @@ + + + + +object Test { + import collection.{ immutable, mutable, generic } + def TheOneTrueCBF = collection.IndexedSeq.ReusableCBF + + val cbf1 = implicitly[generic.CanBuildFrom[immutable.Vector[Int], Int, collection.IndexedSeq[Int]]] + val cbf2 = implicitly[generic.CanBuildFrom[immutable.IndexedSeq[Int], Int, collection.IndexedSeq[Int]]] + val cbf3 = implicitly[generic.CanBuildFrom[collection.IndexedSeq[Int], Int, collection.IndexedSeq[Int]]] + + val cbf4 = implicitly[generic.CanBuildFrom[immutable.Vector[Int], Int, immutable.IndexedSeq[Int]]] + val cbf5 = implicitly[generic.CanBuildFrom[immutable.Vector[Int], Int, immutable.Vector[Int]]] + val cbf6 = implicitly[generic.CanBuildFrom[immutable.IndexedSeq[Int], Int, immutable.IndexedSeq[Int]]] + + def check[C](v: C) = { + assert(v == Vector(1, 2, 3, 4)) + assert(v.isInstanceOf[Vector[_]]) + } + def checkRealMccoy(x: AnyRef) = { + assert(x eq TheOneTrueCBF, cbf1) + } + + val v = immutable.Vector(1, 2, 3) + val iiv: immutable.IndexedSeq[Int] = immutable.Vector(1, 2, 3) + val iv: IndexedSeq[Int] = immutable.Vector(1, 2, 3) + + def main(args: Array[String]): Unit = { + List(cbf1, cbf2, cbf3, cbf4, cbf5, cbf6) foreach checkRealMccoy + check(v.:+(4)(cbf1)) + check(v.:+(4)(cbf2)) + check(v.:+(4)(cbf3)) + + check(iiv.:+(4)(cbf2)) + check(iiv.:+(4)(cbf3)) + + check(iv.:+(4)(cbf3)) + } +} + + + + |