From fce3f8b2e351494dd8c110b896f731931ae2805e Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Tue, 18 Sep 2012 15:04:20 +0200 Subject: existentially typed expansions now work fine If one tries to compile the following code with the parent of this commit: ru.reify(new Object().getClass) then the following error will occur: Test.scala:2: error: type mismatch; found : $u.Expr[Class[_ <: Object]] required: reflect.runtime.universe.Expr[Class[?0(in value )]] where type ?0(in value ) <: Object ru.reify(new Object().getClass) ^ This happens because macro expansions are always typechecked against the return type of their macro definitions instantiated in the context of expandee. In this case the expected type contains skolems which are incompatible with wildcards in the type of the expansion. I tried all the incantations I could think of - without any success. Luckily I met Martin who pointed me at the same problem solved in adapt (see the diff w.r.t Typers.scala). --- test/files/run/t5418a.check | 1 + test/files/run/t5418a.scala | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 test/files/run/t5418a.check create mode 100644 test/files/run/t5418a.scala (limited to 'test') diff --git a/test/files/run/t5418a.check b/test/files/run/t5418a.check new file mode 100644 index 0000000000..ee0e80e11f --- /dev/null +++ b/test/files/run/t5418a.check @@ -0,0 +1 @@ +Expr[Class[_ <: java.lang.Object]](new Object().getClass()) diff --git a/test/files/run/t5418a.scala b/test/files/run/t5418a.scala new file mode 100644 index 0000000000..90bc542be6 --- /dev/null +++ b/test/files/run/t5418a.scala @@ -0,0 +1,3 @@ +object Test extends App { + println(scala.reflect.runtime.universe.reify(new Object().getClass)) +} \ No newline at end of file -- cgit v1.2.3 From 862a1ede4d416186a1753f8e682d16ffc98817a5 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Tue, 18 Sep 2012 15:10:19 +0200 Subject: test case closes SI-5418 Now, when the existential reification bug is fixed, I've been able to take a look at SI-5418, and, apparently, the problem with importers has fixed itself during these 9 months of the bug being active. --- test/files/run/t5418b.check | 2 ++ test/files/run/t5418b.scala | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 test/files/run/t5418b.check create mode 100644 test/files/run/t5418b.scala (limited to 'test') diff --git a/test/files/run/t5418b.check b/test/files/run/t5418b.check new file mode 100644 index 0000000000..875ad08435 --- /dev/null +++ b/test/files/run/t5418b.check @@ -0,0 +1,2 @@ +new Object().getClass() +TypeRef(ThisType(java.lang), java.lang.Class, List(TypeRef(NoPrefix, newTypeName("?0"), List()))) diff --git a/test/files/run/t5418b.scala b/test/files/run/t5418b.scala new file mode 100644 index 0000000000..08e8bb163b --- /dev/null +++ b/test/files/run/t5418b.scala @@ -0,0 +1,11 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + val tb = cm.mkToolBox() + val untyped = reify(new Object().getClass).tree + val typed = tb.typeCheck(untyped) + println(typed) + println(showRaw(typed.tpe)) +} \ No newline at end of file -- cgit v1.2.3