Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using fluent builder patterns can cause issues for Scala 3 users #5947

Closed
jrhee17 opened this issue Oct 17, 2024 · 2 comments
Closed

Using fluent builder patterns can cause issues for Scala 3 users #5947

jrhee17 opened this issue Oct 17, 2024 · 2 comments
Labels

Comments

@jrhee17
Copy link
Contributor

jrhee17 commented Oct 17, 2024

Running the following currently fails for scala 3 since 1.29.0 (PR)

(The following can be run from {root_dir}/scala/scala_3)

@main
def main(): Unit = {
  DnsAddressEndpointGroup.builder("")
    .selectionTimeout(Duration.ofDays(1))
    .selectionTimeout(Duration.ofDays(1))
    .selectionTimeout(Duration.ofDays(1))
    .build()

  val server = Server.builder()
    .contextPath("/v1")
    .service("/", (ctx, req) => HttpResponse.of("Hello, world"))
    .and()
    .build()
    .start()

  println(s"server started = ${server}")
}
Exception in thread "main" java.lang.IllegalAccessError: failed to access class com.linecorp.armeria.client.endpoint.dns.DnsEndpointGroupBuilder from class TestSuite$package$
	at TestSuite$package$.main(TestSuite.scala:14)
	at main.main(TestSuite.scala:8)

It seems like when returning the SELF type, Scala3 tries to find the returned class AND superclasses for some reason.

It might be a better idea to steer clear of this pattern until Scala3 side applies a fix, or we decide to make builder superclasses public.

Link for reference: scala/scala3#21797

@jrhee17 jrhee17 added the defect label Oct 17, 2024
@chungonn
Copy link

Hi, I have just confirmed that the issue is resolved since Scala version3.6.2. I have just tested on Scala version 3.6.3 and confirmed it is compiling without any exception thrown.

You may wish to close this issue.

Thanks again for keeping tap on this issue.

@ikhoon
Copy link
Contributor

ikhoon commented Feb 18, 2025

Thank you for letting us know. 🙇‍♂️

@ikhoon ikhoon closed this as completed Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants