Skip to content

fix viewpoint adaptation#614

Closed
AndrewShf wants to merge 7 commits into
eisop:masterfrom
AndrewShf:viewpointAdpatOnGenerics
Closed

fix viewpoint adaptation#614
AndrewShf wants to merge 7 commits into
eisop:masterfrom
AndrewShf:viewpointAdpatOnGenerics

Conversation

@AndrewShf

@AndrewShf AndrewShf commented Oct 27, 2023

Copy link
Copy Markdown
Member

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.

@wmdietl

wmdietl commented Jan 3, 2025

Copy link
Copy Markdown
Member

Closed in favor of #799.

@wmdietl wmdietl closed this Jan 3, 2025
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.

3 participants