Skip to content

Commit d1daec3

Browse files
committed
Fix #7715: Fix Inlined.{isTerm,isType} and case with Inlined(Nil, ...)
1 parent debe978 commit d1daec3

File tree

6 files changed

+13
-3
lines changed

6 files changed

+13
-3
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,8 @@ object Trees {
621621
case class Inlined[-T >: Untyped] private[ast] (call: tpd.Tree, bindings: List[MemberDef[T]], expansion: Tree[T])(implicit @constructorOnly src: SourceFile)
622622
extends Tree[T] {
623623
type ThisTree[-T >: Untyped] = Inlined[T]
624+
override def isTerm = expansion.isTerm
625+
override def isType = expansion.isType
624626
}
625627

626628
/** A type tree that represents an existing or inferred type */

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
10701070
transform(rhs)
10711071
case _ => tree
10721072
}
1073-
case Inlined(_, _, arg) => transform(arg)
1073+
case Inlined(_, Nil, arg) => transform(arg)
10741074
case Block(Nil, arg) => transform(arg)
10751075
case NamedArg(_, arg) => transform(arg)
10761076
case tree => super.transform(tree)

compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
250250
def runtimeClass: Class[?] = classOf[Term]
251251
override def unapply(x: Any): Option[Term] = x match
252252
case _ if isInstanceOfUnapply.unapply(x).isDefined => None
253-
case _: PatternTree => None
253+
case _: tpd.PatternTree => None
254254
case x: tpd.SeqLiteral => Some(x)
255-
case x: Tree if x.isTerm => Some(x)
255+
case x: tpd.Tree if x.isTerm => Some(x)
256256
case _ => None
257257
}
258258

tests/run-macros/i7715.check

Whitespace-only changes.

tests/run-macros/i7715/Macros_1.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import scala.quoted.{ given, _ }
2+
3+
inline def mcr(e: => Any): Any = ${mcrImpl('e)}
4+
def mcrImpl(e: Expr[Any])(given ctx: QuoteContext): Expr[Any] =
5+
e match
6+
case '{ $body } => body

tests/run-macros/i7715/Test_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
given Int = 5
2+
@main def Test = assert(5 == mcr(summon[Int]))

0 commit comments

Comments
 (0)