Skip to content

Generic mismatch message against an intersection target marks no position in the target #2202

Backlog

Description

@vlsi

Kind of problem

Other

Minimal reproducer

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

@NullMarked
class Test {
  interface A<T extends @Nullable Object> {}
  interface D<T extends @Nullable Object> {}
  static class B implements A<@Nullable String>, D<@Nullable String> {}

  static void test(Object o) {
    var x = (A<String> & D<String>) o;
    x = new B();
  }
}

Actual behavior

incompatible nullability in type argument for T of A and 1 other position: source has @Nullable String where target requires String
    source: B
    target: A<String> & D<String>

    1. path: type argument for T of A
       source: @Nullable String
       target: String

    2. path: type argument for T of D
       source: @Nullable String
       target: String

Expected behavior

The target: line has a caret under each differing String, numbered 1 and 2, as for any other target with two differing positions. The numbered entries already name both positions; only the carets are missing.

NullAway configuration

JSpecify mode, -XepOpt:NullAway:OnlyNullMarked=true

NullAway version

Branch of #1828 at 06c4764 (not released); the carets are introduced by that PR.

Error Prone version

2.53.0

JDK version

21.0.9

Additional context

Pinned by ViewedSourceTests.eachComponentOfAnIntersectionTargetIsComparedUnderItsOwnView in #1828.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions