Skip to content

Type inference of "case class".copy being erased #11044

Open
@arontsang

Description

@arontsang
case class Foo[T, TCollection <: Iterable[T]](collection: TCollection, name: String)

def doStuff[T, TCollection <: Iterable[T]](foo: Foo[T, TCollection]){
  println(foo.name)
}

val foo = Foo[Int, Seq[Int]](Seq(1, 2), "foo")
doStuff(foo)
val bar = foo.copy(name = "bar")
doStuff(bar)

The code fails to compile on the last line, as T for bar has been erased to Nothing.

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