typetools / typetools/checker-framework
Crash on outer.new Inner(outer) {}.
Open
@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 nox0) - 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) {};insideReprois fine (javac supplies a
synthetic argument, so the counts match). A barethis.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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.