Skip to content

Bootstrap failure: wrong static initializer of inner class #751

Closed
@odersky

Description

@odersky

If I compile everything in src/dotty and run the resulting program without arguments I get:

dotc
Exception in thread "main" java.lang.NoSuchMethodError: dotty.tools.dotc.ast.Trees$Instance$TreeMap$: method ()V not found
at dotty.tools.dotc.ast.Trees$Instance$TreeMap$.(Trees.scala)
at dotty.tools.dotc.ast.Trees$Instance.(Trees.scala:1087)
at dotty.tools.dotc.ast.untpd$.(untpd.scala:13)
at dotty.tools.dotc.ast.untpd$.(untpd.scala)
at dotty.tools.dotc.core.Contexts$InitialContext.(Contexts.scala:467)
at dotty.tools.dotc.core.Contexts$ContextBase.(Contexts.scala:493)

Investigation with javap shows that TreeMap has a static initializer which tries to create a TreeMap object with an empty constructor. But TreeMap is an inner class, so the constructor takes an outer pointer.

Compiled from "Trees.scala"
public final class dotty.tools.dotc.ast.Trees$Instance$TreeMap$ {
public static final dotty.tools.dotc.ast.Trees$Instance$TreeMap$ MODULE$;

public static {};
Code:
0: new #2 // class dotty/tools/dotc/ast/Trees$Instance$TreeMap$
3: invokespecial #23 // Method "":()V
6: return

public dotty.tools.dotc.ast.Trees$Instance$TreeMap$(dotty.tools.dotc.ast.Trees$Instance);
Code:

The whole static initializer seems to be a random artefact, since TreeMap does not have a companion object.

Edit: No, it does have a synthetic companion object (which contains default arguments). But since it's an inner class of the outer class Instance it should not have a static initializer that creates an instance, it seems to me.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions