Skip to content

Seq.apply[A](elems: A*) and varargs has poor java compatibility #10331

@mosesn

Description

@mosesn

problem

Scala varargs compile down to a method that takes a Seq as an argument, but since Seq.apply itself takes varargs as an argument, we have a circularity problem.

I think adding the scala.annotation.varargs annotation will make this much less painful in future versions of scala.

what I tried to do

Note this is in java

Seq$.MODULE$.apply("sup");

This fails with:

[error] REDACTED:1: method apply in class scala.collection.generic.GenericCompanion<CC> cannot be applied to given types;
[error]   required: scala.collection.Seq<A>
[error]   found: java.lang.String
[error]   reason: cannot infer type-variable(s) A
[error]     (argument mismatch; java.lang.String cannot be converted to scala.collection.Seq<A>)

how this makes me feel

😭

version information etc

This is in java 8 with scala 2.11, but I believe it fails with scala 2.12 too.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions