Skip to content

Commit

Permalink
Add failing test case for contextual parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
zeptometer committed Jun 4, 2023
1 parent 0cffa8f commit c38b378
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/run-macros/i17105/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ def testExprImpl(body: Expr[Any])(using Quotes): Expr[String] =
'{ $a((z: String) => s"[1st case] ${z}") }
case '{ def g(y: String)(z: String) = "placeholder" + y; $a(g): String } =>
'{ $a((z1: String) => (z2: String) => s"[2nd case] ${z1}, ${z2}") }
case '{ given i: String = "given"; def g(using s: String) = "placeholder"; $a(g, i): String } =>
'{ $a((s: String) => s"[3rd case] ${s}")(0) }
/* TODO issue-17105: This causes type error due to another issue from issue-17105 */
// case '{ def g(using s: String) = "placeholder"; $a(g) } =>
// '{ $a((s: String) => s"[3rd case] ${s}") }
case _ => Expr("not matched")

// TODO issue-17105: Clean this up if not neccessary
Expand Down
1 change: 1 addition & 0 deletions tests/run-macros/i17105/Test_2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
println("case curried: " + testExpr { def f(x: String)(y: String) = "placeholder" + x; f("arg1")("arg2") + " outside" })
def outer() = " outer-method"
println("case methods from outer scope: " + testExpr { def f(x: String) = "placeholder" + x; f("arg1") + outer() })
println("case contextual params: " + testExpr { given String = "given"; def f(using t: String) = "placeholder"; f + " outside" })

0 comments on commit c38b378

Please sign in to comment.