Skip to content

Commit f85663a

Browse files
committed
Backport from Linker: ElimStaticThis: allow more calls to static methods
Before there was an implicit assumption that static methods are only present on objects. This assumption is invalidated both by linker optimizations and the new fix to lambdalift.
1 parent 86213e3 commit f85663a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/dotty/tools/dotc/transform/ElimStaticThis.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ class ElimStaticThis extends MiniPhaseTransform {
2727
override def transformIdent(tree: tpd.Ident)(implicit ctx: Context, info: TransformerInfo): tpd.Tree = {
2828
if (ctx.owner.enclosingMethod.is(JavaStatic)) {
2929
tree.tpe match {
30-
case TermRef(thiz: ThisType, _) =>
31-
assert(thiz.underlying.typeSymbol.is(ModuleClass))
30+
case TermRef(thiz: ThisType, _) if thiz.underlying.typeSymbol.is(ModuleClass) =>
3231
ref(thiz.underlying.typeSymbol.sourceModule).select(tree.symbol)
32+
case TermRef(thiz: ThisType, _) =>
33+
assert(tree.symbol.is(Flags.JavaStatic))
34+
tree
3335
case _ => tree
3436
}
3537
}

0 commit comments

Comments
 (0)