Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regression test for #19909 #19915

Merged
merged 1 commit into from
Mar 11, 2024
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
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
Loading