Skip to content

Scala 2 overrides a return type to an inferred type; Scala 3 does not #181

Closed
@SethTisue

Description

@SethTisue
scala 2.13.5> class C; class D extends C
scala 2.13.5> class Test { def foo: C = new C }
scala 2.13.5> class Test2 extends Test { override def foo = new D }
scala 2.13.5> (new Test2).foo
val res0: D = D@5d32c1c7

whereas in Scala 3 the type of res0 is C

I'm fairly sure this is intended behavior in Scala 3, but I can't seem to find either a ticket, or a migration guide entry about it.

There is a ticket complaining about the Scala 2 behavior: scala/bug#7212

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