From 2b09d8caf5497c4e016a3e1179e5f7e842766176 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 23 Apr 2012 17:51:28 +0200 Subject: rethinks tags * introduces ArrayTag and ErasureTag * all type tags now feature erasure --- test/files/neg/classtags_contextbound_a.check | 2 +- test/files/neg/classtags_contextbound_c.check | 2 +- test/files/neg/classtags_dont_use_typetags.check | 4 ++ test/files/neg/classtags_dont_use_typetags.scala | 3 ++ test/files/neg/macro-invalidret-nontree.check | 14 ++--- .../neg/macro-invalidret-nonuniversetree.check | 14 ++--- test/files/neg/t5689.check | 2 +- test/files/run/arraytags_basic.check | 36 +++++++++++++ test/files/run/arraytags_basic.scala | 22 ++++++++ test/files/run/arraytags_core.check | 48 +++++++++++++++++ test/files/run/arraytags_core.scala | 50 +++++++++++++++++ test/files/run/arraytags_usage.check | 3 ++ test/files/run/arraytags_usage.scala | 15 ++++++ test/files/run/classtags_core.check | 62 +++++++++++----------- test/files/run/classtags_core.scala | 2 + test/files/run/classtags_multi.check | 5 ++ test/files/run/classtags_multi.scala | 7 +++ .../files/run/classtags_use_concretetypetags.scala | 3 ++ test/files/run/concretetypetags_core.check | 32 +++++++++++ test/files/run/concretetypetags_core.scala | 34 ++++++++++++ test/files/run/concretetypetags_multi.check | 5 ++ test/files/run/concretetypetags_multi.scala | 7 +++ test/files/run/erasuretags_abstract.check | 4 ++ test/files/run/erasuretags_abstract.scala | 9 ++++ test/files/run/erasuretags_basic.check | 24 +++++++++ test/files/run/erasuretags_basic.scala | 21 ++++++++ test/files/run/erasuretags_core.check | 32 +++++++++++ test/files/run/erasuretags_core.scala | 34 ++++++++++++ test/files/run/erasuretags_usage.scala | 12 +++++ test/files/run/groundtypetags_core.check | 30 ----------- test/files/run/groundtypetags_core.scala | 32 ----------- .../Impls_Macros_1.scala | 7 --- .../run/macro-typecheck-macrosdisabled2.check | 5 ++ .../run/macro-typecheck-macrosdisabled2.flags | 1 + .../Impls_Macros_1.scala | 29 ++++++++++ .../macro-typecheck-macrosdisabled2/Test_2.scala | 4 ++ .../run/toolbox_typecheck_macrosdisabled2.check | 5 ++ .../run/toolbox_typecheck_macrosdisabled2.scala | 17 ++++++ test/files/run/typetags_core.check | 62 +++++++++++----------- test/files/run/typetags_core.scala | 2 + test/files/run/typetags_multi.check | 5 ++ test/files/run/typetags_multi.scala | 7 +++ test/files/speclib/instrumented.jar.desired.sha1 | 2 +- 43 files changed, 569 insertions(+), 147 deletions(-) create mode 100644 test/files/neg/classtags_dont_use_typetags.check create mode 100644 test/files/neg/classtags_dont_use_typetags.scala create mode 100644 test/files/run/arraytags_basic.check create mode 100644 test/files/run/arraytags_basic.scala create mode 100644 test/files/run/arraytags_core.check create mode 100644 test/files/run/arraytags_core.scala create mode 100644 test/files/run/arraytags_usage.check create mode 100644 test/files/run/arraytags_usage.scala create mode 100644 test/files/run/classtags_multi.check create mode 100644 test/files/run/classtags_multi.scala create mode 100644 test/files/run/classtags_use_concretetypetags.scala create mode 100644 test/files/run/concretetypetags_core.check create mode 100644 test/files/run/concretetypetags_core.scala create mode 100644 test/files/run/concretetypetags_multi.check create mode 100644 test/files/run/concretetypetags_multi.scala create mode 100644 test/files/run/erasuretags_abstract.check create mode 100644 test/files/run/erasuretags_abstract.scala create mode 100644 test/files/run/erasuretags_basic.check create mode 100644 test/files/run/erasuretags_basic.scala create mode 100644 test/files/run/erasuretags_core.check create mode 100644 test/files/run/erasuretags_core.scala create mode 100644 test/files/run/erasuretags_usage.scala delete mode 100644 test/files/run/groundtypetags_core.check delete mode 100644 test/files/run/groundtypetags_core.scala create mode 100644 test/files/run/macro-typecheck-macrosdisabled2.check create mode 100644 test/files/run/macro-typecheck-macrosdisabled2.flags create mode 100644 test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala create mode 100644 test/files/run/macro-typecheck-macrosdisabled2/Test_2.scala create mode 100644 test/files/run/toolbox_typecheck_macrosdisabled2.check create mode 100644 test/files/run/toolbox_typecheck_macrosdisabled2.scala create mode 100644 test/files/run/typetags_multi.check create mode 100644 test/files/run/typetags_multi.scala (limited to 'test/files') diff --git a/test/files/neg/classtags_contextbound_a.check b/test/files/neg/classtags_contextbound_a.check index f4b6ff5af1..a4fd37506d 100644 --- a/test/files/neg/classtags_contextbound_a.check +++ b/test/files/neg/classtags_contextbound_a.check @@ -1,4 +1,4 @@ -classtags_contextbound_a.scala:2: error: No ClassTag available for T +classtags_contextbound_a.scala:2: error: No ArrayTag available for T def foo[T] = Array[T]() ^ one error found diff --git a/test/files/neg/classtags_contextbound_c.check b/test/files/neg/classtags_contextbound_c.check index 54f630862a..a1c5eddfe1 100644 --- a/test/files/neg/classtags_contextbound_c.check +++ b/test/files/neg/classtags_contextbound_c.check @@ -1,4 +1,4 @@ -classtags_contextbound_c.scala:2: error: No ClassTag available for T +classtags_contextbound_c.scala:2: error: No ArrayTag available for T def mkArray[T] = Array[T]() ^ one error found diff --git a/test/files/neg/classtags_dont_use_typetags.check b/test/files/neg/classtags_dont_use_typetags.check new file mode 100644 index 0000000000..c7d2fba35b --- /dev/null +++ b/test/files/neg/classtags_dont_use_typetags.check @@ -0,0 +1,4 @@ +classtags_dont_use_typetags.scala:2: error: No ArrayTag available for T + def foo[T: TypeTag] = Array[T]() + ^ +one error found diff --git a/test/files/neg/classtags_dont_use_typetags.scala b/test/files/neg/classtags_dont_use_typetags.scala new file mode 100644 index 0000000000..0f675f71aa --- /dev/null +++ b/test/files/neg/classtags_dont_use_typetags.scala @@ -0,0 +1,3 @@ +object Test extends App { + def foo[T: TypeTag] = Array[T]() +} \ No newline at end of file diff --git a/test/files/neg/macro-invalidret-nontree.check b/test/files/neg/macro-invalidret-nontree.check index 7fcc396463..0b793cf421 100644 --- a/test/files/neg/macro-invalidret-nontree.check +++ b/test/files/neg/macro-invalidret-nontree.check @@ -1,7 +1,7 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.makro.Context): c.Expr[Any] - found : (c: scala.reflect.makro.Context): Int -type mismatch for return type : c.Expr[Any] does not conform to Int - def foo = macro Impls.foo - ^ -one error found +Macros_Test_2.scala:2: error: macro implementation has wrong shape: + required: (c: scala.reflect.makro.Context): c.Expr[Any] + found : (c: scala.reflect.makro.Context): Int +type mismatch for return type: Int does not conform to c.Expr[Any] + def foo = macro Impls.foo + ^ +one error found diff --git a/test/files/neg/macro-invalidret-nonuniversetree.check b/test/files/neg/macro-invalidret-nonuniversetree.check index a97d6daaa9..4fc06b5ceb 100644 --- a/test/files/neg/macro-invalidret-nonuniversetree.check +++ b/test/files/neg/macro-invalidret-nonuniversetree.check @@ -1,7 +1,7 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.makro.Context): c.Expr[Any] - found : (c: scala.reflect.makro.Context): reflect.mirror.Literal -type mismatch for return type : c.Expr[Any] does not conform to reflect.mirror.Literal - def foo = macro Impls.foo - ^ -one error found +Macros_Test_2.scala:2: error: macro implementation has wrong shape: + required: (c: scala.reflect.makro.Context): c.Expr[Any] + found : (c: scala.reflect.makro.Context): reflect.mirror.Literal +type mismatch for return type: reflect.mirror.Literal does not conform to c.Expr[Any] + def foo = macro Impls.foo + ^ +one error found diff --git a/test/files/neg/t5689.check b/test/files/neg/t5689.check index f286d08cfa..6abc4c13f6 100644 --- a/test/files/neg/t5689.check +++ b/test/files/neg/t5689.check @@ -1,7 +1,7 @@ t5689.scala:4: error: macro implementation has wrong shape: required: (c: scala.reflect.makro.Context)(i: c.Expr[Double]): c.Expr[String] found : (c: scala.reflect.makro.Context)(i: c.Expr[Double]): c.Expr[Int] -type mismatch for return type : c.Expr[String] does not conform to c.Expr[Int] +type mismatch for return type: c.Expr[Int] does not conform to c.Expr[String] def returnsString(i: Double): String = macro returnsIntImpl ^ one error found diff --git a/test/files/run/arraytags_basic.check b/test/files/run/arraytags_basic.check new file mode 100644 index 0000000000..92816b91bd --- /dev/null +++ b/test/files/run/arraytags_basic.check @@ -0,0 +1,36 @@ +class [I +class [[I +class [[[I +class [Lscala.collection.immutable.List; +class [[Lscala.collection.immutable.List; +class [[[Lscala.collection.immutable.List; +class [Lscala.collection.immutable.List; +class [[Lscala.collection.immutable.List; +class [[[Lscala.collection.immutable.List; +class [Lscala.collection.immutable.Map; +class [[Lscala.collection.immutable.Map; +class [[[Lscala.collection.immutable.Map; +class [[I +class [[[I +class [[[[I +class [[Lscala.collection.immutable.List; +class [[[Lscala.collection.immutable.List; +class [[[[Lscala.collection.immutable.List; +class [[Lscala.collection.immutable.List; +class [[[Lscala.collection.immutable.List; +class [[[[Lscala.collection.immutable.List; +class [[Lscala.collection.immutable.Map; +class [[[Lscala.collection.immutable.Map; +class [[[[Lscala.collection.immutable.Map; +class [[[I +class [[[[I +class [[[[[I +class [[[Lscala.collection.immutable.List; +class [[[[Lscala.collection.immutable.List; +class [[[[[Lscala.collection.immutable.List; +class [[[Lscala.collection.immutable.List; +class [[[[Lscala.collection.immutable.List; +class [[[[[Lscala.collection.immutable.List; +class [[[Lscala.collection.immutable.Map; +class [[[[Lscala.collection.immutable.Map; +class [[[[[Lscala.collection.immutable.Map; diff --git a/test/files/run/arraytags_basic.scala b/test/files/run/arraytags_basic.scala new file mode 100644 index 0000000000..edc20e9bc1 --- /dev/null +++ b/test/files/run/arraytags_basic.scala @@ -0,0 +1,22 @@ +object Test extends App { + def test[T: ArrayTag] = { + println(implicitly[ArrayTag[T]].newArray(10).getClass) + println(implicitly[ArrayTag[T]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[T]]].wrap.newArray(10).getClass) + } + + test[Int] + test[List[Int]] + test[List[String]] + test[Map[Int, String]] + + test[Array[Int]] + test[Array[List[Int]]] + test[Array[List[String]]] + test[Array[Map[Int, String]]] + + test[Array[Array[Int]]] + test[Array[Array[List[Int]]]] + test[Array[Array[List[String]]]] + test[Array[Array[Map[Int, String]]]] +} \ No newline at end of file diff --git a/test/files/run/arraytags_core.check b/test/files/run/arraytags_core.check new file mode 100644 index 0000000000..82ed84ad78 --- /dev/null +++ b/test/files/run/arraytags_core.check @@ -0,0 +1,48 @@ +class [B +class [[B +class [[[B +class [S +class [[S +class [[[S +class [C +class [[C +class [[[C +class [I +class [[I +class [[[I +class [J +class [[J +class [[[J +class [F +class [[F +class [[[F +class [D +class [[D +class [[[D +class [Z +class [[Z +class [[[Z +class [Lscala.runtime.BoxedUnit; +class [[Lscala.runtime.BoxedUnit; +class [[[Lscala.runtime.BoxedUnit; +class [Ljava.lang.Object; +class [[Ljava.lang.Object; +class [[[Ljava.lang.Object; +class [Ljava.lang.Object; +class [[Ljava.lang.Object; +class [[[Ljava.lang.Object; +class [Ljava.lang.Object; +class [[Ljava.lang.Object; +class [[[Ljava.lang.Object; +class [Ljava.lang.Object; +class [[Ljava.lang.Object; +class [[[Ljava.lang.Object; +class [Lscala.runtime.Null$; +class [[Lscala.runtime.Null$; +class [[[Lscala.runtime.Null$; +class [Lscala.runtime.Nothing$; +class [[Lscala.runtime.Nothing$; +class [[[Lscala.runtime.Nothing$; +class [Ljava.lang.String; +class [[Ljava.lang.String; +class [[[Ljava.lang.String; diff --git a/test/files/run/arraytags_core.scala b/test/files/run/arraytags_core.scala new file mode 100644 index 0000000000..a59ae24f30 --- /dev/null +++ b/test/files/run/arraytags_core.scala @@ -0,0 +1,50 @@ +object Test extends App { + println(implicitly[ArrayTag[Byte]].newArray(10).getClass) + println(implicitly[ArrayTag[Byte]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Byte]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Short]].newArray(10).getClass) + println(implicitly[ArrayTag[Short]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Short]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Char]].newArray(10).getClass) + println(implicitly[ArrayTag[Char]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Char]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Int]].newArray(10).getClass) + println(implicitly[ArrayTag[Int]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Int]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Long]].newArray(10).getClass) + println(implicitly[ArrayTag[Long]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Long]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Float]].newArray(10).getClass) + println(implicitly[ArrayTag[Float]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Float]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Double]].newArray(10).getClass) + println(implicitly[ArrayTag[Double]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Double]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Boolean]].newArray(10).getClass) + println(implicitly[ArrayTag[Boolean]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Boolean]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Unit]].newArray(10).getClass) + println(implicitly[ArrayTag[Unit]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Unit]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Any]].newArray(10).getClass) + println(implicitly[ArrayTag[Any]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Any]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Object]].newArray(10).getClass) + println(implicitly[ArrayTag[Object]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Object]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[AnyVal]].newArray(10).getClass) + println(implicitly[ArrayTag[AnyVal]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[AnyVal]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[AnyRef]].newArray(10).getClass) + println(implicitly[ArrayTag[AnyRef]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[AnyRef]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Null]].newArray(10).getClass) + println(implicitly[ArrayTag[Null]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Null]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Nothing]].newArray(10).getClass) + println(implicitly[ArrayTag[Nothing]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Nothing]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[String]].newArray(10).getClass) + println(implicitly[ArrayTag[String]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[String]]].wrap.newArray(10).getClass) +} \ No newline at end of file diff --git a/test/files/run/arraytags_usage.check b/test/files/run/arraytags_usage.check new file mode 100644 index 0000000000..b1d02b7bfe --- /dev/null +++ b/test/files/run/arraytags_usage.check @@ -0,0 +1,3 @@ +class [I +class [I +class [I diff --git a/test/files/run/arraytags_usage.scala b/test/files/run/arraytags_usage.scala new file mode 100644 index 0000000000..60b0a8f218 --- /dev/null +++ b/test/files/run/arraytags_usage.scala @@ -0,0 +1,15 @@ +object Test extends App { + def foo[T] = { + class MyArrayTag extends ArrayTag[T] { + def wrap: ArrayTag[Array[T]] = ??? + def newArray(len: Int): Array[T] = new Array[Int](len).asInstanceOf[Array[T]] + } + + implicit val tag = new MyArrayTag() + println(Array[T]().getClass) + } + + foo[Int] + foo[String] + foo[Array[String]] +} \ No newline at end of file diff --git a/test/files/run/classtags_core.check b/test/files/run/classtags_core.check index ce5a893b08..ebccfcd54c 100644 --- a/test/files/run/classtags_core.check +++ b/test/files/run/classtags_core.check @@ -1,30 +1,32 @@ -true -ClassTag(byte) -true -ClassTag(short) -true -ClassTag(char) -true -ClassTag(int) -true -ClassTag(long) -true -ClassTag(float) -true -ClassTag(double) -true -ClassTag(boolean) -true -ClassTag(void) -true -ClassTag(class java.lang.Object) -true -ClassTag(class java.lang.Object) -true -ClassTag(class java.lang.Object) -true -ClassTag(class java.lang.Object) -true -ClassTag(class java.lang.Object) -true -ClassTag(class java.lang.Object) +true +ClassTag[byte] +true +ClassTag[short] +true +ClassTag[char] +true +ClassTag[int] +true +ClassTag[long] +true +ClassTag[float] +true +ClassTag[double] +true +ClassTag[boolean] +true +ClassTag[void] +true +ClassTag[class java.lang.Object] +true +ClassTag[class java.lang.Object] +true +ClassTag[class java.lang.Object] +true +ClassTag[class java.lang.Object] +true +ClassTag[class scala.runtime.Null$] +true +ClassTag[class scala.runtime.Nothing$] +true +ClassTag[class java.lang.String] diff --git a/test/files/run/classtags_core.scala b/test/files/run/classtags_core.scala index 45c54b1fe0..9f2031377d 100644 --- a/test/files/run/classtags_core.scala +++ b/test/files/run/classtags_core.scala @@ -29,4 +29,6 @@ object Test extends App { println(implicitly[ClassTag[Null]]) println(implicitly[ClassTag[Nothing]] eq ClassTag.Nothing) println(implicitly[ClassTag[Nothing]]) + println(implicitly[ClassTag[String]] eq ClassTag.String) + println(implicitly[ClassTag[String]]) } \ No newline at end of file diff --git a/test/files/run/classtags_multi.check b/test/files/run/classtags_multi.check new file mode 100644 index 0000000000..3a7f16c3a0 --- /dev/null +++ b/test/files/run/classtags_multi.check @@ -0,0 +1,5 @@ +ClassTag[int] +ClassTag[class [I] +ClassTag[class [[I] +ClassTag[class [[[I] +ClassTag[class [[[[I] diff --git a/test/files/run/classtags_multi.scala b/test/files/run/classtags_multi.scala new file mode 100644 index 0000000000..5aafb55223 --- /dev/null +++ b/test/files/run/classtags_multi.scala @@ -0,0 +1,7 @@ +object Test extends App { + println(classTag[Int]) + println(classTag[Array[Int]]) + println(classTag[Array[Array[Int]]]) + println(classTag[Array[Array[Array[Int]]]]) + println(classTag[Array[Array[Array[Array[Int]]]]]) +} \ No newline at end of file diff --git a/test/files/run/classtags_use_concretetypetags.scala b/test/files/run/classtags_use_concretetypetags.scala new file mode 100644 index 0000000000..57e7085cec --- /dev/null +++ b/test/files/run/classtags_use_concretetypetags.scala @@ -0,0 +1,3 @@ +object Test extends App { + def foo[T: ConcreteTypeTag] = Array[T]() +} \ No newline at end of file diff --git a/test/files/run/concretetypetags_core.check b/test/files/run/concretetypetags_core.check new file mode 100644 index 0000000000..f124aa6a35 --- /dev/null +++ b/test/files/run/concretetypetags_core.check @@ -0,0 +1,32 @@ +true +ConcreteTypeTag[Byte] +true +ConcreteTypeTag[Short] +true +ConcreteTypeTag[Char] +true +ConcreteTypeTag[Int] +true +ConcreteTypeTag[Long] +true +ConcreteTypeTag[Float] +true +ConcreteTypeTag[Double] +true +ConcreteTypeTag[Boolean] +true +ConcreteTypeTag[Unit] +true +ConcreteTypeTag[Any] +true +ConcreteTypeTag[Object] +true +ConcreteTypeTag[AnyVal] +true +ConcreteTypeTag[AnyRef] +true +ConcreteTypeTag[Null] +true +ConcreteTypeTag[Nothing] +true +ConcreteTypeTag[String] diff --git a/test/files/run/concretetypetags_core.scala b/test/files/run/concretetypetags_core.scala new file mode 100644 index 0000000000..b6cfea3895 --- /dev/null +++ b/test/files/run/concretetypetags_core.scala @@ -0,0 +1,34 @@ +object Test extends App { + println(implicitly[ConcreteTypeTag[Byte]] eq ConcreteTypeTag.Byte) + println(implicitly[ConcreteTypeTag[Byte]]) + println(implicitly[ConcreteTypeTag[Short]] eq ConcreteTypeTag.Short) + println(implicitly[ConcreteTypeTag[Short]]) + println(implicitly[ConcreteTypeTag[Char]] eq ConcreteTypeTag.Char) + println(implicitly[ConcreteTypeTag[Char]]) + println(implicitly[ConcreteTypeTag[Int]] eq ConcreteTypeTag.Int) + println(implicitly[ConcreteTypeTag[Int]]) + println(implicitly[ConcreteTypeTag[Long]] eq ConcreteTypeTag.Long) + println(implicitly[ConcreteTypeTag[Long]]) + println(implicitly[ConcreteTypeTag[Float]] eq ConcreteTypeTag.Float) + println(implicitly[ConcreteTypeTag[Float]]) + println(implicitly[ConcreteTypeTag[Double]] eq ConcreteTypeTag.Double) + println(implicitly[ConcreteTypeTag[Double]]) + println(implicitly[ConcreteTypeTag[Boolean]] eq ConcreteTypeTag.Boolean) + println(implicitly[ConcreteTypeTag[Boolean]]) + println(implicitly[ConcreteTypeTag[Unit]] eq ConcreteTypeTag.Unit) + println(implicitly[ConcreteTypeTag[Unit]]) + println(implicitly[ConcreteTypeTag[Any]] eq ConcreteTypeTag.Any) + println(implicitly[ConcreteTypeTag[Any]]) + println(implicitly[ConcreteTypeTag[Object]] eq ConcreteTypeTag.Object) + println(implicitly[ConcreteTypeTag[Object]]) + println(implicitly[ConcreteTypeTag[AnyVal]] eq ConcreteTypeTag.AnyVal) + println(implicitly[ConcreteTypeTag[AnyVal]]) + println(implicitly[ConcreteTypeTag[AnyRef]] eq ConcreteTypeTag.AnyRef) + println(implicitly[ConcreteTypeTag[AnyRef]]) + println(implicitly[ConcreteTypeTag[Null]] eq ConcreteTypeTag.Null) + println(implicitly[ConcreteTypeTag[Null]]) + println(implicitly[ConcreteTypeTag[Nothing]] eq ConcreteTypeTag.Nothing) + println(implicitly[ConcreteTypeTag[Nothing]]) + println(implicitly[ConcreteTypeTag[String]] eq ConcreteTypeTag.String) + println(implicitly[ConcreteTypeTag[String]]) +} \ No newline at end of file diff --git a/test/files/run/concretetypetags_multi.check b/test/files/run/concretetypetags_multi.check new file mode 100644 index 0000000000..613106985c --- /dev/null +++ b/test/files/run/concretetypetags_multi.check @@ -0,0 +1,5 @@ +ConcreteTypeTag[Int] +ConcreteTypeTag[Array[Int]] +ConcreteTypeTag[Array[Array[Int]]] +ConcreteTypeTag[Array[Array[Array[Int]]]] +ConcreteTypeTag[Array[Array[Array[Array[Int]]]]] diff --git a/test/files/run/concretetypetags_multi.scala b/test/files/run/concretetypetags_multi.scala new file mode 100644 index 0000000000..7e19d7db34 --- /dev/null +++ b/test/files/run/concretetypetags_multi.scala @@ -0,0 +1,7 @@ +object Test extends App { + println(concreteTypeTag[Int]) + println(concreteTypeTag[Array[Int]]) + println(concreteTypeTag[Array[Array[Int]]]) + println(concreteTypeTag[Array[Array[Array[Int]]]]) + println(concreteTypeTag[Array[Array[Array[Array[Int]]]]]) +} \ No newline at end of file diff --git a/test/files/run/erasuretags_abstract.check b/test/files/run/erasuretags_abstract.check new file mode 100644 index 0000000000..17e7204664 --- /dev/null +++ b/test/files/run/erasuretags_abstract.check @@ -0,0 +1,4 @@ +class java.lang.Object +class java.lang.Object +class java.lang.Object +int diff --git a/test/files/run/erasuretags_abstract.scala b/test/files/run/erasuretags_abstract.scala new file mode 100644 index 0000000000..8e4ad0d090 --- /dev/null +++ b/test/files/run/erasuretags_abstract.scala @@ -0,0 +1,9 @@ +object Test extends App { + def foo1[T] = erasureTag[T] + println(foo1[Int].erasure) + println(foo1[String].erasure) + println(foo1[Array[Int]].erasure) + + def foo2[T <: Int] = erasureTag[T] + println(foo2[Int].erasure) +} \ No newline at end of file diff --git a/test/files/run/erasuretags_basic.check b/test/files/run/erasuretags_basic.check new file mode 100644 index 0000000000..c02a4d32af --- /dev/null +++ b/test/files/run/erasuretags_basic.check @@ -0,0 +1,24 @@ +int +class [I +class scala.collection.immutable.List +class [Lscala.collection.immutable.List; +class scala.collection.immutable.List +class [Lscala.collection.immutable.List; +interface scala.collection.immutable.Map +class [Lscala.collection.immutable.Map; +class [I +class [[I +class [Lscala.collection.immutable.List; +class [[Lscala.collection.immutable.List; +class [Lscala.collection.immutable.List; +class [[Lscala.collection.immutable.List; +class [Lscala.collection.immutable.Map; +class [[Lscala.collection.immutable.Map; +class [[I +class [[[I +class [[Lscala.collection.immutable.List; +class [[[Lscala.collection.immutable.List; +class [[Lscala.collection.immutable.List; +class [[[Lscala.collection.immutable.List; +class [[Lscala.collection.immutable.Map; +class [[[Lscala.collection.immutable.Map; diff --git a/test/files/run/erasuretags_basic.scala b/test/files/run/erasuretags_basic.scala new file mode 100644 index 0000000000..d894fdf2e9 --- /dev/null +++ b/test/files/run/erasuretags_basic.scala @@ -0,0 +1,21 @@ +object Test extends App { + def test[T: ErasureTag] = { + println(implicitly[ErasureTag[T]].erasure) + println(implicitly[ErasureTag[Array[T]]].erasure) + } + + test[Int] + test[List[Int]] + test[List[String]] + test[Map[Int, String]] + + test[Array[Int]] + test[Array[List[Int]]] + test[Array[List[String]]] + test[Array[Map[Int, String]]] + + test[Array[Array[Int]]] + test[Array[Array[List[Int]]]] + test[Array[Array[List[String]]]] + test[Array[Array[Map[Int, String]]]] +} \ No newline at end of file diff --git a/test/files/run/erasuretags_core.check b/test/files/run/erasuretags_core.check new file mode 100644 index 0000000000..2c544678d1 --- /dev/null +++ b/test/files/run/erasuretags_core.check @@ -0,0 +1,32 @@ +byte +class [B +short +class [S +char +class [C +int +class [I +long +class [J +float +class [F +double +class [D +boolean +class [Z +void +class [Lscala.runtime.BoxedUnit; +class java.lang.Object +class [Ljava.lang.Object; +class java.lang.Object +class [Ljava.lang.Object; +class java.lang.Object +class [Ljava.lang.Object; +class java.lang.Object +class [Ljava.lang.Object; +class scala.runtime.Null$ +class [Lscala.runtime.Null$; +class scala.runtime.Nothing$ +class [Lscala.runtime.Nothing$; +class java.lang.String +class [Ljava.lang.String; diff --git a/test/files/run/erasuretags_core.scala b/test/files/run/erasuretags_core.scala new file mode 100644 index 0000000000..5ed06dcd31 --- /dev/null +++ b/test/files/run/erasuretags_core.scala @@ -0,0 +1,34 @@ +object Test extends App { + println(implicitly[ErasureTag[Byte]].erasure) + println(implicitly[ErasureTag[Array[Byte]]].erasure) + println(implicitly[ErasureTag[Short]].erasure) + println(implicitly[ErasureTag[Array[Short]]].erasure) + println(implicitly[ErasureTag[Char]].erasure) + println(implicitly[ErasureTag[Array[Char]]].erasure) + println(implicitly[ErasureTag[Int]].erasure) + println(implicitly[ErasureTag[Array[Int]]].erasure) + println(implicitly[ErasureTag[Long]].erasure) + println(implicitly[ErasureTag[Array[Long]]].erasure) + println(implicitly[ErasureTag[Float]].erasure) + println(implicitly[ErasureTag[Array[Float]]].erasure) + println(implicitly[ErasureTag[Double]].erasure) + println(implicitly[ErasureTag[Array[Double]]].erasure) + println(implicitly[ErasureTag[Boolean]].erasure) + println(implicitly[ErasureTag[Array[Boolean]]].erasure) + println(implicitly[ErasureTag[Unit]].erasure) + println(implicitly[ErasureTag[Array[Unit]]].erasure) + println(implicitly[ErasureTag[Any]].erasure) + println(implicitly[ErasureTag[Array[Any]]].erasure) + println(implicitly[ErasureTag[Object]].erasure) + println(implicitly[ErasureTag[Array[Object]]].erasure) + println(implicitly[ErasureTag[AnyVal]].erasure) + println(implicitly[ErasureTag[Array[AnyVal]]].erasure) + println(implicitly[ErasureTag[AnyRef]].erasure) + println(implicitly[ErasureTag[Array[AnyRef]]].erasure) + println(implicitly[ErasureTag[Null]].erasure) + println(implicitly[ErasureTag[Array[Null]]].erasure) + println(implicitly[ErasureTag[Nothing]].erasure) + println(implicitly[ErasureTag[Array[Nothing]]].erasure) + println(implicitly[ErasureTag[String]].erasure) + println(implicitly[ErasureTag[Array[String]]].erasure) +} \ No newline at end of file diff --git a/test/files/run/erasuretags_usage.scala b/test/files/run/erasuretags_usage.scala new file mode 100644 index 0000000000..16e53af071 --- /dev/null +++ b/test/files/run/erasuretags_usage.scala @@ -0,0 +1,12 @@ +object Test extends App { + def foo[T] = { + class MyErasureTag(_erasure: Class[_]) extends ErasureTag[T] { + def erasure: Class[T] = _erasure.asInstanceOf[Class[T]] + } + + implicit val tag = new MyErasureTag(classOf[Int]) + println(typeTag[T]) + println(typeTag[T].tpe) + println(typeTag[T].erasure) + } +} \ No newline at end of file diff --git a/test/files/run/groundtypetags_core.check b/test/files/run/groundtypetags_core.check deleted file mode 100644 index 62fcb481ae..0000000000 --- a/test/files/run/groundtypetags_core.check +++ /dev/null @@ -1,30 +0,0 @@ -true -ConcreteTypeTag[Byte] -true -ConcreteTypeTag[Short] -true -ConcreteTypeTag[Char] -true -ConcreteTypeTag[Int] -true -ConcreteTypeTag[Long] -true -ConcreteTypeTag[Float] -true -ConcreteTypeTag[Double] -true -ConcreteTypeTag[Boolean] -true -ConcreteTypeTag[Unit] -true -ConcreteTypeTag[Any] -true -ConcreteTypeTag[Object] -true -ConcreteTypeTag[AnyVal] -true -ConcreteTypeTag[AnyRef] -true -ConcreteTypeTag[Null] -true -ConcreteTypeTag[Nothing] diff --git a/test/files/run/groundtypetags_core.scala b/test/files/run/groundtypetags_core.scala deleted file mode 100644 index 8b81a0c795..0000000000 --- a/test/files/run/groundtypetags_core.scala +++ /dev/null @@ -1,32 +0,0 @@ -object Test extends App { - println(implicitly[ConcreteTypeTag[Byte]] eq ConcreteTypeTag.Byte) - println(implicitly[ConcreteTypeTag[Byte]]) - println(implicitly[ConcreteTypeTag[Short]] eq ConcreteTypeTag.Short) - println(implicitly[ConcreteTypeTag[Short]]) - println(implicitly[ConcreteTypeTag[Char]] eq ConcreteTypeTag.Char) - println(implicitly[ConcreteTypeTag[Char]]) - println(implicitly[ConcreteTypeTag[Int]] eq ConcreteTypeTag.Int) - println(implicitly[ConcreteTypeTag[Int]]) - println(implicitly[ConcreteTypeTag[Long]] eq ConcreteTypeTag.Long) - println(implicitly[ConcreteTypeTag[Long]]) - println(implicitly[ConcreteTypeTag[Float]] eq ConcreteTypeTag.Float) - println(implicitly[ConcreteTypeTag[Float]]) - println(implicitly[ConcreteTypeTag[Double]] eq ConcreteTypeTag.Double) - println(implicitly[ConcreteTypeTag[Double]]) - println(implicitly[ConcreteTypeTag[Boolean]] eq ConcreteTypeTag.Boolean) - println(implicitly[ConcreteTypeTag[Boolean]]) - println(implicitly[ConcreteTypeTag[Unit]] eq ConcreteTypeTag.Unit) - println(implicitly[ConcreteTypeTag[Unit]]) - println(implicitly[ConcreteTypeTag[Any]] eq ConcreteTypeTag.Any) - println(implicitly[ConcreteTypeTag[Any]]) - println(implicitly[ConcreteTypeTag[Object]] eq ConcreteTypeTag.Object) - println(implicitly[ConcreteTypeTag[Object]]) - println(implicitly[ConcreteTypeTag[AnyVal]] eq ConcreteTypeTag.AnyVal) - println(implicitly[ConcreteTypeTag[AnyVal]]) - println(implicitly[ConcreteTypeTag[AnyRef]] eq ConcreteTypeTag.AnyRef) - println(implicitly[ConcreteTypeTag[AnyRef]]) - println(implicitly[ConcreteTypeTag[Null]] eq ConcreteTypeTag.Null) - println(implicitly[ConcreteTypeTag[Null]]) - println(implicitly[ConcreteTypeTag[Nothing]] eq ConcreteTypeTag.Nothing) - println(implicitly[ConcreteTypeTag[Nothing]]) -} \ No newline at end of file diff --git a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala index a1f124f790..3de9367994 100644 --- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala @@ -4,13 +4,6 @@ object Macros { def impl_with_macros_enabled(c: Context) = { import c.mirror._ - // todo. doesn't work. why? - //val mrPkg = staticModule("scala.reflect.package") - //val mrSym = selectTerm(mrPkg, "mirror") - //val NullaryMethodType(mrTpe) = mrSym.typeSignature - //val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror) - //val tree1 = Apply(Select(Ident(mr), newTermName("reify")), List(Literal(Constant(2)))) - val mr = Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("package")), newTermName("mirror")) val tree1 = Apply(Select(mr, newTermName("reify")), List(Literal(Constant(2)))) val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check new file mode 100644 index 0000000000..02da6ad0c7 --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled2.check @@ -0,0 +1,5 @@ +{ + val $mr: reflect.mirror.type = scala.reflect.`package`.mirror; + $mr.Expr.apply[Array[Int]]($mr.Apply.apply($mr.Select.apply($mr.Select.apply($mr.Ident($mr.staticModule("scala")), $mr.newTermName("Array")), $mr.newTermName("apply")), scala.collection.immutable.List.apply[$mr.Literal]($mr.Literal.apply($mr.Constant.apply(2)))))($mr.ConcreteTypeTag.apply[Array[Int]]($mr.TypeRef.apply($mr.thisModuleType("scala"), $mr.staticClass("scala.Array"), scala.collection.immutable.List.apply[$mr.Type]($mr.staticClass("scala.Int").asTypeConstructor)), ScalaRunTime.this.arrayClass(classOf[scala.Int]))) +} +mr.reify[Array[Int]](scala.Array.apply(2)) diff --git a/test/files/run/macro-typecheck-macrosdisabled2.flags b/test/files/run/macro-typecheck-macrosdisabled2.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled2.flags @@ -0,0 +1 @@ +-language:experimental.macros \ No newline at end of file diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala new file mode 100644 index 0000000000..1b840a6204 --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala @@ -0,0 +1,29 @@ +import scala.reflect.makro.Context + +object Macros { + def impl_with_macros_enabled(c: Context) = { + import c.mirror._ + + val mr = Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("package")), newTermName("mirror")) + val tree1 = Apply(Select(mr, newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) + c.literal(ttree1.toString) + } + + def foo_with_macros_enabled = macro impl_with_macros_enabled + + def impl_with_macros_disabled(c: Context) = { + import c.mirror._ + + val mrPkg = staticModule("scala.reflect.package") + val mrSym = selectTerm(mrPkg, "mirror") + val NullaryMethodType(mrTpe) = mrSym.typeSignature + val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror) + + val tree2 = Apply(Select(Ident(mr), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) + c.literal(ttree2.toString) + } + + def foo_with_macros_disabled = macro impl_with_macros_disabled +} \ No newline at end of file diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Test_2.scala b/test/files/run/macro-typecheck-macrosdisabled2/Test_2.scala new file mode 100644 index 0000000000..bdba39195b --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled2/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + println(Macros.foo_with_macros_enabled) + println(Macros.foo_with_macros_disabled) +} \ No newline at end of file diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check new file mode 100644 index 0000000000..271139b031 --- /dev/null +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check @@ -0,0 +1,5 @@ +{ + val $mr: mr.type = mr; + $mr.Expr.apply[Array[Int]]($mr.Apply.apply($mr.Select.apply($mr.Select.apply($mr.Ident($mr.staticModule("scala")), $mr.newTermName("Array")), $mr.newTermName("apply")), scala.collection.immutable.List.apply[$mr.Literal]($mr.Literal.apply($mr.Constant.apply(2)))))($mr.ConcreteTypeTag.apply[Array[Int]]($mr.TypeRef.apply($mr.thisModuleType("scala"), $mr.staticClass("scala.Array"), scala.collection.immutable.List.apply[$mr.Type]($mr.staticClass("scala.Int").asTypeConstructor)), ScalaRunTime.this.arrayClass(classOf[scala.Int]))) +} +mr.reify[Array[Int]](scala.Array.apply(2)) diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.scala b/test/files/run/toolbox_typecheck_macrosdisabled2.scala new file mode 100644 index 0000000000..b4c76d0600 --- /dev/null +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.scala @@ -0,0 +1,17 @@ +import scala.reflect.mirror._ + +object Test extends App { + val toolbox = mkToolBox() + val mrPkg = staticModule("scala.reflect.package") + val mrSym = selectTerm(mrPkg, "mirror") + val NullaryMethodType(mrTpe) = mrSym.typeSignature + val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror) + + val tree1 = Apply(Select(Ident(mr), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) + println(ttree1) + + val tree2 = Apply(Select(Ident(mr), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true) + println(ttree2) +} diff --git a/test/files/run/typetags_core.check b/test/files/run/typetags_core.check index 62fcb481ae..f124aa6a35 100644 --- a/test/files/run/typetags_core.check +++ b/test/files/run/typetags_core.check @@ -1,30 +1,32 @@ -true -ConcreteTypeTag[Byte] -true -ConcreteTypeTag[Short] -true -ConcreteTypeTag[Char] -true -ConcreteTypeTag[Int] -true -ConcreteTypeTag[Long] -true -ConcreteTypeTag[Float] -true -ConcreteTypeTag[Double] -true -ConcreteTypeTag[Boolean] -true -ConcreteTypeTag[Unit] -true -ConcreteTypeTag[Any] -true -ConcreteTypeTag[Object] -true -ConcreteTypeTag[AnyVal] -true -ConcreteTypeTag[AnyRef] -true -ConcreteTypeTag[Null] -true -ConcreteTypeTag[Nothing] +true +ConcreteTypeTag[Byte] +true +ConcreteTypeTag[Short] +true +ConcreteTypeTag[Char] +true +ConcreteTypeTag[Int] +true +ConcreteTypeTag[Long] +true +ConcreteTypeTag[Float] +true +ConcreteTypeTag[Double] +true +ConcreteTypeTag[Boolean] +true +ConcreteTypeTag[Unit] +true +ConcreteTypeTag[Any] +true +ConcreteTypeTag[Object] +true +ConcreteTypeTag[AnyVal] +true +ConcreteTypeTag[AnyRef] +true +ConcreteTypeTag[Null] +true +ConcreteTypeTag[Nothing] +true +ConcreteTypeTag[String] diff --git a/test/files/run/typetags_core.scala b/test/files/run/typetags_core.scala index 883c54b9a8..7d6be16379 100644 --- a/test/files/run/typetags_core.scala +++ b/test/files/run/typetags_core.scala @@ -29,4 +29,6 @@ object Test extends App { println(implicitly[TypeTag[Null]]) println(implicitly[TypeTag[Nothing]] eq TypeTag.Nothing) println(implicitly[TypeTag[Nothing]]) + println(implicitly[TypeTag[String]] eq TypeTag.String) + println(implicitly[TypeTag[String]]) } \ No newline at end of file diff --git a/test/files/run/typetags_multi.check b/test/files/run/typetags_multi.check new file mode 100644 index 0000000000..613106985c --- /dev/null +++ b/test/files/run/typetags_multi.check @@ -0,0 +1,5 @@ +ConcreteTypeTag[Int] +ConcreteTypeTag[Array[Int]] +ConcreteTypeTag[Array[Array[Int]]] +ConcreteTypeTag[Array[Array[Array[Int]]]] +ConcreteTypeTag[Array[Array[Array[Array[Int]]]]] diff --git a/test/files/run/typetags_multi.scala b/test/files/run/typetags_multi.scala new file mode 100644 index 0000000000..868edc2b2a --- /dev/null +++ b/test/files/run/typetags_multi.scala @@ -0,0 +1,7 @@ +object Test extends App { + println(typeTag[Int]) + println(typeTag[Array[Int]]) + println(typeTag[Array[Array[Int]]]) + println(typeTag[Array[Array[Array[Int]]]]) + println(typeTag[Array[Array[Array[Array[Int]]]]]) +} \ No newline at end of file diff --git a/test/files/speclib/instrumented.jar.desired.sha1 b/test/files/speclib/instrumented.jar.desired.sha1 index 2d4cd04a92..a7da67429e 100644 --- a/test/files/speclib/instrumented.jar.desired.sha1 +++ b/test/files/speclib/instrumented.jar.desired.sha1 @@ -1 +1 @@ -d83c6bf3765ab1378943020a8d9cda8851604ffa ?instrumented.jar +15f200d9f0f25f9fd871bad2ebb4ba5cfc671db4 ?instrumented.jar -- cgit v1.2.3