[ 
https://issues.apache.org/jira/browse/GROOVY-11122?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles updated GROOVY-11122:
---------------------------------
    Description: 
Consider the following:
{code:groovy}
@groovy.transform.CompileStatic
class Foo {
  class Bar {
    def baz
  }

  void test() {
    { ->
      new Bar(baz: null)
    }.call()
  }
}

new Foo().test()
{code}

The constructor call "new Bar(...)" produces an error at runtime:
{code}
VerifyError: Bad type on operand stack
Exception Details:
  Location:
    Foo$_test_closure1.doCall()LFoo$Bar; @5: invokespecial
  Reason:
    Type 'Foo$_test_closure1' (current frame, stack[2]) is not assignable to 
'Foo'
  Current Frame:
    bci: @5
    flags: { }
    locals: { 'Foo$_test_closure1' }
    stack: { uninitialized 0, uninitialized 0, 'Foo$_test_closure1' }
{code}

Remove the named argument or {{@CompileStatic}} and it runs fine.

  was:
Consider the following:
{code:groovy}
@groovy.transform.CompileStatic
class Foo {
  class Bar {
    def baz
  }

  void test() {
    { ->
      new Bar(baz: null)
    }.call()
  }
}

new Foo().test()
{code}

The constructor call "new Bar(...)" produces an error at runtime:
{code}
VerifyError: Bad type on operand stack
Exception Details:
  Location:
    Foo$_test_closure1.doCall()LFoo$Bar; @5: invokespecial
  Reason:
    Type 'Foo$_test_closure1' (current frame, stack[2]) is not assignable to 
'Foo'
  Current Frame:
    bci: @5
    flags: { }
    locals: { 'Foo$_test_closure1' }
    stack: { uninitialized 0, uninitialized 0, 'Foo$_test_closure1' }
{code}


> SC: non-static inner class named-argument constructor within closure
> --------------------------------------------------------------------
>
>                 Key: GROOVY-11122
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11122
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>              Labels: VerifyError
>
> Consider the following:
> {code:groovy}
> @groovy.transform.CompileStatic
> class Foo {
>   class Bar {
>     def baz
>   }
>   void test() {
>     { ->
>       new Bar(baz: null)
>     }.call()
>   }
> }
> new Foo().test()
> {code}
> The constructor call "new Bar(...)" produces an error at runtime:
> {code}
> VerifyError: Bad type on operand stack
> Exception Details:
>   Location:
>     Foo$_test_closure1.doCall()LFoo$Bar; @5: invokespecial
>   Reason:
>     Type 'Foo$_test_closure1' (current frame, stack[2]) is not assignable to 
> 'Foo'
>   Current Frame:
>     bci: @5
>     flags: { }
>     locals: { 'Foo$_test_closure1' }
>     stack: { uninitialized 0, uninitialized 0, 'Foo$_test_closure1' }
> {code}
> Remove the named argument or {{@CompileStatic}} and it runs fine.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to