Re: @MapConstructor + @CompileStatic on Static Inner Class => CTE

2018-09-03 Thread MG

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 > 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.(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:
 0x000: 2ab7 001b 121d 4d2c 2a5f b500 1f2c 5712
 0x010: 214e 2d2a 5fb5 0023 2d57 2ab6 0027 3a04
 0x020: 1904 2a5f b500 2919 0457 2bc7 0007 04a7
 0x030: 0004 0399 001a 03bd 0004 b800 2f3a 0519
 0x040: 0512 31b8 0035 c000 314c 1905 572a 2bb8
 0x050: 003b 0157 2ab6 0041 c000 4312 44b9 004a
 0x060: 0200 9900 232a b600 41c0 0043 1244 b900
 0x070: 4e02 003a 0619 06b8 0054 c000 562a 5fb5
 0x080: 001f 1906 572a b600 41c0 0043 1257 b900
 0x090: 4a02 0099 0020 2ab6 0041 c000 4312 57b9
 0x0a0: 004e 0200 3a07 1907 b800 5d2a 5fb5 005f
 0x0b0: 1907 572a b600 41c0 0043 1260 b900 4a02
 0x0c0: 0099 0023 2ab6 0041 c000 4312 60b9 004e
 0x0d0: 0200 3a08 1908 b800 54c0 0056 2a5f b500
 0x0e0: 6219 0857 2ab6 0041 c000 4312 63b9 004a
 0x0f0: 0200 9900 232a b600 41c0 0043 1263 b900
 0x100: 4e02 003a 0919 09b8 0054 c000 562a 5fb5
 0x110: 0023 1909 572a b600 41c0 0043 1264 b900
 0x120: 4a02 0099 001d 2ab6 0041 c000 4312 64b9
 0x130: 004e 0200 3a0a 190a 2a5f b500 6619 0a57
 0x140: 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)
*/





Re: @MapConstructor + @CompileStatic on Static Inner Class => CTE

2018-09-03 Thread Paul King
Please create an issue. VerifyError is always a bug.

On Tue, Sep 4, 2018 at 4:55 AM MG  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.(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:
>  0x000: 2ab7 001b 121d 4d2c 2a5f b500 1f2c 5712
>  0x010: 214e 2d2a 5fb5 0023 2d57 2ab6 0027 3a04
>  0x020: 1904 2a5f b500 2919 0457 2bc7 0007 04a7
>  0x030: 0004 0399 001a 03bd 0004 b800 2f3a 0519
>  0x040: 0512 31b8 0035 c000 314c 1905 572a 2bb8
>  0x050: 003b 0157 2ab6 0041 c000 4312 44b9 004a
>  0x060: 0200 9900 232a b600 41c0 0043 1244 b900
>  0x070: 4e02 003a 0619 06b8 0054 c000 562a 5fb5
>  0x080: 001f 1906 572a b600 41c0 0043 1257 b900
>  0x090: 4a02 0099 0020 2ab6 0041 c000 4312 57b9
>  0x0a0: 004e 0200 3a07 1907 b800 5d2a 5fb5 005f
>  0x0b0: 1907 572a b600 41c0 0043 1260 b900 4a02
>  0x0c0: 0099 0023 2ab6 0041 c000 4312 60b9 004e
>  0x0d0: 0200 3a08 1908 b800 54c0 0056 2a5f b500
>  0x0e0: 6219 0857 2ab6 0041 c000 4312 63b9 004a
>  0x0f0: 0200 9900 232a b600 41c0 0043 1263 b900
>  0x100: 4e02 003a 0919 09b8 0054 c000 562a 5fb5
>  0x110: 0023 1909 572a b600 41c0 0043 1264 b900
>  0x120: 4a02 0099 001d 2ab6 0041 c000 4312 64b9
>  0x130: 004e 0200 3a0a 190a 2a5f b500 6619 0a57
>  0x140: 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)
> */
>


@MapConstructor + @CompileStatic on Static Inner Class => CTE

2018-09-03 Thread MG
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.(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:
    0x000: 2ab7 001b 121d 4d2c 2a5f b500 1f2c 5712
    0x010: 214e 2d2a 5fb5 0023 2d57 2ab6 0027 3a04
    0x020: 1904 2a5f b500 2919 0457 2bc7 0007 04a7
    0x030: 0004 0399 001a 03bd 0004 b800 2f3a 0519
    0x040: 0512 31b8 0035 c000 314c 1905 572a 2bb8
    0x050: 003b 0157 2ab6 0041 c000 4312 44b9 004a
    0x060: 0200 9900 232a b600 41c0 0043 1244 b900
    0x070: 4e02 003a 0619 06b8 0054 c000 562a 5fb5
    0x080: 001f 1906 572a b600 41c0 0043 1257 b900
    0x090: 4a02 0099 0020 2ab6 0041 c000 4312 57b9
    0x0a0: 004e 0200 3a07 1907 b800 5d2a 5fb5 005f
    0x0b0: 1907 572a b600 41c0 0043 1260 b900 4a02
    0x0c0: 0099 0023 2ab6 0041 c000 4312 60b9 004e
    0x0d0: 0200 3a08 1908 b800 54c0 0056 2a5f b500
    0x0e0: 6219 0857 2ab6 0041 c000 4312 63b9 004a
    0x0f0: 0200 9900 232a b600 41c0 0043 1263 b900
    0x100: 4e02 003a 0919 09b8 0054 c000 562a 5fb5
    0x110: 0023 1909 572a b600 41c0 0043 1264 b900
    0x120: 4a02 0099 001d 2ab6 0041 c000 4312 64b9
    0x130: 004e 0200 3a0a 190a 2a5f b500 6619 0a57
    0x140: 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)

*/