File tree Expand file tree Collapse file tree 5 files changed +39
-0
lines changed Expand file tree Collapse file tree 5 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ import scala .quoted .*
2+
3+ object Macro :
4+ def positiveImpl (using Quotes ): Expr [Any ] =
5+ ' { 0.0 } match
6+ case ' { - 0.0 } => ' {1 }
7+ inline def positive : Any = $ {positiveImpl}
8+
9+ def negativeImpl (using Quotes ): Expr [Any ] =
10+ ' { - 0.0 } match
11+ case ' { 0.0 } => ' {- 1 }
12+ inline def negative : Any = $ {negativeImpl}
Original file line number Diff line number Diff line change 1+ @ main def test (): Unit =
2+ println(Macro .positive) // error
3+ println(Macro .negative) // error
Original file line number Diff line number Diff line change 1+ 0
2+ 1
3+ -1
Original file line number Diff line number Diff line change 1+ import scala .quoted .*
2+
3+ object Macro :
4+ def nanImpl (using Quotes ): Expr [Any ] =
5+ ' { Double .NaN } match
6+ case ' { Double .NaN } => ' {0 }
7+ inline def nan : Any = $ {nanImpl}
8+
9+ def positiveImpl (using Quotes ): Expr [Any ] =
10+ ' { 0.0 } match
11+ case ' { 0.0 } => ' {1 }
12+ inline def positive : Any = $ {positiveImpl}
13+
14+ def negativeImpl (using Quotes ): Expr [Any ] =
15+ ' { - 0.0 } match
16+ case ' { - 0.0 } => ' {- 1 }
17+ inline def negative : Any = $ {negativeImpl}
Original file line number Diff line number Diff line change 1+ @ main def Test (): Unit =
2+ println(Macro .nan)
3+ println(Macro .positive)
4+ println(Macro .negative)
You can’t perform that action at this time.
0 commit comments