typetools / typetools/checker-framework

Permit stub files to specify non-existent overriding methods

Open
#3,094 2 comments 1 reaction 0 assignees View on GitHub

A pull request for this has already been merged.

  • #4275 by @mernst — merged
enhancement
Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

Sometimes, a method defined in a superclass behaves differently for a subclass, even though the subclass inherits the method (the subclass does not override or redefine the method). Here is a trivial example:

class Super {
  int a() { return Random.nextInt(); }

  int b() { return this.a(); }
}

class Sub extends Super {
  @NonNegative int a() { return Random.nextInt(Integer.MAX_VALUE); }
}

The return type of Sub.b is @NonNegative int, but there is no way to specify this fact.

As a more realistic example, consider javax.lang.model.element.Name.
It should be specified by

interface Name {
    @PolySignature String toString(@PolySignature Name this);
}

but Name does not define an override of toString.

Here are some more words to make this issue more discoverable by searching: override, overridden, inherit, inherited.

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

Start by tracing how stub files represent methods and inherited members, using the Super/Sub example and javax.lang.model.element.Name as cases to support. Determine how a stub can describe an inherited method without declaring a real override. Done means stub files can express the differing contract for inherited methods and the relevant checker behavior is covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.