Skip to content

Commit

Permalink
no transform when inline
Browse files Browse the repository at this point in the history
  • Loading branch information
iusildra committed Jul 20, 2023
1 parent 2be127b commit d02703a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class ExtractExpression(using exprCtx: ExpressionContext) extends MacroTransform
desugaredIdent match
case tree: ImportOrExport => tree

case tree if tree.symbol.is(Inline) => tree

// static object
case tree: (Ident | Select) if isStaticObject(tree.symbol) =>
getStaticObject(tree)(tree.symbol.moduleClass)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2146,6 +2146,37 @@ abstract class Scala2EvaluationTests(val scalaVersion: ScalaVersion) extends Sca
}

abstract class Scala3EvaluationTests(scalaVersion: ScalaVersion) extends ScalaEvaluationTests(scalaVersion) {
test("evaluate inline elements") {
val source =
"""|package example
|
|object Main {
| def main(args: Array[String]): Unit = {
| inline val y = 2
| println("ok")
| }
| inline def m(): Int = 42
| inline def n(inline x: Int): Int = x
| inline val x = 1
| inline def test(inline x: Int) = Test(x)
| inline def t = test(42).x
| case class Test(x: Int)
|}
|""".stripMargin
implicit val debuggee: TestingDebuggee = TestingDebuggee.mainClass(source, "example.Main", scalaVersion)
check(
Breakpoint(6),
Evaluation.success("m()", 42),
Evaluation.success("n(1)", 1),
Evaluation.success("x", 1),
Evaluation.success("test(42)", ObjectRef("Main$Test")),
Evaluation.success("t", 42),
Evaluation.success("n(x)", 1),
Evaluation.success("y", 2),
Evaluation.success("n(y)", 2),
Evaluation.success("n(m())", 42)
)
}
test("evaluate shadowed variable") {
val source =
"""|package example
Expand Down

0 comments on commit d02703a

Please sign in to comment.