Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VarAccess: Support lambda parameters #38

Open
knutwannheden opened this issue Nov 9, 2023 · 1 comment
Open

VarAccess: Support lambda parameters #38

knutwannheden opened this issue Nov 9, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@knutwannheden
Copy link
Contributor

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?

@knutwannheden knutwannheden added the enhancement New feature or request label Nov 9, 2023
@JLLeitschuh
Copy link
Collaborator

This is one of those problems I realized was more complex than I could solve with the time I had.

I want to model this right, but, off hand, I don't have any answers here right now.

What I really need to do is sit down and write some test CodeQL queries and attempt to model lambdas and see what API's return what. That way I can verify that what we do for this API matches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

2 participants