File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
scalactic.dotty/src/main/scala/org/scalactic Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,25 @@ import scala.quoted._
19
19
import scala .tasty ._
20
20
21
21
object BooleanMacro {
22
+ private val logicOperators = Set (" &&" , " ||" , " &" , " |" )
23
+
24
+ private val supportedBinaryOperations =
25
+ Set (
26
+ " ==" ,
27
+ " !=" ,
28
+ " ===" ,
29
+ " !==" ,
30
+ " <" ,
31
+ " >" ,
32
+ " >=" ,
33
+ " <=" ,
34
+ " startsWith" ,
35
+ " endsWith" ,
36
+ " contains" ,
37
+ " eq" ,
38
+ " ne" ,
39
+ " exists" ) ++ logicOperators
40
+
22
41
def parse (condition : Expr [Boolean ], prettifier : Expr [Prettifier ])(implicit refl : Reflection ): Expr [Bool ] = {
23
42
import refl ._
24
43
import util ._
@@ -78,7 +97,7 @@ object BooleanMacro {
78
97
case Apply (sel @ Select (lhs, op), rhs :: Nil ) =>
79
98
def binaryDefault =
80
99
if (isByNameMethodType(sel.tpe)) defaultCase
81
- else
100
+ else if (supportedBinaryOperations.contains(op))
82
101
let(lhs) { left =>
83
102
let(rhs) { right =>
84
103
val app = left.select(sel.symbol).appliedTo(right)
@@ -91,6 +110,7 @@ object BooleanMacro {
91
110
}
92
111
}
93
112
}.seal.cast[Bool ]
113
+ else defaultCase
94
114
95
115
op match {
96
116
case " ||" =>
You can’t perform that action at this time.
0 commit comments