Skip to content

Subtyping considers that a { def foo: T } refinement is valid for { val foo: T } #18047

Closed
@sjrd

Description

@sjrd

Compiler version

3.3.0

Scala 2.13.11 does the right thing.

Minimized code

def foo(x: Any { def foo: Int }): Any { val foo: Int } = x

Output

Compiles

Expectation

Should not compile. Scala 2.13.11 reports:

scala> def foo(x: Any { def foo: Int }): Any { val foo: Int } = x
                                                                ^
       error: type mismatch;
        found   : Any{def foo: Int}
        required: Any{val foo: Int}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions