You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2026/03/19 16:51:00 UTC

[jira] [Commented] (GROOVY-11754) Compilation error: ClassCastException (unnamed module)

    [ https://issues.apache.org/jira/browse/GROOVY-11754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18066841#comment-18066841 ] 

ASF GitHub Bot commented on GROOVY-11754:
-----------------------------------------

eric-milles opened a new pull request, #2397:
URL: https://github.com/apache/groovy/pull/2397

   Changes to `StaticTypesTypeChooser` in Groovy 5 caused a cast exception at runtime for statically-compiled imbalanced-`instanceof` scenarios like `if (cn instanceof InnerClassNode || cn.isEnum())`.  This traces back to the temp types storage in STC.  For the statement above, only `InnerClassNode` is saved as a temp type.  When the temp type is computed for "cn.isEnum()", `InnerClassNode` is the result.
   
   A small part of the GROOVY-7971 solution is to mix in the original variable type in a scenario such as this 

> Compilation error: ClassCastException (unnamed module)
> ------------------------------------------------------
>
>                 Key: GROOVY-11754
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11754
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 5.0.1
>            Reporter: Mattias Reichel
>            Assignee: Eric Milles
>            Priority: Major
>
> To reproduce:
> {noformat}
> git clone https://github.com/matrei/grails-core.git
> cd grails-core
> git checkout groovy-5 # or 9538ca0c458e08f175e57618d0cefc24b59467f4
> ./gradlew grails-datastore-core:compileTestGroovy{noformat}
>  
> {noformat}
> Execution failed for task ':grails-datastore-core:compileTestGroovy'.
> > BUG! exception in phase 'semantic analysis' in source unit '/home/mattias/test/grails-core/grails-datastore-core/src/test/groovy/org/grails/datastore/mapping/model/JpaMappingSyntaxTests.groovy' class org.codehaus.groovy.ast.ClassNode cannot be cast to class org.
> codehaus.groovy.ast.InnerClassNode (org.codehaus.groovy.ast.ClassNode and org.codehaus.groovy.ast.InnerClassNode are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @6cd5cc65) {noformat}
> Build scan: https://ge.grails.org/s/aq37mleqgllxw



--
This message was sent by Atlassian Jira
(v8.20.10#820010)