Skip to content

[java] Disambiguation IllegalStateException resolving a synthesized record accessor used as a call argument alongside an anonymous class #6768

Closed

Description

@stevenschlansker

Affects PMD Version:

7.25

Description:

A single method/constructor invocation that has, in its argument list, both a call to a record's implicitly synthesized accessor and an anonymous class instantiation produces a processing error during type resolution. The anonymous-class argument forces Infer to compute the sibling arguments' standalone types; resolving the accessor return type via AstRecordComponentSym.getTypeMirror reads the record component's ASTClassType, which the disambiguation pass never populated, throwing IllegalStateException: Disambiguation pass should resolve everything except qualified ctor calls.

Exception Stacktrace:

[WARNING] There is 1 PMD processing error:
[WARNING] /J.java: ContextedRuntimeException: java.lang.IllegalStateException: Disambiguation pass should resolve everything except qualified ctor calls
Exception Context:
	[1:Resolving type of=!debug only! [ClassType:4:18]String]
	[2:Location=!debug only! /J.java:4:18]
	[3:Resolving type of=!debug only! [VariableId:4:25]userView]
	[4:Location=!debug only! /J.java:4:25]
	[5:Resolving type of=!debug only! [MethodCall:6:39]convert(actor.userView(), new Object() {})]
	[6:Location=!debug only! /J.java:6:39]
	[7:Resolving type of=!debug only! [ConstructorCall:6:65]new Object() {}]
	[8:Location=!debug only! /J.java:6:65]

Code Sample demonstrating the issue:

public class J {
    record Actor(String userView) {}
    static Object convert(Object a, Object b) { return null; }
    Object make(Actor actor) { return convert(actor.userView(), new Object() {}); }
}

Steps to reproduce:

Please provide detailed steps for how we can reproduce the bug.

pmd check -d J.java \
    -R category/java/bestpractices.xml/UnusedPrivateMethod \
    --use-version java-21

Running PMD through: Maven

Activity

  1. added
    a:bug
    on Jun 8, 2026
  2. added a commit that references this issue on Jul 14, 2026
    14f0c14
  3. added this to the 7.27.0 milestone on Jul 16, 2026
  4. added a commit that references this issue on Jul 16, 2026
    aed5491
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions