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

fix viewpoint adaptation #614

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

AndrewShf
Copy link
Member

@AndrewShf AndrewShf commented Oct 27, 2023

According to the manual (https://eisop.github.io/cf/manual/manual.html#type-variable-use), if the type variable use and the corresponding type argument both are annotated by type qualifiers, we will keep the one presented on the type variable use.
For example,

class MyClass<T> {
  ...
  @Nullable T myField = null;
  ...
}

The myField field of the local variable MyClass<@NonNull Object> mc still has type @Nullable.

However, this rule is broken in context-sensitive type systems (For example, PICO, viewpointtest)

Consider the viewpointtest checker

@SuppressWarnings("cast.unsafe.constructor.invocation")
class Demo<E> {
    @A E element;

    static void test() {
        @A Demo<@B Element> d = new @A Demo<@B Element>();
        // d.element = @A |> @ A = @A
        // thus expects no error here
        d.element = new @A Element();
    }
}

class Element {
    int f = 1;
}

viewpointtest is a context-sensitive type system for testing purposes. @A, @B are not incompatible type qualifiers. It acts differently than what we have discussed earlier when doing type substitution for d.element, replacing @A E with @B Element, instead of keeping @A on the field, and would report an assignment.type.incompatible error in the assignment of the static test method.

We realize it is in the process of viewpoint adaptation, the type substitution goes wrong, and we fix the bug there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants