Skip to content

Scala 2 regression: type inference widens type too much for an overridden member #16868

@myazinn

Description

@myazinn

Compiler version

3.0.0, 3.2.2 and 3.3.0-RC2

Minimized code

https://scastie.scala-lang.org/VOJKBf5MSC6SRJAin3TrSA

trait Resource class MyResource() extends Resource { def something: String = "something" } trait Suite { def resource: Resource } class MySuite extends Suite { // def resource: MyResource = MyResource() // works def resource = new MyResource() resource.something }

Output

value something is not a member of Playground.Resource 

Expectation

Expected to compile, as in Scala 2.
Expected type inference to use MyResource type for resource method and not inherited Resource.

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