typetools / typetools/checker-framework

Error message on "Do so by passing the top qualifier from the given hierarchy." violation is not informative

Open
#7,652 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

If you create custom type hierarchy with subtyping checker, add polymorphic qualifier and pass to PolymorphicQualifier meta-annotation value() property class that is not top qualifier, you will get TypeSystemError that says something about bottom types, rather than that you have passed not the top qualifier. Debugging this can be quite tedious.

Example:

@DefaultQualifierInHierarchy
@SubtypeOf({})
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface root { }

@SubtypeOf({
    foo.class, boo.class, goo.class
})
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface bottom { }

@SubtypeOf(root.class)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface goo { }

@SubtypeOf(goo.class)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface foo { }

@SubtypeOf(goo.class)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface boo { }

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@PolymorphicQualifier(goo.class)
public @interface polygoo { }

will get you this error.

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 reproducing the Java custom type hierarchy and polymorphic qualifier example from the issue, then trace where the TypeSystemError for the invalid PolymorphicQualifier value is constructed. Done means the diagnostic explains that the supplied qualifier is not the top qualifier, rather than referring misleadingly to bottom types.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.