diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-09-14 08:12:32 -0700 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-09-14 08:12:32 -0700 |
commit | 65358306ba2538a6954767952058d6281ef139e2 (patch) | |
tree | 51a8bc0a388c578e96b97a24c8ef272dafe5c0d4 /test/files/neg | |
parent | 52abc96229e624f6b31ee30ffced945ff652c994 (diff) | |
parent | 511578d7938a57b0756501cd565435083739fb39 (diff) | |
download | scala-65358306ba2538a6954767952058d6281ef139e2.tar.gz scala-65358306ba2538a6954767952058d6281ef139e2.tar.bz2 scala-65358306ba2538a6954767952058d6281ef139e2.zip |
Merge pull request #1295 from scalamacros/ticket/6323
improvements for type tags
Diffstat (limited to 'test/files/neg')
17 files changed, 59 insertions, 28 deletions
diff --git a/test/files/neg/interop_abstypetags_arenot_classmanifests.scala b/test/files/neg/interop_abstypetags_arenot_classmanifests.scala index c8567be5d4..5d88c90ffd 100644 --- a/test/files/neg/interop_abstypetags_arenot_classmanifests.scala +++ b/test/files/neg/interop_abstypetags_arenot_classmanifests.scala @@ -1,11 +1,11 @@ import scala.reflect.runtime.universe._ object Test extends App { - def absTypeTagIsnotClassManifest[T: AbsTypeTag] = { + def weakTypeTagIsnotClassManifest[T: WeakTypeTag] = { println(classManifest[T]) } - absTypeTagIsnotClassManifest[Int] - absTypeTagIsnotClassManifest[String] - absTypeTagIsnotClassManifest[Array[Int]] + weakTypeTagIsnotClassManifest[Int] + weakTypeTagIsnotClassManifest[String] + weakTypeTagIsnotClassManifest[Array[Int]] }
\ No newline at end of file diff --git a/test/files/neg/interop_abstypetags_arenot_classtags.scala b/test/files/neg/interop_abstypetags_arenot_classtags.scala index e3911c1588..de1f8657b6 100644 --- a/test/files/neg/interop_abstypetags_arenot_classtags.scala +++ b/test/files/neg/interop_abstypetags_arenot_classtags.scala @@ -2,11 +2,11 @@ import scala.reflect.runtime.universe._ import scala.reflect.{ClassTag, classTag} object Test extends App { - def absTypeTagIsnotClassTag[T: AbsTypeTag] = { + def weakTypeTagIsnotClassTag[T: WeakTypeTag] = { println(classTag[T]) } - absTypeTagIsnotClassTag[Int] - absTypeTagIsnotClassTag[String] - absTypeTagIsnotClassTag[Array[Int]] + weakTypeTagIsnotClassTag[Int] + weakTypeTagIsnotClassTag[String] + weakTypeTagIsnotClassTag[Array[Int]] }
\ No newline at end of file diff --git a/test/files/neg/interop_abstypetags_arenot_manifests.scala b/test/files/neg/interop_abstypetags_arenot_manifests.scala index 77a95048fd..1ca3673ce4 100644 --- a/test/files/neg/interop_abstypetags_arenot_manifests.scala +++ b/test/files/neg/interop_abstypetags_arenot_manifests.scala @@ -1,11 +1,11 @@ import scala.reflect.runtime.universe._ object Test extends App { - def absTypeTagIsnotManifest[T: AbsTypeTag] = { + def weakTypeTagIsnotManifest[T: WeakTypeTag] = { println(manifest[T]) } - absTypeTagIsnotManifest[Int] - absTypeTagIsnotManifest[String] - absTypeTagIsnotManifest[Array[Int]] + weakTypeTagIsnotManifest[Int] + weakTypeTagIsnotManifest[String] + weakTypeTagIsnotManifest[Array[Int]] }
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-context-bounds.check b/test/files/neg/macro-invalidsig-context-bounds.check index 5d42ebc515..eb5d833bc0 100644 --- a/test/files/neg/macro-invalidsig-context-bounds.check +++ b/test/files/neg/macro-invalidsig-context-bounds.check @@ -1,7 +1,7 @@ Macros_Test_1.scala:2: error: macro implementation has wrong shape:
required: (c: scala.reflect.macros.Context): c.Expr[Any]
found : (c: scala.reflect.macros.Context)(implicit evidence$2: Numeric[U]): c.universe.Literal
-macro implementations cannot have implicit parameters other than AbsTypeTag evidences
+macro implementations cannot have implicit parameters other than WeakTypeTag evidences
def foo[U] = macro Impls.foo[U]
^
one error found
diff --git a/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala b/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala index 5aa9a7eaf9..c066c485b1 100644 --- a/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala @@ -2,7 +2,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.AbsTypeTag: Numeric](c: Ctx) = { + def foo[U: c.WeakTypeTag: Numeric](c: Ctx) = { import c.universe._ Literal(Constant(42)) } diff --git a/test/files/neg/macro-invalidsig-implicit-params.check b/test/files/neg/macro-invalidsig-implicit-params.check index 62156770e4..ca35e62cd7 100644 --- a/test/files/neg/macro-invalidsig-implicit-params.check +++ b/test/files/neg/macro-invalidsig-implicit-params.check @@ -1,7 +1,7 @@ Impls_Macros_1.scala:18: error: macro implementation has wrong shape:
required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Unit]
found : (c: scala.reflect.macros.Context)(implicit x: c.Expr[Int]): c.Expr[Unit]
-macro implementations cannot have implicit parameters other than AbsTypeTag evidences
+macro implementations cannot have implicit parameters other than WeakTypeTag evidences
def foo_targs[U](x: Int) = macro Impls.foo_targs[T, U]
^
one error found
diff --git a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala index f724538993..845a168ff2 100644 --- a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala +++ b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala @@ -2,13 +2,13 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo_targs[T, U: c.AbsTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = { + def foo_targs[T, U: c.WeakTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = { import c.{prefix => prefix} import c.universe._ val body = Block( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + implicitly[c.AbsTypeTag[U]].tpe)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + implicitly[c.WeakTypeTag[U]].tpe)))), Literal(Constant(()))) c.Expr[Unit](body) } diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a.check b/test/files/neg/macro-invalidsig-tparams-notparams-a.check index 5aee62b9e5..5404c185f3 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-a.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:2: error: wrong number of type parameters for method foo: [U](c: scala.reflect.macros.Context)(implicit evidence$1: c.AbsTypeTag[U])Nothing
+Macros_Test_2.scala:2: error: wrong number of type parameters for method foo: [U](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[U])Nothing
def foo = macro Impls.foo
^
one error found
diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala index afbe0f0915..f8b3c92869 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala @@ -2,5 +2,5 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.AbsTypeTag](c: Ctx) = ??? + def foo[U: c.WeakTypeTag](c: Ctx) = ??? }
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b.check b/test/files/neg/macro-invalidsig-tparams-notparams-b.check index e8de8a4c6b..485d4de96e 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-b.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.AbsTypeTag[T], implicit evidence$2: c.AbsTypeTag[U], implicit V: c.AbsTypeTag[V])c.Expr[Unit]
+Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[T], implicit evidence$2: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
def foo[V] = macro Impls.foo
^
one error found
diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala index b48f9d5f98..baf3aab9e3 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala @@ -2,9 +2,9 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.AbsTypeTag, U: c.AbsTypeTag, V](c: Ctx)(implicit V: c.AbsTypeTag[V]): c.Expr[Unit] = { - println(implicitly[c.AbsTypeTag[T]]) - println(implicitly[c.AbsTypeTag[U]]) + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Ctx)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { + println(implicitly[c.WeakTypeTag[T]]) + println(implicitly[c.WeakTypeTag[U]]) println(V) c.literalUnit } diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c.check b/test/files/neg/macro-invalidsig-tparams-notparams-c.check index b1078fb233..1530c35097 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-c.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.AbsTypeTag[T], implicit evidence$2: c.AbsTypeTag[U], implicit V: c.AbsTypeTag[V])c.Expr[Unit]
+Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[T], implicit evidence$2: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
def foo[V] = macro Impls.foo[V]
^
one error found
diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala index 3506bdc789..44b4ed6ab3 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala @@ -2,10 +2,10 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.AbsTypeTag, U: c.AbsTypeTag, V](c: Ctx)(implicit V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Ctx)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ - println(implicitly[c.AbsTypeTag[T]]) - println(implicitly[c.AbsTypeTag[U]]) + println(implicitly[c.WeakTypeTag[T]]) + println(implicitly[c.WeakTypeTag[U]]) println(V) c.literalUnit } diff --git a/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala b/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala index b66ad6c523..1e7fcb3f45 100644 --- a/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala +++ b/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala @@ -1,7 +1,7 @@ import scala.reflect.runtime.universe._ object Test extends App { - def fooTypeTag[T: AbsTypeTag] = { + def fooTypeTag[T: WeakTypeTag] = { println(implicitly[TypeTag[T]]) println(implicitly[TypeTag[List[T]]]) } diff --git a/test/files/neg/t6323a.check b/test/files/neg/t6323a.check new file mode 100644 index 0000000000..694c79ca5f --- /dev/null +++ b/test/files/neg/t6323a.check @@ -0,0 +1,9 @@ +t6323a.scala:11: `package`.this.materializeTypeTag[Test](scala.reflect.runtime.`package`.universe) is not a valid implicit value for reflect.runtime.universe.TypeTag[Test] because:
+failed to typecheck the materialized tag:
+cannot create a TypeTag referring to local class Test.Test
+ val value = u.typeOf[Test]
+ ^
+t6323a.scala:11: error: No TypeTag available for Test
+ val value = u.typeOf[Test]
+ ^
+one error found
diff --git a/test/files/neg/t6323a.flags b/test/files/neg/t6323a.flags new file mode 100644 index 0000000000..4c6cdb71e2 --- /dev/null +++ b/test/files/neg/t6323a.flags @@ -0,0 +1 @@ +-Xlog-implicits
\ No newline at end of file diff --git a/test/files/neg/t6323a.scala b/test/files/neg/t6323a.scala new file mode 100644 index 0000000000..a203167f3c --- /dev/null +++ b/test/files/neg/t6323a.scala @@ -0,0 +1,21 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => m} +import scala.reflect.runtime.{universe => u} + +object Test extends App { + locally { + try { + case class Test(a:String,b:List[Int]) + + val lookAtMe = m.reflect(Test("a",List(5))) + val value = u.typeOf[Test] + val members = value.members + val member = value.members.filter(_.name.encoded == "a") + val aAccessor = lookAtMe.reflectMethod(member.head.asMethod) + val thisShouldBeA = aAccessor.apply() + println(thisShouldBeA) + } catch { + case ScalaReflectionException(msg) => println(msg) + } + } +}
\ No newline at end of file |