Skip to content

Threading annotations hit on lambda, not class or method ref #8

@JakeWharton

Description

@JakeWharton

Here's a minimum representative sample which illustrates the problem:
screen shot 2015-08-31 at 5 49 58 pm

Now this code is 100% contrived. One could imagine doInBackground using an Executor or hell, AsyncTask. But for the purposes of the bug it actually needs no implementation.

For copy/paste:

  @WorkerThread static void doSomething() {}
  static void doInBackground(Runnable r) {}

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    doInBackground(new Runnable() {
      @Override public void run() {
        doSomething();
      }
    });
    doInBackground(() -> doSomething());
    doInBackground(MainActivity::doSomething);
  }

Now I don't know about the implementation of this library, but it seems like it is exposing the code inside of the lambda to lint as if it were a part of the surrounding method rather than nested in a context similar to an anonymous class. Ideally the behavior would be exactly that as an anonymous class but I don't know if you have all the information needed for that or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions