This is an automated email from the ASF dual-hosted git repository. paulk pushed a commit to branch GROOVY_2_5_X in repository https://gitbox.apache.org/repos/asf/groovy.git
commit bcd8b6914f88ba39e04db05b9b25c0e8f9b888af Author: Paul King <pa...@asert.com.au> AuthorDate: Fri Jan 11 18:20:13 2019 +1000 GROOVY-8954: VerifyError due to incorrect bytecode produced when a trait super property call also comes from an interface (closes #852) --- .../groovy/classgen/asm/InvocationWriter.java | 4 ++-- .../traitx/TraitASTTransformationTest.groovy | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java index a7dd34c..79e9946 100644 --- a/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java +++ b/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java @@ -151,10 +151,10 @@ public class InvocationWriter { int opcode = INVOKEVIRTUAL; if (target.isStatic()) { opcode = INVOKESTATIC; - } else if (target.isPrivate() || ((receiver instanceof VariableExpression && ((VariableExpression) receiver).isSuperExpression()))) { - opcode = INVOKESPECIAL; } else if (declaringClass.isInterface()) { opcode = INVOKEINTERFACE; + } else if (target.isPrivate() || ((receiver instanceof VariableExpression && ((VariableExpression) receiver).isSuperExpression()))) { + opcode = INVOKESPECIAL; } // handle receiver diff --git a/src/test/org/codehaus/groovy/transform/traitx/TraitASTTransformationTest.groovy b/src/test/org/codehaus/groovy/transform/traitx/TraitASTTransformationTest.groovy index 27ecd8d..d4c27b3 100644 --- a/src/test/org/codehaus/groovy/transform/traitx/TraitASTTransformationTest.groovy +++ b/src/test/org/codehaus/groovy/transform/traitx/TraitASTTransformationTest.groovy @@ -2668,4 +2668,24 @@ assert c.b() == 2 assert Counter.count == 11 ''' } + + //GROOVY-8954 + void testTraitWithPropertyAlsoFromInterfaceSC() { + assertScript ''' + interface DomainProp { + boolean isNullable() + } + + abstract class OrderedProp implements DomainProp { } + + trait Nullable { + boolean nullable = true + } + + @groovy.transform.CompileStatic + abstract class CustomProp extends OrderedProp implements Nullable { } + + assert new CustomProp() {} + ''' + } }