typetools / typetools/checker-framework

Type of "this" in field initializers & initializer blocks must be the least upper bound of all constructor result annotations

Open
#2,265 0 comments 0 reactions 1 assignee View on GitHub

@smillst is already working on this.

Since Mar 6, 2019.

Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

In the lock checker, @GuardedBy <: @GuardedByUnknown.
Consider the following example which has an initialization block.

import org.checkerframework.checker.lock.qual.GuardedByUnknown;
import org.checkerframework.checker.lock.qual.GuardedBy;

public class InitializerLub{
    {
        @GuardedBy InitializerLub field = this;
    }
    @GuardedByUnknown InitializerLub() {}
}

We expect the type of this to be the least upper bound of all constructor types (@GuardedByUnknown in this example). So, the checker framework must report an error at line @GuardedBy InitializerLub field = this; because this should have type @GuardedByUnknown and assigning this to type @GuardedBy is illegal.
However, the command javac -processor tainting InitializerLub.java doesn't produce any warning.
This suggests that the checker framework incorrectly annotates the type of this with the default qualifier in hierarchy instead of the lub of all constructor types.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.