[
https://issues.apache.org/jira/browse/GROOVY-11375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18028435#comment-18028435
]
ASF GitHub Bot commented on GROOVY-11375:
-----------------------------------------
eric-milles commented on PR #2311:
URL: https://github.com/apache/groovy/pull/2311#issuecomment-3382724018
I'm reluctant to merge myself because GROOVY-11769 is about bytecode
optimization, not failing functionality. And GROOVY-11375 was not strong
enough on its own to make this change earlier.
> Power binary expression finds incorrect type - currently uses declaration
> inferred type
> ---------------------------------------------------------------------------------------
>
> Key: GROOVY-11375
> URL: https://issues.apache.org/jira/browse/GROOVY-11375
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 5.0.0-alpha-8, 4.0.21
> Reporter: Paul King
> Assignee: Eric Milles
> Priority: Major
> Fix For: 5.0.0-alpha-9
>
>
> For this code:
> {code}
> @groovy.transform.CompileStatic
> def method() {
> var temp = 'foo'
> temp = temp.size()
> assert temp ** temp == 27
> }
> method()
> {code}
> The compiler gives this error:
> {noformat}
> BUG! exception in phase 'class generation' in source unit 'ConsoleScript3' At
> line 10 column 8
> On receiver: temp with message: power and arguments: temp
> This method should not have been called. Please try to create a simple
> example reproducing
> this error and file a bug report at
> https://issues.apache.org/jira/browse/GROOVY
> at
> org.codehaus.groovy.classgen.asm.sc.StaticTypesCallSiteWriter.makeSingleArgumentCall(StaticTypesCallSiteWriter.java:582)
> at
> org.codehaus.groovy.classgen.asm.InvocationWriter.makeSingleArgumentCall(InvocationWriter.java:626)
> at
> org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateBinaryExpression(BinaryExpressionHelper.java:602)
> at
> org.codehaus.groovy.classgen.asm.BinaryExpressionMultiTypeDispatcher.evaluateBinaryExpression(BinaryExpressionMultiTypeDispatcher.java:242)
> at
> org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.eval(BinaryExpressionHelper.java:264)
> at
> org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:849)
> ...
> {noformat}
> We apply flow typing for the receiver but not the argument type. This looks
> like a case that should be handled where we currently have "TODO: more cases
> ..." in StaticTypesCallSiteWriter.
> The same situation occurs for the shift operators and plus etc., e.g.:
> {code}
> assert temp << temp == 24
> assert temp + temp == 6
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)