typetools / typetools/checker-framework

Unexpected compilation error Enum<Enum<...

Open
#1,250 2 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

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.Set;
import java.util.TreeSet;

public class Test<K extends Enum<K>, A extends Annotation> {

    public static <K extends Enum<K>, A extends Annotation> Set<String> foo(Test<K, A> test, Class<?> cl){
        Set<String> result = new TreeSet<>();
        for (Field field : cl.getFields()) {
            result.addAll(foo(test, field.getType()));
        }
        return result;
    }
}

Produce error
Error:(13, 30) java: [type.argument.type.incompatible] incompatible types in type argument.
found : Enum<K extends Enum>
required: Enum<Enum<K extends Enum>>

CF 2.1.0

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 compiling the supplied Java reproducer with Checker Framework 2.1.0 and inspect the type-argument incompatibility reported at line 13. Trace the checker’s handling of the nested Enum and Annotation bounds; done means the valid case no longer produces the diagnostic, with a regression test covering the reproducer.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.