Skip to content

Export vararg method from Java does not adapt Seq to array #10884

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

Closed
bishabosha opened this issue Dec 22, 2020 · 0 comments · Fixed by #10948
Closed

Export vararg method from Java does not adapt Seq to array #10884

bishabosha opened this issue Dec 22, 2020 · 0 comments · Fixed by #10948
Assignees
Labels
area:desugar Desugaring happens after parsing but before typing, see desugar.scala compat:java itype:bug
Milestone

Comments

@bishabosha
Copy link
Member

bishabosha commented Dec 22, 2020

Minimized code

The following compiles ok, but fails at runtime

// JavaExporter.java
public class JavaExporter {
  public static String varargExample(String... args) {
    return "";
  }
}
object Exporter:
  export JavaExporter._

import Exporter._

@main def Test =
  println(varargExample("a", "b", "c"))

Output

~/Workspace/dotty/sandbox/ctx(fix-10724*) » scala -classpath out Test
Exception in thread "main" java.lang.ClassCastException: scala.collection.immutable.ArraySeq$ofRef cannot be cast to [Ljava.lang.String;
	at Foo$package$.test3(Foo.scala:16)
	at Foo$package$.Test(Foo.scala:21)
	at Test.main(Foo.scala:18)

Expectation

the vararg forwarder should adapt the varargs for java

@bishabosha bishabosha added itype:bug compat:java area:desugar Desugaring happens after parsing but before typing, see desugar.scala labels Dec 22, 2020
@bishabosha bishabosha self-assigned this Dec 23, 2020
@bishabosha bishabosha added this to the 3.0.0-RC1 milestone Dec 23, 2020
bishabosha added a commit to dotty-staging/dotty that referenced this issue Dec 29, 2020
bishabosha added a commit to dotty-staging/dotty that referenced this issue Dec 29, 2020
bishabosha added a commit that referenced this issue Dec 29, 2020
fix #10884: eliminate JavaMethodType from exported info
@Kordyjan Kordyjan modified the milestones: 3.0.0-RC1, 3.0.0 Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:desugar Desugaring happens after parsing but before typing, see desugar.scala compat:java itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants