Skip to content

Contravariant given summoning does not keep hardened union types #16819

Open
@soronpo

Description

@soronpo

Compiler version

v3.3.0-RC2

Minimized code

import annotation.unchecked.uncheckedVariance
class Foo
class U1 extends Foo
class U2 extends Foo
class Box[T](x: T)
type U = U1 | U2
final val u : U1 | U2 = ???
trait TC[-T]:
  type Out = Box[T @uncheckedVariance]
  val value: Out @uncheckedVariance= ???
object TC:
  given [T]: TC[T] = new TC[T]{}

val b1 = summon[TC[U]]
val b1Test: Box[U] = b1.value //error

Output

Found: (b1.value : b1.Out @uncheckedVariance) 
Required: Box[U]

Expectation

No error.

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