Skip to content

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

Closed
@prolativ

Description

@prolativ

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions