@@ -5,8 +5,6 @@ import scala.annotation.tailrec
5
5
import scala .collection .mutable .ListBuffer
6
6
import scala .util .matching .Regex .Match
7
7
8
- import PartialFunction .cond
9
-
10
8
import dotty .tools .dotc .ast .tpd .{Match => _ , * }
11
9
import dotty .tools .dotc .core .Contexts .*
12
10
import dotty .tools .dotc .core .Symbols .*
@@ -129,10 +127,8 @@ class TypedFormatChecker(partsElems: List[Tree], parts: List[String], args: List
129
127
def intOf (g : SpecGroup ): Option [Int ] = group(g).map(_.toInt)
130
128
131
129
extension (inline value : Boolean )
132
- inline def or (inline body : => Unit ): Boolean = value || { body ; false }
133
- inline def orElse (inline body : => Unit ): Boolean = value || { body ; true }
134
- inline def and (inline body : => Unit ): Boolean = value && { body ; true }
135
- inline def but (inline body : => Unit ): Boolean = value && { body ; false }
130
+ inline infix def or (inline body : => Unit ): Boolean = value || { body; false }
131
+ inline infix def and (inline body : => Unit ): Boolean = value && { body; true }
136
132
137
133
enum Kind :
138
134
case StringXn , HashXn , BooleanXn , CharacterXn , IntegralXn , FloatingPointXn , DateTimeXn , LiteralXn , ErrorXn
@@ -214,11 +210,18 @@ class TypedFormatChecker(partsElems: List[Tree], parts: List[String], args: List
214
210
// is the specifier OK with the given arg
215
211
def accepts (arg : Type ): Boolean =
216
212
kind match
217
- case BooleanXn => arg == defn.BooleanType orElse warningAt(CC )(" Boolean format is null test for non-Boolean" )
218
- case IntegralXn => arg == BigIntType || ! cond(cc) {
219
- case 'o' | 'x' | 'X' if hasAnyFlag(" + (" ) => " + (" .filter(hasFlag).foreach(bad => badFlag(bad, s " only use ' $bad' for BigInt conversions to o, x, X " )); true
220
- }
213
+ case BooleanXn if arg != defn.BooleanType =>
214
+ warningAt(CC ):
215
+ """ non-Boolean value formats as "true" for non-null references and boxed primitives, otherwise "false""""
216
+ true
217
+ case IntegralXn if arg != BigIntType =>
218
+ cc match
219
+ case 'o' | 'x' | 'X' if hasAnyFlag(" + (" ) =>
220
+ " + (" .filter(hasFlag).foreach: bad =>
221
+ badFlag(bad, s " only use ' $bad' for BigInt conversions to o, x, X " )
222
+ false
221
223
case _ => true
224
+ case _ => true
222
225
223
226
def lintToString (arg : Type ): Unit =
224
227
if ctx.settings.Whas .toStringInterpolated && kind == StringXn && ! (arg.widen =:= defn.StringType ) && ! arg.isPrimitiveValueType
0 commit comments