Skip to content

VarAccess: Support lambda parameters #38

@knutwannheden

Description

@knutwannheden

Currently, a VarAccessTest test case like the following fails:

    @Test
    void lambdaParameter() {
        rewriteRun(
          java(
            """
              interface Fun {
                  String message(String s);
              }
                        
              class Test {
                  void test() {
                      Fun foobar = (s) -> s;
                  }
              }
              """,
            """
              interface Fun {
                  String message(String s);
              }
              
              class Test {
                  void test() {
                      Fun foobar = (s) -> /*~~>*/s;
                  }
              }
              """
          )
        );
    }

The Parameter trait does not yet support lambdas. From the docs I tried to understand how CodeQL models lambdas. It looks like a lambda is somehow a wrapper around a Method and thus somehow resembles the Java runtime view of a lambda. The lambda's parameters are then declared on this method.

I don't remember / understand CodeQL well enough to see how we should translate this into the traits we have. Intuitively I would otherwise have made the LambdaExpr trait extend Callable. But that would be a deviation of CodeQL.

@JLLeitschuh Can you provide some guidance here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions