[ 
https://issues.apache.org/jira/browse/GROOVY-8803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17043520#comment-17043520
 ] 

Paul King commented on GROOVY-8803:
-----------------------------------

Currently resolution occurs before the @Builder transform runs. This isn't 
normally a problem since either you are using the normal modes of usage where 
the builder class name is effectively a hidden detail or you are compiling your 
builder separately from usage as part of a build system. Perhaps it could be 
extended to cover additional modes of operation. To get everything within one 
script (I tried with 2.5.9 and 3.0.1), you could try something like:

{code}
import groovy.transform.builder.Builder

@Builder
class Foo {
    String bar
}

new GroovyShell(getClass().classLoader).evaluate '''
Foo.FooBuilder aBuilder = Foo.builder()
assert aBuilder.class.name == 'Foo$FooBuilder'
assert aBuilder.methods*.name.contains('setBar')

class FooBuilderExtension extends Foo.FooBuilder {}
def foo = new FooBuilderExtension().builder().bar('baz')
assert foo.bar == 'baz'

class Bar {
  @Delegate Foo.FooBuilder builder
}
assert Bar.methods*.name.contains('build')
'''
{code}

> Can't refer class declared with @Builder annotation
> ---------------------------------------------------
>
>                 Key: GROOVY-8803
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8803
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.2
>            Reporter: Tomasz Przybysz
>            Priority: Minor
>
> The following fails to compile:
> {code:java}
> import groovy.transform.builder.Builder
> @Builder
> class Foo {
>     String bar
> }
> Foo.FooBuilder aBuilder = Foo.builder()
> {code}
> The compile error is:
> {quote}Error:(8, 16) Groovyc: unable to resolve class Foo.FooBuilder
> {quote}
> I'm not sure if it's a bug. Although seems it should be possible to refer a 
> `@Builder` generated class as any other.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to