Skip to content

Inconsistent handling of Union and Intersection types #18565

Open
@gzoller

Description

@gzoller

Compiler version

3.3.0

Minimized code

  def apply(quotes: Quotes)(aType: quotes.reflect.TypeRepr, typedName: TypedName, resolveTypeSyms: Boolean): RType[_] = 
    import quotes.reflect.*

    val typeRef = aType.asInstanceOf[TypeRef]
    typeRef.classSymbol match {
      case None => 
        typeRef match {
          case AndType(left,right) => ...
        }
      case Some(classSymbol) =>
        typeRef match {
          case OrType(left,right) => ...
        }

Expectation

Union types (OR) are marked with scala.Matchable trait, so they have a classSymbol. Not a very interesting one, but Intersection (AND) types do not have this. So its strange they are handled differently. Previously, both had no classSymbol, and now only one does. Not the end of all things, but this seems like an oversight when Matchable was added to OR. If you add Matchable to AND then it would be consistent again, and you'd be set up for success if ever you want to add behavior to Matchable.

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