[
https://issues.apache.org/jira/browse/GROOVY-10035?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17321825#comment-17321825
]
Daniel Sun commented on GROOVY-10035:
-------------------------------------
As I explained in the following comment, the proposal is to tweak the original
fix, not only simplify the check but also make it general to eliminate more
redundant type cast.
[https://github.com/apache/groovy/pull/1561#discussion_r613659839]
We have to admit that API is more friendly than implementation to developers,
so {{isCompatibleWith}} is more complicated than the original check though, it
helps us make the code a bit more readable and eliminate more redundant type
cast, no pain no gain ;)
> Eliminate redundant type cast
> -----------------------------
>
> Key: GROOVY-10035
> URL: https://issues.apache.org/jira/browse/GROOVY-10035
> Project: Groovy
> Issue Type: Improvement
> Components: bytecode
> Reporter: Eric Milles
> Priority: Minor
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> The ticket is to provide some suggestion to tweak the fix of GROOVY-10034 (
> [https://github.com/apache/groovy/pull/1556] ):
> It seems that we could make the check simpler, we do not add extra checks but
> tweak the existing check.
> h3. *Current*
> [https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/classgen/asm/OperandStack.java#L334]
> {code:java}
> if (targetType == top) return;
> {code}
> h3. *Proposed*
> [https://github.com/apache/groovy/pull/1561]
> {code:java}
> if (ClassNodeUtils.isCompatibleWith(top, targetType)) return;
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)