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

Peter Schmitz commented on GROOVY-8603:
---------------------------------------

At the moment we're hitting the limit only in a few rare cases. I'd guess 64 
should be enough - or 128 to be on the safe side.

 

A collegue of mine happened to take a look into it last week or so and we're 
currently evaluating a patch. As far as I remember his explanation, the limit 
is introduced by some kind of distance function/variable that uses a 32bit int 
and bit shifts each time a class is inherited from. The patch we're currently 
testing switches from shifting to incrementing after the value has already 
shifted several times, e.g. the distance is larger than 10bit.

He is currently unavailable, but should provide the diff in the near future if 
no problems have been found by then.

hth

> @CompileStatic: matching method check limited to 30 super classes
> -----------------------------------------------------------------
>
>                 Key: GROOVY-8603
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8603
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.3.11, 2.4.13, 2.5.0-rc-3
>            Reporter: Peter Schmitz
>            Priority: Major
>              Labels: CompileStatic, Matching, extends, inheritance, method, 
> parameters, typecheck
>
> There is currently a maximum hierarchical depth for childclasses when using 
> compile static.
> The compiler only searches for method parameters that match the provided 
> class or up to 29 super classes. This in return means that the usable 
> hierarchical depth is limited 29 child classes/distance from the root.
> Without CompileStatic this limit does not exists. Changing the following code 
> to Java works too.
> This Code:
> {code:java}
> import groovy.transform.CompileStatic
> @CompileStatic
> class StaticTest {
>    public static int getNummer( ZClassDepth0 instance ) {
>       return instance.depth
>    }
>    public static void main( String[] args ) {
>       println getNummer( new ZClassDepth29() ) //works
>       println getNummer( new ZClassDepth30() ) //doesn't work
>    }
> }
> {code}
> fails with the following execption:
> {code:java}
> Error:(13, 15) Groovyc: [Static type checking] - Cannot find matching method 
> StaticTest#getNummer(ZClassDepth30). Please check if the declared type is 
> right and if the method exists.
> {code}
>  
> How the "ZClassDepth" files where generated:
> {code:java}
> import java.nio.file.Paths
> class Generator {
>    public static void main( String[] args ) {
>       def template = { int nummer ->
>          return """\
> public class ZClassDepth${ nummer } ${ nummer > 0 ? "extends ZClassDepth${ 
> nummer - 1 }" : '' } {
>    ${ nummer > 0 ? '@Override' : '' }
>    public int getDepth() { 
>       return $nummer 
>    }
> }
> """
>       }
>       def path = Paths.get( '[PATH_TO_SOURCE]/src' )
>       101.times{ i ->
>          new File( path.toFile(), "ZClassDepth${i}.groovy" ).text = template( 
> i )
>       }
>    }
> }
> {code}
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to