From 89bacb9c25a58454ff1878e67f7ea07ffc8c269f Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Tue, 12 May 2015 18:30:53 +0200 Subject: Run tests as they were in scala. --- tests/pending/run/fail-non-value-types.scala | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/pending/run/fail-non-value-types.scala (limited to 'tests/pending/run/fail-non-value-types.scala') 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) + } +} -- cgit v1.2.3