Skip to content

Scala 3: support variance reading for opaque types #548

@neko-kai

Description

@neko-kai

Right now izumi-reflect correctly detects variance on Scala 3 for trait/class types:

trait X[+T]
0 -> X[+0]

But not for opaque types, where type variables are assumed invariant:

object x {
  opaque type X[+T] = Any
}
0 -> x::X[0]

That's because we rely on Symbol#declaredTypes method to find out the variances of type parameters of a type. But an opaque type does not "declare" its parameters as members of its definition and therefore declaredTypes List is empty.

We need to find and test some other way to extract that data – perhaps using private compiler APIs if there's no way to extract that data using public API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions