Skip to content

Commit

Permalink
Backport "Add regression test for #19909" to LTS (#20981)
Browse files Browse the repository at this point in the history
Backports #19915 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jul 3, 2024
2 parents 371b551 + ffd8f5a commit ba0ce7a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/pos-macros/i19909/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package examples.select

import scala.language.dynamics
import scala.quoted.*

case class Wrapper[A](inner: A) extends Dynamic:
transparent inline def selectDynamic(inline name: String) =
${selectDynamicImpl('inner, 'name)}

def selectDynamicImpl[A:Type](inner: Expr[A], name: Expr[String])(using quotes: Quotes): Expr[Any] =
import quotes.reflect.*
Select.unique(inner.asTerm, name.valueOrAbort).asExpr
15 changes: 15 additions & 0 deletions tests/pos-macros/i19909/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package examples.select


import scala.language.dynamics
import examples.select.Wrapper

object Dynamic0:

@main
def runTimeError =

val w = Wrapper(Option(1))
println(w.isEmpty)

end Dynamic0
12 changes: 12 additions & 0 deletions tests/pos-macros/i19909b/Macro.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package examples.select

import scala.language.dynamics
import scala.quoted.*

case class Wrapper[A](inner: A) extends Dynamic:
transparent inline def selectDynamic(inline name: String) =
${selectDynamicImpl('inner, 'name)}

def selectDynamicImpl[A:Type](inner: Expr[A], name: Expr[String])(using quotes: Quotes): Expr[Any] =
import quotes.reflect.*
Select.unique(inner.asTerm, name.valueOrAbort).asExpr
15 changes: 15 additions & 0 deletions tests/pos-macros/i19909b/Test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package examples.select


import scala.language.dynamics
import examples.select.Wrapper

object Dynamic0:

@main
def runTimeError =

val w = Wrapper(Option(1))
println(w.isEmpty)

end Dynamic0

0 comments on commit ba0ce7a

Please sign in to comment.