typetools / typetools/checker-framework

Crash on outer.new Inner(outer) {}.

Open
#8,017 0 comments 0 reactions 1 assignee View on GitHub

@smillst is already working on this.

Since Aug 20, 2026.

crash
Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

Crash on outer.new Inner(outer) {}: synthetic enclosing-instance parameter is mis-aligned with the arguments

Reproducer

public class Repro {
  class Inner {
    Inner(Repro o) {}
  }

  void test(Repro outer) {
    outer.new Inner(outer) {};
  }
}
AssertionError: numRequired 2 should equal 1 in checkArguments(
  [@H1Top @H2S2 Issue282, @H1Top @H2Top Issue282], [outer], constructor, [x0,o])

Which code crashes

A qualified new (enclosing expression written explicitly) that creates an anonymous
subclass of an inner class
, where the first explicit argument has the same type as the
enclosing class
, and the call is not varargs.

Removing any one of those conditions avoids the crash:

  • no class body — outer.new Inner(outer); is fine (the parameter list has no x0)
  • a first argument of a different type — outer.new Inner("s") {}; is fine, and so is
    outer.new Inner(null) {};
  • no enclosing expression — new Inner(this) {}; inside Repro is fine (javac supplies a
    synthetic argument, so the counts match). A bare this. qualifier is enough to trigger the
    crash, though: this.new Inner(this) {}; crashes.

Only the first argument matters: outer.new Inner(outer, "s") {}; crashes as well.

There's also a test case that issues new errors in addition to the crash.

Enable framework/tests/h1h2checker/Issue282.java.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.