typetools / typetools/checker-framework

Issue error if type arguments differ when the same interface is inherited by multiple super types

Open
#679 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug False Negative (missing warning or unsoundness)
Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

If a class implements the same interface as its super class, then the AnnotatedTypeMirrors of type arguments must be equivalent. If they are not, an error should be issued. For example,

interface Interface<T> {}
class B implements Interface<@NonNull Integer> {}
class A extends B implements Interface<@Nullable Integer> {}

An error should be issued at A's declaration. This is consistent with the error issued by javac if they java types where not the same.

interface Interface<T> {}
class B implements Interface<Integer> {}
class A extends B implements Interface<String> {}

The code above issues the error below:

error: Interface cannot be inherited with different arguments: <java.lang.String> and <java.lang.Integer>
    class A extends B implements Interface<String> {}
    ^

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.

Research direction

No files or tests are named. Start by locating the Java type-checking logic that handles inherited interfaces and compare the AnnotatedTypeMirrors for repeated interface type arguments; done means reporting an error at A's declaration when those arguments differ, with a regression test for the examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.