summaryrefslogtreecommitdiff
path: root/test/files/run/typetags_typeof_x.check
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-12-10 00:33:30 +0100
committerEugene Burmako <xeno.by@gmail.com>2014-02-14 14:09:14 +0100
commitb0176294060c9ce8b86d71e7bc8a7a13cef15b1e (patch)
treefb68701eda408edfd8d347d22ca97f36eb70df45 /test/files/run/typetags_typeof_x.check
parent51b16e421ddd4e6c7e90ba945addf39ffcb4fa41 (diff)
downloadscala-b0176294060c9ce8b86d71e7bc8a7a13cef15b1e.tar.gz
scala-b0176294060c9ce8b86d71e7bc8a7a13cef15b1e.tar.bz2
scala-b0176294060c9ce8b86d71e7bc8a7a13cef15b1e.zip
SI-6484 adds Universe.typeOf[T](x: T)
This is a nice addition to Universe.typeOf[T], quite frequently useful for inspecting ad-hoc types. As promised by https://github.com/scala/scala/pull/1741, which represented my previous stab at adding this API, I ran into problems when trying to introduce the API naively. def typeOf[T](implicit ttag: TypeTag[T]): Type def typeOf[T: TypeTag](x: T): Type The first problem came from the fact that even though they don't look ambiguous, under certain circumstances, the couple of typeOf overloads can become ambiguous. Concretely, ambiguity happens when T <: TypeTag[T], which makes the compiler uncapable to choose an overload to typecheck `typeOf[T](<materialized>: TypeTag[T])`. Luckily, defining x as a by-name parameter fixes the problem. def typeOf[T](implicit ttag: TypeTag[T]): Type def typeOf[T: TypeTag](x: => T): Type The second problem manifested itself in reification of snippets that contained calls to typeOf. Apparently, materialized tags get rolled back by reify as products of macro expansion, becoming replaced with `implicitly[TypeTag[T]]`. Afterwards, subsequent rollback of TypeTree's strips the replacement of its type argument, producing bare `implicitly`. Back then when typeOf wasn't overloaded, this abomination typechecked and worked correctly, but now, due to some weird reason, it stopped. I have worked around this by performing the rollback on a larger scale - instead of hunting down materialized tags, this commit detects calls to typeOf and removes their implicit argument lists altogether.
Diffstat (limited to 'test/files/run/typetags_typeof_x.check')
-rw-r--r--test/files/run/typetags_typeof_x.check8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/files/run/typetags_typeof_x.check b/test/files/run/typetags_typeof_x.check
new file mode 100644
index 0000000000..832a8bc63c
--- /dev/null
+++ b/test/files/run/typetags_typeof_x.check
@@ -0,0 +1,8 @@
+List[T]
+C
+Int
+List[Any]
+AnyRef{def x: Int}
+Null
+Nothing
+Null