Skip to content

Commit

Permalink
Add regression test for #19909
Browse files Browse the repository at this point in the history
Closes #19909

Probably fixed by #19645

[Cherry-picked 2a97cb4]
  • Loading branch information
nicolasstucki authored and WojciechMazur committed Jul 2, 2024
1 parent 64996f4 commit ffd8f5a
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 ffd8f5a

Please sign in to comment.