Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[backport] SI-7776 post-erasure signature clashes are now macro-aware

"double definition: macro this and method that have same type after erasure"
This error doesn't make sense when macros are involved, because macros
expand at compile-time, where we're not affected by erasure. Moreover,
macros produce no bytecode, which means that we're safe from VerifyErrors.
  • Loading branch information...
commit d15ed081efdcb70bb77b5f76b2ac36a7e6b009ba 1 parent 79788af
@xeno-by xeno-by authored
View
8 src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -895,6 +895,9 @@ abstract class Erasure extends AddInterfaces
* but their erased types are the same.
*/
private def checkNoDoubleDefs(root: Symbol) {
+ def sameTypeAfterErasure(sym1: Symbol, sym2: Symbol) =
+ afterPostErasure(sym1.info =:= sym2.info) && !sym1.isMacro && !sym2.isMacro
+
def doubleDefError(sym1: Symbol, sym2: Symbol) {
// the .toString must also be computed at the earlier phase
val tpe1 = afterRefchecks(root.thisType.memberType(sym1))
@@ -920,7 +923,7 @@ abstract class Erasure extends AddInterfaces
if (e.sym.isTerm) {
var e1 = decls.lookupNextEntry(e)
while (e1 ne null) {
- if (afterPostErasure(e1.sym.info =:= e.sym.info)) doubleDefError(e.sym, e1.sym)
+ if (sameTypeAfterErasure(e1.sym, e.sym)) doubleDefError(e.sym, e1.sym)
e1 = decls.lookupNextEntry(e1)
}
}
@@ -939,7 +942,8 @@ abstract class Erasure extends AddInterfaces
while (opc.hasNext) {
if (!afterRefchecks(
root.thisType.memberType(opc.overriding) matches
- root.thisType.memberType(opc.overridden))) {
+ root.thisType.memberType(opc.overridden)) &&
+ sameTypeAfterErasure(opc.overriding, opc.overridden)) {
debuglog("" + opc.overriding.locationString + " " +
opc.overriding.infosString +
opc.overridden.locationString + " " +
View
0  test/files/pos/t7776.check
No changes.
View
12 test/files/pos/t7776.scala
@@ -0,0 +1,12 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.Context
+
+class MacroErasure {
+ def app(f: Any => Any, x: Any): Any = macro MacroErasure.appMacro
+ def app[A](f: A => Any, x: Any): Any = macro MacroErasure.appMacroA[A]
+}
+
+object MacroErasure {
+ def appMacro(c: Context)(f: c.Expr[Any => Any], x: c.Expr[Any]): c.Expr[Any] = ???
+ def appMacroA[A](c: Context)(f: c.Expr[A => Any], x: c.Expr[Any])(implicit tt: c.WeakTypeTag[A]): c.Expr[Any] = ???
+}
Please sign in to comment.
Something went wrong with that request. Please try again.