Skip to content

Commit 492aa60

Browse files
committed
constant fold in forwarder for backwards compat
1 parent b8a7aa0 commit 492aa60

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/compiler/scala/tools/nsc/transform/Mixin.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,14 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
11021102
// add forwarders
11031103
assert(sym.alias != NoSymbol, sym)
11041104
// debuglog("New forwarder: " + sym.defString + " => " + sym.alias.defString)
1105-
if (!sym.isMacro) addDefDef(sym, Apply(staticRef(sym.alias), gen.mkAttributedThis(clazz) :: sym.paramss.head.map(Ident)))
1105+
if (!sym.isMacro) {
1106+
val rhs =
1107+
enteringPickler(sym.info) match {
1108+
case ct: ConstantType => gen.mkAttributedQualifier(ct) // don't call forwarder if it's just going to return a literal
1109+
case _ => Apply(staticRef(sym.alias), gen.mkAttributedThis(clazz) :: sym.paramss.head.map(Ident))
1110+
}
1111+
addDefDef(sym, rhs)
1112+
}
11061113
}
11071114
}
11081115
}

0 commit comments

Comments
 (0)