Skip to content

Crash: a call argument that is itself a call, in a file that declares a record (CtRecordImpl does not have CtRole.TYPE) #568

Backlog

Description

@CatarinaGamboa

Verifying this file crashes on main (9974d9b). It passes on 1a506fe.

public class RecordArg {
    record Point(int x, int y) {}

    static int twice(int n) { return 2 * n; }

    static int size() { return 3; }

    static int f() {
        return twice(size());
    }
}
Exception in thread "main" java.lang.RuntimeException:
Error while checking CtMethodImpl
  on f() {
...
  with The element of class class spoon.support.reflect.declaration.CtRecordImpl does not have CtRole.TYPE

It needs no annotations, only a record somewhere in the file and a call whose argument is a call (twice(size())).

First bad commit (git bisect): 9aa2467 "Write a call argument as the caller wrote it in refinement errors" (#486). MethodsFunctionsChecker.createVariableRepresentingArgument now calls getOriginalSourceFragment() on call arguments. Spoon's fragment builder then walks the file's record and throws.

A possible fix: catch the SpoonException and fall back to toString(), or read the argument's text from its source position.

Found while moving liquid-java/co-specification to main: a mined client with a record Result (ImageWriteParam, E_OSS_A1_04) now crashes for every spec. Related, but a different path: #369.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions