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

Given instance of Type not found for a path dependent type #17037

Closed
prolativ opened this issue Mar 3, 2023 · 1 comment · Fixed by #17049
Closed

Given instance of Type not found for a path dependent type #17037

prolativ opened this issue Mar 3, 2023 · 1 comment · Fixed by #17049
Assignees
Labels
area:metaprogramming:quotes Issues related to quotes and splices itype:bug
Milestone

Comments

@prolativ
Copy link
Contributor

prolativ commented Mar 3, 2023

Compiler version

3.3.1-RC1-bin-20230301-0df5ae2-NIGHTLY and before

Minimized code

import scala.quoted.*

class Foo:
  type Bar = Int

def macroImpl(using Quotes) =
  val foo = Foo()
  Type.of[foo.Bar] match
    case '[foo.Bar] => '{true}
    case _ => '{false}

Output

[error] ./Repro.scala:8:11
[error] Reference to foo.Bar within quotes requires a given scala.quoted.Type[foo.Bar] in scope.
[error] 
[error]   Type.of[foo.Bar] match
[error]           ^^^^^^^
[error] ./Repro.scala:9:12
[error] Reference to foo.Bar within quotes requires a given scala.quoted.Type[foo.Bar] in scope.
[error] 
[error]     case '[foo.Bar] => '{true}
[error]            ^^^^^^^

Expectation

It doesn't seem to be true that there's no no Type[foo.Bar] in scope as the following does compile

import scala.quoted.*

class Foo:
  type Bar = Int

def macroImpl(using Quotes) =
  val foo = new Foo
  val t = summon[Type[foo.Bar]] // this proves existence of `Type[foo.Bar]` in scope
  locally {
    given tt: Type[foo.Bar] = t
    Type.of[Int] match
      case '[foo.Bar] => '{true}
      case _ => '{false}
  }

So I would expect the first snippet to compile too

@nicolasstucki
Copy link
Contributor

The difference that we are experiencing seems to be due to summon[Type[foo.Bar]] dealiasing foo.Bar into Int but Type.of[foo.Bar] does not. They should behave the same and therefore I would expect Type.of to also dealias.

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 6, 2023
We where only doing the dealiasing if the type had no prefix but missed
it if the type reference was on some path.

Fixes scala#17037
nicolasstucki added a commit that referenced this issue Mar 10, 2023
We where only doing the dealiasing if the type had no prefix but missed
it if the type reference was on some path.

Fixes #17037
Dedelweiss pushed a commit to Dedelweiss/dotty that referenced this issue Apr 17, 2023
We where only doing the dealiasing if the type had no prefix but missed
it if the type reference was on some path.

Fixes scala#17037
@Kordyjan Kordyjan added this to the 3.3.1 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metaprogramming:quotes Issues related to quotes and splices itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants