Closed
Description
When an opaque type is an alias of a singleton type (literal or term), then in the companion object, the conversion from the singleton type to the alias type does not work. The conversion in the other direction works.
Test code 1:
object A{
opaque type T = 3
object T {
val x: T = 3
}
}
Output
-- [E007] Type Mismatch Error: opaque-singleton.scala:4:15 ---------
4 | val x: T = 3
| ^
| Found: Int(3)
| Required: A.T.T'
|
| where: T is a object in object A
| T' is a type in object T
one error found
Test code 2:
object O{
val x = 3
opaque type T = x.type
object T {
def wrap(a: x.type): T = a // Error
def unwrap(a: T): x.type = a // OK
}
}
Metadata
Metadata
Assignees
Labels
No labels