aboutsummaryrefslogtreecommitdiff
path: root/tests/pending/run/fail-non-value-types.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-05-12 18:30:53 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-05-12 18:30:53 +0200
commit89bacb9c25a58454ff1878e67f7ea07ffc8c269f (patch)
tree51f1ff6c66aebe1b6109b1cffcc2bb8e4cf760a3 /tests/pending/run/fail-non-value-types.scala
parenta0fa33deafbea1bf53edc068c5ed9db5592822f9 (diff)
downloaddotty-89bacb9c25a58454ff1878e67f7ea07ffc8c269f.tar.gz
dotty-89bacb9c25a58454ff1878e67f7ea07ffc8c269f.tar.bz2
dotty-89bacb9c25a58454ff1878e67f7ea07ffc8c269f.zip
Run tests as they were in scala.
Diffstat (limited to 'tests/pending/run/fail-non-value-types.scala')
-rw-r--r--tests/pending/run/fail-non-value-types.scala40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/pending/run/fail-non-value-types.scala b/tests/pending/run/fail-non-value-types.scala
new file mode 100644
index 000000000..d9a69e17c
--- /dev/null
+++ b/tests/pending/run/fail-non-value-types.scala
@@ -0,0 +1,40 @@
+import scala.reflect.runtime.universe._
+
+class ImaginaryCanBuildFrom[-From, -Elem, +To]
+class CompletelyIndependentList[+A] {
+ type Repr <: CompletelyIndependentList[A]
+ def map[B, That](f: A => B)(implicit cbf: ImaginaryCanBuildFrom[Repr, B, That]): That = ???
+ def distinct(): CompletelyIndependentList[A] = ???
+}
+
+object Test {
+ var failed = false
+ def expectFailure[T](body: => T): Boolean = {
+ try { val res = body ; failed = true ; println(res + " failed to fail.") ; false }
+ catch { case _: AssertionError => true }
+ }
+
+ /** Attempt to use a method type as a type argument - expect failure. */
+ def tcon[T: TypeTag](args: Type*) = appliedType(typeOf[T].typeConstructor, args.toList)
+
+ def cil = typeOf[CompletelyIndependentList[Int]]
+ def map = cil.member(TermName("map")).asMethod
+ def distinct = cil.member(TermName("distinct")).asMethod
+
+ def main(args: Array[String]): Unit = {
+ // Need the assert in there to fail.
+ // expectFailure(println(tcon[CompletelyIndependentList[Int]](map)))
+ // expectFailure(tcon[CompletelyIndependentList[Int]](distinct))
+
+ // Why is the first map signature printing showing an
+ // uninitialized symbol?
+ //
+ // [B <: <?>, That <: <?>](f: <?>)(implicit cbf: <?>)That
+ //
+
+ println(map.info)
+ println(map.infoIn(cil))
+ println(distinct.info)
+ if (failed) sys.exit(1)
+ }
+}