Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent handling of Union and Intersection types #18565

Open
gzoller opened this issue Sep 18, 2023 · 1 comment
Open

Inconsistent handling of Union and Intersection types #18565

gzoller opened this issue Sep 18, 2023 · 1 comment
Labels
area:metaprogramming:reflection Issues related to the quotes reflection API itype:bug

Comments

@gzoller
Copy link
Contributor

gzoller commented Sep 18, 2023

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.

@gzoller gzoller added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 18, 2023
@mbovel mbovel added area:metaprogramming:reflection Issues related to the quotes reflection API and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 18, 2023
@nicolasstucki
Copy link
Contributor

@gzoller could you provide an example of types that are problematic and a self-contained macro implementation that shows this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metaprogramming:reflection Issues related to the quotes reflection API itype:bug
Projects
None yet
Development

No branches or pull requests

3 participants