groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MG <mg...@arscreat.com>
Subject Re: @MapConstructor + @CompileStatic on Static Inner Class => CTE
Date Tue, 04 Sep 2018 00:10:05 GMT
Might have been reported before. Will do.

On 04.09.2018 00:12, Paul King wrote:
> Please create an issue. VerifyError is always a bug.
>
> On Tue, Sep 4, 2018 at 4:55 AM MG <mgbiz@arscreat.com 
> <mailto:mgbiz@arscreat.com>> wrote:
>
>     The following code using @MapConstructor on a static inner class
>     raises
>     a compile time error (see end of mail; different error when making
>     the
>     inner class non-static):
>
>     import groovy.transform.CompileStatic
>     import groovy.transform.MapConstructor
>
>     @CompileStatic
>     class GroovyMapConstructorCheck {
>
>          @MapConstructor(noArg = true)
>          static class Goo {
>              final String s0 = "text0"
>              final int x0
>              final String s1
>              final String s2 = "TEXT2"
>              final o0
>
>              @Override
>              public String toString() {
>                  return "Goo(|$s0|,|$x0|,|$s1|,|$s2|,|$o0|)"
>              }
>          }
>
>          void go() {
>              println new Goo()
>              println new Goo(s0:"abc")
>              println new Goo(x0:123, s0:"abc")
>              println new Goo(s1:"S1", s2:"S2", x0:-999, o0:new Object(),
>     s0:"S0")
>              final goo = new Goo(s1:"S1", s2:"S2", x0:-999, o0:new
>     Object(),
>     s0:"S0")
>          }
>     }
>
>     final check = new GroovyMapConstructorCheck()
>     check.go()
>
>     /*
>     Compile time error:
>
>     java.lang.VerifyError: Bad type on operand stack
>     Exception Details:
>        Location:
>     GroovyMapConstructorCheck$Goo.<init>(Ljava/util/Map;)V @85:
>     invokevirtual
>        Reason:
>          Type 'GroovyMapConstructorCheck$Goo' (current frame,
>     stack[0]) is
>     not assignable to 'groovy/lang/Closure'
>        Current Frame:
>          bci: @85
>          flags: { }
>          locals: { 'GroovyMapConstructorCheck$Goo', 'java/lang/Object',
>     'java/lang/String', 'java/lang/String', 'groovy/lang/MetaClass' }
>          stack: { 'GroovyMapConstructorCheck$Goo' }
>        Bytecode:
>          0x0000000: 2ab7 001b 121d 4d2c 2a5f b500 1f2c 5712
>          0x0000010: 214e 2d2a 5fb5 0023 2d57 2ab6 0027 3a04
>          0x0000020: 1904 2a5f b500 2919 0457 2bc7 0007 04a7
>          0x0000030: 0004 0399 001a 03bd 0004 b800 2f3a 0519
>          0x0000040: 0512 31b8 0035 c000 314c 1905 572a 2bb8
>          0x0000050: 003b 0157 2ab6 0041 c000 4312 44b9 004a
>          0x0000060: 0200 9900 232a b600 41c0 0043 1244 b900
>          0x0000070: 4e02 003a 0619 06b8 0054 c000 562a 5fb5
>          0x0000080: 001f 1906 572a b600 41c0 0043 1257 b900
>          0x0000090: 4a02 0099 0020 2ab6 0041 c000 4312 57b9
>          0x00000a0: 004e 0200 3a07 1907 b800 5d2a 5fb5 005f
>          0x00000b0: 1907 572a b600 41c0 0043 1260 b900 4a02
>          0x00000c0: 0099 0023 2ab6 0041 c000 4312 60b9 004e
>          0x00000d0: 0200 3a08 1908 b800 54c0 0056 2a5f b500
>          0x00000e0: 6219 0857 2ab6 0041 c000 4312 63b9 004a
>          0x00000f0: 0200 9900 232a b600 41c0 0043 1263 b900
>          0x0000100: 4e02 003a 0919 09b8 0054 c000 562a 5fb5
>          0x0000110: 0023 1909 572a b600 41c0 0043 1264 b900
>          0x0000120: 4a02 0099 001d 2ab6 0041 c000 4312 64b9
>          0x0000130: 004e 0200 3a0a 190a 2a5f b500 6619 0a57
>          0x0000140: b1
>        Stackmap Table:
>     full_frame(@50,{Object[#2],Object[#70],Object[#86],Object[#86],Object[#108]},{})
>          same_locals_1_stack_item_frame(@51,Integer)
>     full_frame(@77,{Object[#2],Object[#4],Object[#86],Object[#86],Object[#108]},{})
>          same_frame(@133)
>          same_frame(@179)
>          same_frame(@228)
>          same_frame(@277)
>          same_frame(@320)
>
>
>          at
>     GroovyMapConstructorCheck.go(MapConstructorCheck_inner_class_error.groovy:24)
>
>          at GroovyMapConstructorCheck$go.call(Unknown Source)
>
>          at
>     MapConstructorCheck_inner_class_error.run(MapConstructorCheck_inner_class_error.groovy:33)
>     */
>


Mime
View raw message