Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type.argument.inference.crashed for generic exception parameters since 3.43.0 #6887

Open
veikokaap opened this issue Nov 11, 2024 · 0 comments
Assignees

Comments

@veikokaap
Copy link

veikokaap commented Nov 11, 2024

Description

Happens only with diamond operator.
It's been broken since 3.43.0, last working version was 3.42.0.

Command

javac \
-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \
-processorpath ./checker/dist/checker.jar \
-cp ./checker/dist/checker-qual.jar \
-processor org.checkerframework.checker.nullness.NullnessChecker \
-source 21 -target 21 \
./CheckerFailure.java

File

import java.io.IOException;

public final class CheckerFailure<E extends Exception> {

    public CheckerFailure(ThrowingFunctionalInterface<E> throwingFunctionalInterface) {}

    public static void main(String[] args) throws IOException {
        // Works
        new CheckerFailure<IOException>(() -> {
            throw new IOException("");
        });
        // Works
        CheckerFailure<IOException> b = new CheckerFailure<>(() -> {
            throw new IOException("");
        });
        // error: [type.argument.inference.crashed] Type argument inference crashed for CheckerFailure constructor
        new CheckerFailure<>(() -> {
            throw new IOException("");
        });
    }

    @FunctionalInterface
    public interface ThrowingFunctionalInterface<E extends Exception> {
        void throwingFunction() throws E;
    }

}

Expected behaviour

Compilation succeeds.

Actual behaviour

An exception is thrown:

CheckerFailure.java:17: error: [type.argument.inference.crashed] Type argument inference crashed for CheckerFailure constructor
        new CheckerFailure<>(() -> {
        ^
  error: An exception occurred: AnnotatedTypeFactory.getAnnotatedType: query of annotated type for tree THROW
  org.checkerframework.javacutil.BugInCF: AnnotatedTypeFactory.getAnnotatedType: query of annotated type for tree THROW
        at org.checkerframework.framework.type.AnnotatedTypeFactory.getAnnotatedType(AnnotatedTypeFactory.java:1409)
        at org.checkerframework.framework.util.typeinference8.util.CheckedExceptionsUtil$CheckedExceptionATMVisitor.visitThrow(CheckedExceptionsUtil.java:219)
        at org.checkerframework.framework.util.typeinference8.util.CheckedExceptionsUtil$CheckedExceptionATMVisitor.visitThrow(CheckedExceptionsUtil.java:185)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCThrow.accept(JCTree.java:1761)
        at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:92)
        at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
        at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:272)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1104)
        at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:92)
        at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
        at jdk.compiler/com.sun.source.util.TreeScanner.visitLambdaExpression(TreeScanner.java:647)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1997)
        at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:92)
        at org.checkerframework.framework.util.typeinference8.util.CheckedExceptionsUtil.thrownCheckedExceptionsATM(CheckedExceptionsUtil.java:178)
        at org.checkerframework.framework.util.typeinference8.types.InferenceFactory.getCheckedExceptionConstraints(InferenceFactory.java:997)
        at org.checkerframework.framework.util.typeinference8.constraint.CheckedExceptionConstraint.reduce(CheckedExceptionConstraint.java:70)
        at org.checkerframework.framework.util.typeinference8.constraint.ConstraintSet.reduceOneStep(ConstraintSet.java:329)
        at org.checkerframework.framework.util.typeinference8.constraint.ConstraintSet.reduceAdditionalArgOnce(ConstraintSet.java:309)
        at org.checkerframework.framework.util.typeinference8.InvocationTypeInference.getB4(InvocationTypeInference.java:671)
        at org.checkerframework.framework.util.typeinference8.InvocationTypeInference.infer(InvocationTypeInference.java:169)
        at org.checkerframework.framework.util.typeinference8.DefaultTypeArgumentInference.inferTypeArgs(DefaultTypeArgumentInference.java:110)
        at org.checkerframework.common.basetype.BaseTypeVisitor.checkTypeArgumentInference(BaseTypeVisitor.java:1883)
        ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants