Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3103,6 +3103,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
&& xtree.isTerm
&& !untpd.isContextualClosure(xtree)
&& !ctx.mode.is(Mode.Pattern)
&& !xtree.isInstanceOf[SplicePattern]
&& !ctx.isAfterTyper
&& !ctx.isInlineContext
then
Expand Down Expand Up @@ -3945,6 +3946,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
&& pt != SingletonTypeProto
&& pt != AssignProto
&& !ctx.mode.is(Mode.Pattern)
&& !tree.isInstanceOf[SplicePattern]
&& !ctx.isAfterTyper
&& !ctx.isInlineContext
then
Expand Down
7 changes: 7 additions & 0 deletions tests/pos-macros/i18197a.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import scala.quoted.*

def readPathMacro[A: Type, B: Type](expr: Expr[Any])(using Quotes) =
expr match
case '{ foo($y) } => y: Expr[Int ?=> Int]

def foo(x: Int ?=> Int): Any = ???
18 changes: 18 additions & 0 deletions tests/pos-macros/i18197b/Macro.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import scala.quoted.*

object ReproMacro {
inline def readPath[A, B](inline config: Config[A, B]) = ${ readPathMacro[A, B]('config) }

def readPathMacro[A: Type, B: Type](expr: Expr[Config[A, B]])(using Quotes) = {
import quotes.reflect.report

expr match {
case '{ Field.const[a, b, tpe]($selector) } =>
val selector2: Expr[Selector ?=> a => tpe] = selector
report.info(s"Matched!")
'{}
case other =>
report.errorAndAbort("woops, I did not match")
}
}
}
19 changes: 19 additions & 0 deletions tests/pos-macros/i18197b/Test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
trait Selector {
extension [A](self: A) def at[B <: A]: B
}

trait Config[A, B]

object Field {
def const[A, B, FieldTpe](selector: Selector ?=> A => FieldTpe): Config[A, B] = ???
}

final case class Example(int: Int)

@main def main = {
// compiles just fine
ReproMacro.readPath[Example, Example](Field.const(_.int))

// doesn't compile
ReproMacro.readPath[Example, Example](Field.const(_.int.at[Int]))
}