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

Treat ClassName.this like this #2208

Closed
mernst opened this issue Nov 15, 2018 · 1 comment · Fixed by #3659
Closed

Treat ClassName.this like this #2208

mernst opened this issue Nov 15, 2018 · 1 comment · Fixed by #3659

Comments

@mernst
Copy link
Member

mernst commented Nov 15, 2018

Consider the following test case:

import org.checkerframework.checker.initialization.qual.UnderInitialization;
import org.checkerframework.checker.nullness.qual.Raw;

public class ThisLiteralQualified {
    public ThisLiteralQualified() {
        super();
        @UnderInitialization @Raw ThisLiteralQualified a = this;
        @UnderInitialization @Raw ThisLiteralQualified b = ThisLiteralQualified.this;
    }
}

The expressions this and ThisLiteralQualified.this should be treated identically.

However, the Nullness Checker issues a warning for the latter but not for the former:

ThisLiteralQualified.java:13: error: [assignment.type.incompatible] incompatible types in assignment.
        @UnderInitialization @Raw ThisLiteralQualified b = ThisLiteralQualified.this;
                                                                               ^
  found   : @Initialized @NonNull ThisLiteralQualified
  required: @UnderInitialization @Nullable ThisLiteralQualified
1 error
@wmdietl
Copy link
Member

wmdietl commented Nov 15, 2018

Possibly related: #352

@smillst smillst self-assigned this Mar 19, 2019
@mernst mernst added this to the Low milestone Apr 12, 2019
mernst added a commit that referenced this issue Dec 1, 2019
smillst added a commit that referenced this issue Sep 15, 2020
This pull request corrects the type of both implicit and explicit `this` references by correctly computing the enclosing type of `this`.

This pull request fixes two kinds of bugs: 
1. The type of `Outer.this` when used in an inner class.   (Issues #352, #2208, and #3561.)
2. For the Initialization Checker, the type of `Outer.this` when used in an anonymous class declared in a constructor. (Issues #354, part of #904, and #3408)

#409 (and other duplicate issues) is a related bug in the Initialization Checker, but isn't fixed by this PR.

Closes #352, closes #354, closes #2208, closes #3266, closes #3408 and closes #3561.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants