@@ -5,8 +5,6 @@ import scala.annotation.tailrec
55import scala .collection .mutable .ListBuffer
66import scala .util .matching .Regex .Match
77
8- import PartialFunction .cond
9-
108import dotty .tools .dotc .ast .tpd .{Match => _ , * }
119import dotty .tools .dotc .core .Contexts .*
1210import dotty .tools .dotc .core .Symbols .*
@@ -129,10 +127,8 @@ class TypedFormatChecker(partsElems: List[Tree], parts: List[String], args: List
129127 def intOf (g : SpecGroup ): Option [Int ] = group(g).map(_.toInt)
130128
131129 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 }
136132
137133 enum Kind :
138134 case StringXn , HashXn , BooleanXn , CharacterXn , IntegralXn , FloatingPointXn , DateTimeXn , LiteralXn , ErrorXn
@@ -214,11 +210,18 @@ class TypedFormatChecker(partsElems: List[Tree], parts: List[String], args: List
214210 // is the specifier OK with the given arg
215211 def accepts (arg : Type ): Boolean =
216212 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
221223 case _ => true
224+ case _ => true
222225
223226 def lintToString (arg : Type ): Unit =
224227 if ctx.settings.Whas .toStringInterpolated && kind == StringXn && ! (arg.widen =:= defn.StringType ) && ! arg.isPrimitiveValueType
0 commit comments