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

Open
jrhee17 opened this issue Oct 17, 2024 · 0 comments
Open

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

jrhee17 opened this issue Oct 17, 2024 · 0 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
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

1 participant