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

Crash in BaseTypeValidator.visitParameterizedType: ClassCastException #4878

Closed
cushon opened this issue Aug 10, 2021 · 0 comments · Fixed by #4882
Closed

Crash in BaseTypeValidator.visitParameterizedType: ClassCastException #4878

cushon opened this issue Aug 10, 2021 · 0 comments · Fixed by #4882
Assignees
Labels

Comments

@cushon
Copy link
Contributor

cushon commented Aug 10, 2021

This reproduces at head with #4866 and #4875 patched in:

import java.util.List;

interface M {}

class A<T extends M, F> {
  void p(T v) {}
}

abstract class S<T extends M> {
  abstract List<A<T, ?>> p();
}

class X {

  <T extends M> void f(S<?> s, T v) {
    s.p()
        .forEach(
            field -> {
              A<T, ?> typedField = (A<T, ?>) field;
              typedField.p(v);
            });
  }
}
error: SourceChecker.typeProcess: unexpected Throwable (ClassCastException) while processing X.java; message: class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedTypeVariable cannot be cast to class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType (org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedTypeVariable and org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType are in unnamed module of loader java.net.URLClassLoader @3498ed)
  ; The Checker Framework crashed.  Please report the crash.
  Compilation unit: X.java
  Last visited tree at line 18 column 13:
              field -> {
  Exception: java.lang.ClassCastException: class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedTypeVariable cannot be cast to class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType (org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedTypeVariable and org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType are in unnamed module of loader java.net.URLClassLoader @3498ed); java.lang.ClassCastException: class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedTypeVariable cannot be cast to class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType (org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedTypeVariable and org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedWildcardType are in unnamed module of loader java.net.URLClassLoader @3498ed)
        at org.checkerframework.common.basetype.BaseTypeValidator.visitParameterizedType(BaseTypeValidator.java:575)
        at org.checkerframework.common.basetype.BaseTypeValidator.visitDeclared(BaseTypeValidator.java:334)
        at org.checkerframework.common.basetype.BaseTypeValidator.visitDeclared(BaseTypeValidator.java:57)
        at org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType.accept(AnnotatedTypeMirror.java:955)
        at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.scan(AnnotatedTypeScanner.java:206)
        at org.checkerframework.framework.type.visitor.AnnotatedTypeScanner.visit(AnnotatedTypeScanner.java:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants