diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-02-11 17:19:21 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-02-11 17:19:21 +0100 |
commit | 64ad11b49bd7630d596e950953a5b15d3abf1689 (patch) | |
tree | 1b0d7bfa6f7a15e1a66cf8fb4c98fe2353e0777c | |
parent | 4f660d8c1282398655da24211f3c74af33ec8a6b (diff) | |
parent | 2606becba91fa3d31cdeb3069a5a35b0163a4cde (diff) | |
download | scala-64ad11b49bd7630d596e950953a5b15d3abf1689.tar.gz scala-64ad11b49bd7630d596e950953a5b15d3abf1689.tar.bz2 scala-64ad11b49bd7630d596e950953a5b15d3abf1689.zip |
Merge pull request #3495 from xeno-by/ticket/8209
changes the order of whitebox typechecks. yes, again.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Macros.scala | 8 | ||||
-rw-r--r-- | test/files/pos/t8209a.check | 0 | ||||
-rw-r--r-- | test/files/pos/t8209a/Macros_1.scala | 17 | ||||
-rw-r--r-- | test/files/pos/t8209a/Test_2.scala | 4 | ||||
-rw-r--r-- | test/files/pos/t8209b.check | 0 | ||||
-rw-r--r-- | test/files/pos/t8209b/Macros_1.scala | 17 | ||||
-rw-r--r-- | test/files/pos/t8209b/Test_2.scala | 4 |
7 files changed, 47 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index cf82d6baac..677c94e063 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -620,9 +620,11 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers { val expanded1 = atPos(enclosingMacroPosition.makeTransparent)(Typed(expanded0, TypeTree(innerPt))) typecheck("blackbox typecheck", expanded1, outerPt) } else { - val expanded1 = expanded0 - val expanded2 = typecheck("whitebox typecheck #1", expanded1, outerPt) - typecheck("whitebox typecheck #2", expanded2, innerPt) + // whitebox expansions need to be typechecked against WildcardType first in order to avoid SI-6992 and SI-8048 + // then we typecheck against innerPt, not against outerPt in order to prevent SI-8209 + val expanded1 = typecheck("whitebox typecheck #0", expanded0, WildcardType) + val expanded2 = typecheck("whitebox typecheck #1", expanded1, innerPt) + typecheck("whitebox typecheck #2", expanded2, outerPt) } } override def onDelayed(delayed: Tree) = { diff --git a/test/files/pos/t8209a.check b/test/files/pos/t8209a.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/pos/t8209a.check diff --git a/test/files/pos/t8209a/Macros_1.scala b/test/files/pos/t8209a/Macros_1.scala new file mode 100644 index 0000000000..17014b4744 --- /dev/null +++ b/test/files/pos/t8209a/Macros_1.scala @@ -0,0 +1,17 @@ +import scala.language.experimental.macros +import scala.language.implicitConversions +import scala.reflect.macros.blackbox.Context + +class A +object A { implicit def a2b(a: A): B = ??? } +class B +class C extends A + +object Macros { + def impl(c: Context) = { + import c.universe._ + q"new C" + } + + def foo: A = macro impl +}
\ No newline at end of file diff --git a/test/files/pos/t8209a/Test_2.scala b/test/files/pos/t8209a/Test_2.scala new file mode 100644 index 0000000000..e19d572f55 --- /dev/null +++ b/test/files/pos/t8209a/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + val a: A = Macros.foo + val b: B = Macros.foo +}
\ No newline at end of file diff --git a/test/files/pos/t8209b.check b/test/files/pos/t8209b.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/pos/t8209b.check diff --git a/test/files/pos/t8209b/Macros_1.scala b/test/files/pos/t8209b/Macros_1.scala new file mode 100644 index 0000000000..705f7d630c --- /dev/null +++ b/test/files/pos/t8209b/Macros_1.scala @@ -0,0 +1,17 @@ +import scala.language.experimental.macros +import scala.language.implicitConversions +import scala.reflect.macros.whitebox.Context + +class A +object A { implicit def a2b(a: A): B = ??? } +class B +class C extends A + +object Macros { + def impl(c: Context) = { + import c.universe._ + q"new C" + } + + def foo: A = macro impl +}
\ No newline at end of file diff --git a/test/files/pos/t8209b/Test_2.scala b/test/files/pos/t8209b/Test_2.scala new file mode 100644 index 0000000000..e19d572f55 --- /dev/null +++ b/test/files/pos/t8209b/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + val a: A = Macros.foo + val b: B = Macros.foo +}
\ No newline at end of file |