You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/10/23 16:07:00 UTC

[jira] [Commented] (GROOVY-10327) Compiler crash when combining closure with function reference

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

Eric Milles commented on GROOVY-10327:
--------------------------------------

Supposed to be fixed by: https://github.com/apache/groovy/commit/5864765e5819e7227740df99b59e499cb4150e60

> Compiler crash when combining closure with function reference
> -------------------------------------------------------------
>
>                 Key: GROOVY-10327
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10327
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>    Affects Versions: 4.0.0-beta-1
>            Reporter: Stefanos Chaliasos
>            Assignee: Eric Milles
>            Priority: Major
>
> I have the following Groovy program.
> {code:groovy}
> import java.util.function.Function;
> @groovy.transform.TypeChecked
> class A<X, Y> {
>   void a() {
>     Closure<Integer> x = { Function<Integer, Integer> x -> 1};
>     B b = new B();
>     x(b::b);
>   }
> }
> class B {
>   Integer b(Integer x) { return null; }
> }
> {code}
> h2. Actual Behavior
> The compiler crashes with the following stacktrace.
> {code:java}
> >>> a serious error occurred: null
> >>> stacktrace:
> java.lang.StackOverflowError
> 	at java.base/java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90)
> 	at java.base/java.util.LinkedList$LLSpliterator.tryAdvance(LinkedList.java:1253)
> 	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
> 	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
> 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
> 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
> 	at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)
> 	at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)
> 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
> 	at java.base/java.util.stream.ReferencePipeline.noneMatch(ReferencePipeline.java:538)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferMethodReferenceType(StaticTypeCheckingVisitor.java:3681)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallArguments(StaticTypeCheckingVisitor.java:2794)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferMethodReferenceType(StaticTypeCheckingVisitor.java:3708)
> 	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallArguments(StaticTypeCheckingVisitor.java:2794)
> {code}
> h2. Expected Behavior
> Compile successfully.
> h2. Comment
> Tested against 4-beta-1, and master (commit: 868dabf9fadbddd13c7e8859556e4ed2796f7e1b).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)