diff options
author | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2012-09-29 17:06:06 +0200 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2012-09-29 17:06:06 +0200 |
commit | be49f36154efa78c3dcbeba394aa6ec2b5e764ec (patch) | |
tree | ae83e7ed20574b2ece619f650125d841a2f1a386 /test/files/run/fail-non-value-types.scala | |
parent | ac311c4f7be3353c8f13396d4c7d21f2c0887005 (diff) | |
parent | e46ceca8a0166a459cb336da83ae71afe69dc025 (diff) | |
download | scala-be49f36154efa78c3dcbeba394aa6ec2b5e764ec.tar.gz scala-be49f36154efa78c3dcbeba394aa6ec2b5e764ec.tar.bz2 scala-be49f36154efa78c3dcbeba394aa6ec2b5e764ec.zip |
Merge remote-tracking branch 'scala/2.10.x' into 2.10.0-wip
Diffstat (limited to 'test/files/run/fail-non-value-types.scala')
-rw-r--r-- | test/files/run/fail-non-value-types.scala | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/files/run/fail-non-value-types.scala b/test/files/run/fail-non-value-types.scala new file mode 100644 index 0000000000..51198a5f31 --- /dev/null +++ b/test/files/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("map": TermName).asMethod + def distinct = cil.member("distinct": TermName).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.typeSignature) + println(map.typeSignatureIn(cil)) + println(distinct.typeSignature) + if (failed) sys.exit(1) + } +} |