diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/fail-non-value-types.check | 2 | ||||
-rw-r--r-- | test/files/run/fail-non-value-types.scala | 30 | ||||
-rw-r--r-- | test/files/run/macro-reify-type/Macros_1.scala | 2 |
3 files changed, 33 insertions, 1 deletions
diff --git a/test/files/run/fail-non-value-types.check b/test/files/run/fail-non-value-types.check new file mode 100644 index 0000000000..1c2d7dcf1b --- /dev/null +++ b/test/files/run/fail-non-value-types.check @@ -0,0 +1,2 @@ +[B, That](f: A => B)(implicit cbf: ImaginaryCanBuildFrom[CompletelyIndependentList.this.Repr,B,That])That +()CompletelyIndependentList[A] 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..d9aa5c01ca --- /dev/null +++ b/test/files/run/fail-non-value-types.scala @@ -0,0 +1,30 @@ +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) + + val map = typeOf[CompletelyIndependentList[Int]].member("map": TermName).typeSignature + val distinct = typeOf[CompletelyIndependentList[Int]].member("distinct": TermName).typeSignature + + def main(args: Array[String]): Unit = { + expectFailure(println(tcon[CompletelyIndependentList[Int]](map))) + expectFailure(tcon[CompletelyIndependentList[Int]](distinct)) + println(map) + println(distinct) + if (failed) sys.exit(1) + } +} diff --git a/test/files/run/macro-reify-type/Macros_1.scala b/test/files/run/macro-reify-type/Macros_1.scala index aeec9fc97c..06de05735d 100644 --- a/test/files/run/macro-reify-type/Macros_1.scala +++ b/test/files/run/macro-reify-type/Macros_1.scala @@ -17,7 +17,7 @@ object StaticReflect { case NoSymbol => c.error(c.enclosingPosition, s"No member called $nameName in $clazz.") ; reify(ru.NoType) case member => val mtpe = member typeSignatureIn clazz - val mtag = c.reifyType(c.runtimeUniverse, Select(c.runtimeUniverse, newTermName("rootMirror")), mtpe) + val mtag = c.reifyType(treeBuild.mkRuntimeUniverseRef, Select(treeBuild.mkRuntimeUniverseRef, newTermName("rootMirror")), mtpe) val mtree = Select(mtag, newTermName("tpe")) c.Expr[ru.Type](mtree) |