Skip to content

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

@PukPukov

Description

@PukPukov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions