Skip to content

A singleton type is not a subtype of its refined type #10980

Closed
@LPTK

Description

@LPTK

Minimized code

class A:
  val x: AnyRef

@main def m: Unit =
  val a = new A
  a.x: a.x.type // ok
  a: A { val x: a.x.type } // nope

https://scastie.scala-lang.org/0PCX1TY0TxCO1Voo5NohLQ

Output

Found:    (a : A)
Required: A{x: (a.x : AnyRef)}

Expectation

Should type check. This is crucially needed for more advanced dependent-typing use cases.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions