Skip to content
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
20 changes: 20 additions & 0 deletions tests/disabled/pos-macros/forwardCompat-3.1/Macro_1_r3.1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import scala.quoted.*

object Macros:

inline def power(x: Double, inline n: Int) = ${ powerCode('x, 'n) }

private def powerCode(x: Expr[Double], n: Expr[Int])(using Quotes): Expr[Double] =
unrolledPowerCode(x, n.valueOrError)

private def unrolledPowerCode(x: Expr[Double], n: Int)(using Quotes): Expr[Double] =
if n == 0 then '{ 1.0 } // tests simple quotes without splices
else if n % 2 == 1 then '{ $x * ${ unrolledPowerCode(x, n - 1) } } // tests simple splices
else '{ val y = $x * $x; ${ unrolledPowerCode('y, n / 2) } } // tests splice with term capture


inline def let[T, U](x: T)(inline body: T => U): U = ${ letCode('x, 'body) }

private def letCode[T: Type, U: Type](x: Expr[T], body: Expr[T => U])(using Quotes): Expr[U] =
// tests use of Type
'{ val y: T = $x; $body(y): U }
15 changes: 15 additions & 0 deletions tests/disabled/pos-macros/forwardCompat-3.1/Test_2_c3.1.0.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Macros.*

def powerTest(x: Double): Unit =
power(x, 0)
power(x, 1)
power(x, 5)
power(x, 10)

def letTest: Unit =
let(0) { _ + 1 }
let(0) { _.toString }
let((4, 'a')) { _.swap }
let(new Foo) { _.hashCode }

class Foo
1 change: 1 addition & 0 deletions tests/disabled/pos-macros/forwardCompat-3.1/why.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disabled until https://github.com/lampepfl/dotty/issues/14306 is fixed
20 changes: 20 additions & 0 deletions tests/pos-macros/backwardCompat-3.0/Macro_1_c3.0.0.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import scala.quoted.*

object Macros:

inline def power(x: Double, inline n: Int) = ${ powerCode('x, 'n) }

private def powerCode(x: Expr[Double], n: Expr[Int])(using Quotes): Expr[Double] =
unrolledPowerCode(x, n.valueOrError)

private def unrolledPowerCode(x: Expr[Double], n: Int)(using Quotes): Expr[Double] =
if n == 0 then '{ 1.0 } // tests simple quotes without splices
else if n % 2 == 1 then '{ $x * ${ unrolledPowerCode(x, n - 1) } } // tests simple splices
else '{ val y = $x * $x; ${ unrolledPowerCode('y, n / 2) } } // tests splice with term capture


inline def let[T, U](x: T)(inline body: T => U): U = ${ letCode('x, 'body) }

private def letCode[T: Type, U: Type](x: Expr[T], body: Expr[T => U])(using Quotes): Expr[U] =
// tests use of Type
'{ val y: T = $x; $body(y): U }
15 changes: 15 additions & 0 deletions tests/pos-macros/backwardCompat-3.0/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Macros.*

def powerTest(x: Double): Unit =
power(x, 0)
power(x, 1)
power(x, 5)
power(x, 10)

def letTest: Unit =
let(0) { _ + 1 }
let(0) { _.toString }
let((4, 'a')) { _.swap }
let(new Foo) { _.hashCode }

class Foo
20 changes: 20 additions & 0 deletions tests/pos-macros/backwardCompat-3.1/Macro_1_c3.1.0.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import scala.quoted.*

object Macros:

inline def power(x: Double, inline n: Int) = ${ powerCode('x, 'n) }

private def powerCode(x: Expr[Double], n: Expr[Int])(using Quotes): Expr[Double] =
unrolledPowerCode(x, n.valueOrError)

private def unrolledPowerCode(x: Expr[Double], n: Int)(using Quotes): Expr[Double] =
if n == 0 then '{ 1.0 } // tests simple quotes without splices
else if n % 2 == 1 then '{ $x * ${ unrolledPowerCode(x, n - 1) } } // tests simple splices
else '{ val y = $x * $x; ${ unrolledPowerCode('y, n / 2) } } // tests splice with term capture


inline def let[T, U](x: T)(inline body: T => U): U = ${ letCode('x, 'body) }

private def letCode[T: Type, U: Type](x: Expr[T], body: Expr[T => U])(using Quotes): Expr[U] =
// tests use of Type
'{ val y: T = $x; $body(y): U }
15 changes: 15 additions & 0 deletions tests/pos-macros/backwardCompat-3.1/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Macros.*

def powerTest(x: Double): Unit =
power(x, 0)
power(x, 1)
power(x, 5)
power(x, 10)

def letTest: Unit =
let(0) { _ + 1 }
let(0) { _.toString }
let((4, 'a')) { _.swap }
let(new Foo) { _.hashCode }

class Foo
20 changes: 20 additions & 0 deletions tests/pos-macros/baseCompat/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import scala.quoted.*

object Macros:

inline def power(x: Double, inline n: Int) = ${ powerCode('x, 'n) }

private def powerCode(x: Expr[Double], n: Expr[Int])(using Quotes): Expr[Double] =
unrolledPowerCode(x, n.valueOrError)

private def unrolledPowerCode(x: Expr[Double], n: Int)(using Quotes): Expr[Double] =
if n == 0 then '{ 1.0 } // tests simple quotes without splices
else if n % 2 == 1 then '{ $x * ${ unrolledPowerCode(x, n - 1) } } // tests simple splices
else '{ val y = $x * $x; ${ unrolledPowerCode('y, n / 2) } } // tests splice with term capture


inline def let[T, U](x: T)(inline body: T => U): U = ${ letCode('x, 'body) }

private def letCode[T: Type, U: Type](x: Expr[T], body: Expr[T => U])(using Quotes): Expr[U] =
// tests use of Type
'{ val y: T = $x; $body(y): U }
15 changes: 15 additions & 0 deletions tests/pos-macros/baseCompat/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Macros.*

def powerTest(x: Double): Unit =
power(x, 0)
power(x, 1)
power(x, 5)
power(x, 10)

def letTest: Unit =
let(0) { _ + 1 }
let(0) { _.toString }
let((4, 'a')) { _.swap }
let(new Foo) { _.hashCode }

class Foo
20 changes: 20 additions & 0 deletions tests/pos-macros/forwardCompat-3.0/Macro_1_r3.0.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import scala.quoted.*

object Macros:

inline def power(x: Double, inline n: Int) = ${ powerCode('x, 'n) }

private def powerCode(x: Expr[Double], n: Expr[Int])(using Quotes): Expr[Double] =
unrolledPowerCode(x, n.valueOrError)

private def unrolledPowerCode(x: Expr[Double], n: Int)(using Quotes): Expr[Double] =
if n == 0 then '{ 1.0 } // tests simple quotes without splices
else if n % 2 == 1 then '{ $x * ${ unrolledPowerCode(x, n - 1) } } // tests simple splices
else '{ val y = $x * $x; ${ unrolledPowerCode('y, n / 2) } } // tests splice with term capture


inline def let[T, U](x: T)(inline body: T => U): U = ${ letCode('x, 'body) }

private def letCode[T: Type, U: Type](x: Expr[T], body: Expr[T => U])(using Quotes): Expr[U] =
// tests use of Type
'{ val y: T = $x; $body(y): U }
15 changes: 15 additions & 0 deletions tests/pos-macros/forwardCompat-3.0/Test_2_c3.0.0.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Macros.*

def powerTest(x: Double): Unit =
power(x, 0)
power(x, 1)
power(x, 5)
power(x, 10)

def letTest: Unit =
let(0) { _ + 1 }
let(0) { _.toString }
let((4, 'a')) { _.swap }
let(new Foo) { _.hashCode }

class Foo