Skip to content

Commit fa3269c

Browse files
committed
Drop e, ex and exm interpolators
That leaves just two interpolators: - i for strings - em for error messages (and other diagnostics)
1 parent f169753 commit fa3269c

File tree

10 files changed

+296
-326
lines changed

10 files changed

+296
-326
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
422422
emitAssocs(nestedVisitor, assocs, bcodeStore)(innerClasesStore)
423423

424424
case t =>
425-
report.error(ex"Annotation argument is not a constant", t.sourcePos)
425+
report.error(em"Annotation argument is not a constant", t.sourcePos)
426426
}
427427
}
428428

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2926,7 +2926,7 @@ class JSCodeGen()(using genCtx: Context) {
29262926
case defn.ArrayOf(el) => el
29272927
case JavaArrayType(el) => el
29282928
case tpe =>
2929-
val msg = ex"expected Array $tpe"
2929+
val msg = em"expected Array $tpe"
29302930
report.error(msg)
29312931
ErrorType(msg)
29322932
}

compiler/src/dotty/tools/dotc/core/Decorators.scala

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -296,46 +296,17 @@ object Decorators {
296296
def derivedCons(x1: T, xs1: List[T]) =
297297
if (xs.head eq x1) && (xs.tail eq xs1) then xs else x1 :: xs1
298298

299-
/* This extension defines the following string formatters:
300-
* i, e, ex, em, exm
301-
* String formatters ending in `m` produce a message, the others produce a string.
302-
* Details are as follows:
303-
*
304-
* i : Gneral purpose string interpolator that uses Formtting.show to print compiler data
305-
* e : Like `i`, but with logic that limits the size of messages and that
306-
* filters out nonsensical messages after the first error is reported.
307-
* `e` or its variants should be used for error messages and warnings instead of `i`.
308-
* ex : Like `e`, but it assembles additional info on type variables and for
309-
* disambiguating symbols.
310-
* em : Like `e`, but producing a message
311-
* exm: Like `ex`, but producing a message
312-
*/
313299
extension (sc: StringContext)
300+
314301
/** General purpose string formatting */
315302
def i(args: Shown*)(using Context): String =
316303
new StringFormatter(sc).assemble(args)
317304

318-
/** Formatting for error messages: Like `i`, with two modifications
319-
* - limit size of messages
320-
* - mark some parts of messages with <nonsensical> tags, so that
321-
* error messages after the first one are filtered out if some of
322-
* their arguments are "non-sensical".
305+
/** Interpolator yielding an error message, which undergoes
306+
* the formatting defined in Message.
323307
*/
324-
def e(args: Shown*)(using Context): String =
325-
new StringFormatter(sc).assemble(args)
326-
327-
/** A NoExplanation message formatted with `e` */
328308
def em(args: Shown*)(using Context): NoExplanation =
329-
NoExplanation(e(args*))
330-
331-
def exm(args: Shown*)(using Context): NoExplanation =
332-
NoExplanation(ex(args*))
333-
334-
/** Formatting with added explanations: Like `em`, but add explanations to
335-
* give more info about type variables and to disambiguate where needed.
336-
*/
337-
def ex(args: Shown*)(using Context): String =
338-
new StringFormatter(sc).assemble(args)
309+
NoExplanation(i(args*))
339310

340311
extension [T <: AnyRef](arr: Array[T])
341312
def binarySearch(x: T | Null): Int = java.util.Arrays.binarySearch(arr.asInstanceOf[Array[Object | Null]], x)

compiler/src/dotty/tools/dotc/inlines/PrepareInlineable.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ object PrepareInlineable {
284284

285285
private def checkInlineMethod(inlined: Symbol, body: Tree)(using Context): body.type = {
286286
if Inlines.inInlineMethod(using ctx.outer) then
287-
report.error(ex"Implementation restriction: nested inline methods are not supported", inlined.srcPos)
287+
report.error(em"Implementation restriction: nested inline methods are not supported", inlined.srcPos)
288288

289289
if (inlined.is(Macro) && !ctx.isAfterTyper) {
290290

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 273 additions & 274 deletions
Large diffs are not rendered by default.

compiler/src/dotty/tools/dotc/transform/Erasure.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ object Erasure {
781781
val tp = originalQual
782782
if tp =:= qual1.tpe.widen then
783783
return errorTree(qual1,
784-
ex"Unable to emit reference to ${sym.showLocated}, ${sym.owner} is not accessible in ${ctx.owner.enclosingClass}")
784+
em"Unable to emit reference to ${sym.showLocated}, ${sym.owner} is not accessible in ${ctx.owner.enclosingClass}")
785785
tp
786786
recur(cast(qual1, castTarget))
787787
}

compiler/src/dotty/tools/dotc/transform/TreeChecker.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class TreeChecker extends Phase with SymTransformer {
169169
everDefinedSyms.get(sym) match {
170170
case Some(t) =>
171171
if (t ne tree)
172-
report.warning(em"symbol ${sym.fullName} is defined at least twice in different parts of AST")
172+
report.warning(i"symbol ${sym.fullName} is defined at least twice in different parts of AST")
173173
// should become an error
174174
case None =>
175175
everDefinedSyms(sym) = tree
@@ -179,7 +179,7 @@ class TreeChecker extends Phase with SymTransformer {
179179
if (ctx.settings.YcheckMods.value)
180180
tree match {
181181
case t: untpd.MemberDef =>
182-
if (t.name ne sym.name) report.warning(em"symbol ${sym.fullName} name doesn't correspond to AST: ${t}")
182+
if (t.name ne sym.name) report.warning(s"symbol ${sym.fullName} name doesn't correspond to AST: ${t}")
183183
// todo: compare trees inside annotations
184184
case _ =>
185185
}
@@ -417,11 +417,11 @@ class TreeChecker extends Phase with SymTransformer {
417417
sym == mbr ||
418418
sym.overriddenSymbol(mbr.owner.asClass) == mbr ||
419419
mbr.overriddenSymbol(sym.owner.asClass) == sym),
420-
ex"""symbols differ for $tree
421-
|was : $sym
422-
|alternatives by type: $memberSyms%, % of types ${memberSyms.map(_.info)}%, %
423-
|qualifier type : ${qualTpe}
424-
|tree type : ${tree.typeOpt} of class ${tree.typeOpt.getClass}""")
420+
i"""symbols differ for $tree
421+
|was : $sym
422+
|alternatives by type: $memberSyms%, % of types ${memberSyms.map(_.info)}%, %
423+
|qualifier type : ${qualTpe}
424+
|tree type : ${tree.typeOpt} of class ${tree.typeOpt.getClass}""")
425425
}
426426

427427
checkNotRepeated(super.typedSelect(tree, pt))

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ trait Checking {
814814
def checkRealizableBounds(cls: Symbol, pos: SrcPos)(using Context): Unit = {
815815
val rstatus = boundsRealizability(cls.thisType)
816816
if (rstatus ne Realizable)
817-
report.error(ex"$cls cannot be instantiated since it${rstatus.msg}", pos)
817+
report.error(em"$cls cannot be instantiated since it${rstatus.msg}", pos)
818818
}
819819

820820
/** Check that pattern `pat` is irrefutable for scrutinee type `sel.tpe`.
@@ -1050,7 +1050,7 @@ trait Checking {
10501050
def checkFeasibleParent(tp: Type, pos: SrcPos, where: => String = "")(using Context): Type = {
10511051
def checkGoodBounds(tp: Type) = tp match {
10521052
case tp @ TypeBounds(lo, hi) if !(lo <:< hi) =>
1053-
report.error(ex"no type exists between low bound $lo and high bound $hi$where", pos)
1053+
report.error(em"no type exists between low bound $lo and high bound $hi$where", pos)
10541054
TypeBounds(hi, hi)
10551055
case _ =>
10561056
tp
@@ -1175,7 +1175,7 @@ trait Checking {
11751175
parent match {
11761176
case parent: ClassSymbol =>
11771177
if (parent.is(Case))
1178-
report.error(ex"""case $caseCls has case ancestor $parent, but case-to-case inheritance is prohibited.
1178+
report.error(em"""case $caseCls has case ancestor $parent, but case-to-case inheritance is prohibited.
11791179
|To overcome this limitation, use extractors to pattern match on non-leaf nodes.""", pos)
11801180
else checkCaseInheritance(parent.superClass, caseCls, pos)
11811181
case _ =>

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ trait TypeAssigner {
167167
case _ => false
168168
def addendum = err.selectErrorAddendum(tree, qual, qualType, importSuggestionAddendum, foundWithoutNull)
169169
val msg: Message =
170-
if tree.name == nme.CONSTRUCTOR then ex"$qualType does not have a constructor".toMessage
170+
if tree.name == nme.CONSTRUCTOR then em"$qualType does not have a constructor"
171171
else NotAMember(qualType, tree.name, kind, addendum)
172172
errorType(msg, tree.srcPos)
173173

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
527527
val found = findRef(name, pt, EmptyFlags, EmptyFlags, tree.srcPos)
528528
if foundUnderScala2.exists && !(foundUnderScala2 =:= found) then
529529
report.migrationWarning(
530-
ex"""Name resolution will change.
530+
em"""Name resolution will change.
531531
| currently selected : $foundUnderScala2
532532
| in the future, without -source 3.0-migration: $found""", tree.srcPos)
533533
foundUnderScala2
@@ -586,7 +586,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
586586
else if ctx.owner.isConstructor && !ctx.owner.isPrimaryConstructor
587587
&& ctx.owner.owner.unforcedDecls.lookup(tree.name).exists
588588
then // we are in the arguments of a this(...) constructor call
589-
errorTree(tree, ex"$tree is not accessible from constructor arguments")
589+
errorTree(tree, em"$tree is not accessible from constructor arguments")
590590
else
591591
errorTree(tree, MissingIdent(tree, kind, name))
592592
end typedIdent
@@ -1528,7 +1528,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
15281528
// Replace the underspecified expected type by one based on the closure method type
15291529
defn.PartialFunctionOf(mt.firstParamTypes.head, mt.resultType)
15301530
else
1531-
report.error(ex"result type of lambda is an underspecified SAM type $pt", tree.srcPos)
1531+
report.error(em"result type of lambda is an underspecified SAM type $pt", tree.srcPos)
15321532
pt
15331533
TypeTree(targetTpe)
15341534
case _ =>
@@ -3736,7 +3736,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
37363736
if (!defn.isFunctionType(pt))
37373737
pt match {
37383738
case SAMType(_) if !pt.classSymbol.hasAnnotation(defn.FunctionalInterfaceAnnot) =>
3739-
report.warning(ex"${tree.symbol} is eta-expanded even though $pt does not have the @FunctionalInterface annotation.", tree.srcPos)
3739+
report.warning(em"${tree.symbol} is eta-expanded even though $pt does not have the @FunctionalInterface annotation.", tree.srcPos)
37403740
case _ =>
37413741
}
37423742
simplify(typed(etaExpand(tree, wtp, arity), pt), pt, locked)

0 commit comments

Comments
 (0)