Skip to content

param accessors should drop @ Repeated from the type. #619

Closed
@retronym

Description

@retronym
cat sandbox/test.scala
class C(val f: Any*) {
  def g = f
}

class Test {
  def test1(c: C): Nothing = c.f
  def test2(c: C): Nothing = c.g
}
% scalac sandbox/test.scala
sandbox/test.scala:6: error: type mismatch;
 found   : c.f.type (with underlying type Any*)
 required: Nothing
  def test1(c: C): Nothing = c.f
                               ^
sandbox/test.scala:7: error: type mismatch;
 found   : Seq[Any]
 required: Nothing
  def test2(c: C): Nothing = c.g
                               ^
two errors found

% ./bin/dotc sandbox/test.scala
sandbox/test.scala:6: error: type mismatch:
 found   : scala.collection.Seq[Any] @Repeated(c.f)
 required: Nothing
  def test1(c: C): Nothing = c.f
                               ^
sandbox/test.scala:7: error: type mismatch:
 found   : scala.collection.Seq[Any] @Repeated
 required: Nothing
  def test2(c: C): Nothing = c.g
                               ^
two errors found

I believe that both dotc and scalac are wrong here to give the param accessor the type Any*/ Any @Repeated. Instead, the repeated-ness of the type should be dropped, in the same way that it is when computing the type of the explicity defined accessor g.

Followup from #617, /cc @smarter

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions