Skip to content

Commit c799891

Browse files
committed
Apply same changes to test compiler
1 parent 818aab1 commit c799891

File tree

9 files changed

+31
-37
lines changed

9 files changed

+31
-37
lines changed

tests/pos-with-compiler-cc/dotc/ast/DesugarEnums.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ object DesugarEnums {
7575
def problem =
7676
if (!tparam.isOneOf(VarianceFlags)) "is invariant"
7777
else "has bounds that depend on a type parameter in the same parameter list"
78-
errorType(i"""cannot determine type argument for enum parent $enumClass,
79-
|type parameter $tparam $problem""", ctx.source.atSpan(span))
78+
errorType(em"""cannot determine type argument for enum parent $enumClass,
79+
|type parameter $tparam $problem""", ctx.source.atSpan(span))
8080
}
8181
}
8282
TypeTree(enumClass.typeRef.appliedTo(targs)).withSpan(span)

tests/pos-with-compiler-cc/dotc/inlines/Inliner.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ class Inliner(val call: tpd.Tree)(using Context):
893893
private def inlineIfNeeded(tree: Tree)(using Context): Tree =
894894
val meth = tree.symbol
895895
if meth.isAllOf(DeferredInline) then
896-
errorTree(tree, i"Deferred inline ${meth.showLocated} cannot be invoked")
896+
errorTree(tree, em"Deferred inline ${meth.showLocated} cannot be invoked")
897897
else if Inlines.needsInlining(tree) then Inlines.inlineCall(tree)
898898
else tree
899899

tests/pos-with-compiler-cc/dotc/transform/PostTyper.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
269269

270270
def checkNotPackage(tree: Tree)(using Context): Tree =
271271
if !tree.symbol.is(Package) then tree
272-
else errorTree(tree, i"${tree.symbol} cannot be used as a type")
272+
else errorTree(tree, em"${tree.symbol} cannot be used as a type")
273273

274274
override def transform(tree: Tree)(using Context): Tree =
275275
try tree match {

tests/pos-with-compiler-cc/dotc/typer/Applications.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ object Applications {
4646
def extractorMemberType(tp: Type, name: Name, errorPos: SrcPos)(using Context): Type = {
4747
val ref = extractorMember(tp, name)
4848
if (ref.isOverloaded)
49-
errorType(i"Overloaded reference to $ref is not allowed in extractor", errorPos)
49+
errorType(em"Overloaded reference to $ref is not allowed in extractor", errorPos)
5050
ref.info.widenExpr.annotatedToRepeated
5151
}
5252

@@ -1134,14 +1134,14 @@ trait Applications extends Compatibility {
11341134

11351135
def typedTypeApply(tree: untpd.TypeApply, pt: Type)(using Context): Tree = {
11361136
if (ctx.mode.is(Mode.Pattern))
1137-
return errorTree(tree, "invalid pattern")
1137+
return errorTree(tree, em"invalid pattern")
11381138

11391139
val isNamed = hasNamedArg(tree.args)
11401140
val typedArgs = if (isNamed) typedNamedArgs(tree.args) else tree.args.mapconserve(typedType(_))
11411141
record("typedTypeApply")
11421142
typedExpr(tree.fun, PolyProto(typedArgs, pt)) match {
11431143
case _: TypeApply if !ctx.isAfterTyper =>
1144-
errorTree(tree, "illegal repeated type application")
1144+
errorTree(tree, em"illegal repeated type application")
11451145
case typedFn =>
11461146
typedFn.tpe.widen match {
11471147
case pt: PolyType =>

tests/pos-with-compiler-cc/dotc/typer/Checking.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ object Checking {
156156
checker.traverse(tpt.tpe)
157157

158158
def checkNoWildcard(tree: Tree)(using Context): Tree = tree.tpe match {
159-
case tpe: TypeBounds => errorTree(tree, "no wildcard type allowed here")
159+
case tpe: TypeBounds => errorTree(tree, em"no wildcard type allowed here")
160160
case _ => tree
161161
}
162162

tests/pos-with-compiler-cc/dotc/typer/Dynamic.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ trait Dynamic {
8080
val args = tree.args
8181
val dynName = if (args.exists(isNamedArg)) nme.applyDynamicNamed else nme.applyDynamic
8282
if (dynName == nme.applyDynamicNamed && untpd.isWildcardStarArgList(args))
83-
errorTree(tree, "applyDynamicNamed does not support passing a vararg parameter")
83+
errorTree(tree, em"applyDynamicNamed does not support passing a vararg parameter")
8484
else {
8585
def namedArgTuple(name: String, arg: untpd.Tree) = untpd.Tuple(List(Literal(Constant(name)), arg))
8686
def namedArgs = args.map {

tests/pos-with-compiler-cc/dotc/typer/ErrorReporting.scala

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ object ErrorReporting {
2424
def errorTree(tree: untpd.Tree, msg: Message)(using Context): tpd.Tree =
2525
errorTree(tree, msg, tree.srcPos)
2626

27-
def errorTree(tree: untpd.Tree, msg: -> String)(using Context): tpd.Tree =
28-
errorTree(tree, msg.toMessage)
29-
3027
def errorTree(tree: untpd.Tree, msg: TypeError, pos: SrcPos)(using Context): tpd.Tree =
3128
tree.withType(errorType(msg, pos))
3229

@@ -35,9 +32,6 @@ object ErrorReporting {
3532
ErrorType(msg)
3633
}
3734

38-
def errorType(msg: -> String, pos: SrcPos)(using Context): ErrorType =
39-
errorType(msg.toMessage, pos)
40-
4135
def errorType(ex: TypeError, pos: SrcPos)(using Context): ErrorType = {
4236
report.error(ex, pos)
4337
ErrorType(ex.toMessage)
@@ -147,11 +141,11 @@ object ErrorReporting {
147141

148142
def exprStr(tree: Tree): String = refStr(tree.tpe)
149143

150-
def takesNoParamsStr(tree: Tree, kind: String): String =
144+
def takesNoParamsMsg(tree: Tree, kind: String): Message =
151145
if (tree.tpe.widen.exists)
152-
i"${exprStr(tree)} does not take ${kind}parameters"
146+
em"${exprStr(tree)} does not take ${kind}parameters"
153147
else {
154-
i"undefined: $tree # ${tree.uniqueId}: ${tree.tpe.toString} at ${ctx.phase}"
148+
em"undefined: $tree # ${tree.uniqueId}: ${tree.tpe.toString} at ${ctx.phase}"
155149
}
156150

157151
def patternConstrStr(tree: Tree): String = ???
@@ -272,9 +266,9 @@ object ErrorReporting {
272266
ownerSym.typeRef.nonClassTypeMembers.map(_.symbol)
273267
}.toList
274268

275-
def dependentStr =
269+
def dependentMsg =
276270
"""Term-dependent types are experimental,
277-
|they must be enabled with a `experimental.dependent` language import or setting""".stripMargin
271+
|they must be enabled with a `experimental.dependent` language import or setting""".stripMargin.toMessage
278272

279273
def err(using Context): Errors = new Errors
280274
}

tests/pos-with-compiler-cc/dotc/typer/TypeAssigner.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ trait TypeAssigner {
226226
val cls = qualifyingClass(tree, tree.qual.name, packageOK = false)
227227
tree.withType(
228228
if (cls.isClass) cls.thisType
229-
else errorType("not a legal qualifying class for this", tree.srcPos))
229+
else errorType(em"not a legal qualifying class for this", tree.srcPos))
230230
}
231231

232232
def superType(qualType: Type, mix: untpd.Ident, mixinClass: Symbol, pos: SrcPos)(using Context) =
@@ -240,7 +240,7 @@ trait TypeAssigner {
240240
case Nil =>
241241
errorType(SuperQualMustBeParent(mix, cls), pos)
242242
case p :: q :: _ =>
243-
errorType("ambiguous parent class qualifier", pos)
243+
errorType(em"ambiguous parent class qualifier", pos)
244244
}
245245
val owntype =
246246
if (mixinClass.exists) mixinClass.typeRef
@@ -288,16 +288,16 @@ trait TypeAssigner {
288288
if (fntpe.paramInfos.hasSameLengthAs(args) || ctx.phase.prev.relaxedTyping)
289289
safeSubstMethodParams(fntpe, args.tpes)
290290
else
291-
errorType(i"wrong number of arguments at ${ctx.phase.prev} for $fntpe: ${fn.tpe}, expected: ${fntpe.paramInfos.length}, found: ${args.length}", tree.srcPos)
291+
errorType(em"wrong number of arguments at ${ctx.phase.prev} for $fntpe: ${fn.tpe}, expected: ${fntpe.paramInfos.length}, found: ${args.length}", tree.srcPos)
292292
case t =>
293293
if (ctx.settings.Ydebug.value) new FatalError("").printStackTrace()
294-
errorType(err.takesNoParamsStr(fn, ""), tree.srcPos)
294+
errorType(err.takesNoParamsMsg(fn, ""), tree.srcPos)
295295
}
296296
ConstFold.Apply(tree.withType(ownType))
297297
}
298298

299299
def assignType(tree: untpd.TypeApply, fn: Tree, args: List[Tree])(using Context): TypeApply = {
300-
def fail = tree.withType(errorType(err.takesNoParamsStr(fn, "type "), tree.srcPos))
300+
def fail = tree.withType(errorType(err.takesNoParamsMsg(fn, "type "), tree.srcPos))
301301
ConstFold(fn.tpe.widen match {
302302
case pt: TypeLambda =>
303303
tree.withType {

tests/pos-with-compiler-cc/dotc/typer/Typer.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
676676
javaSelectOnType(qual2)
677677

678678
case _ =>
679-
errorTree(tree, "cannot convert to type selection") // will never be printed due to fallback
679+
errorTree(tree, em"cannot convert to type selection") // will never be printed due to fallback
680680
}
681681

682682
def selectWithFallback(fallBack: Context ?-> Tree) =
@@ -1535,8 +1535,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
15351535
case _ =>
15361536
if (mt.isParamDependent)
15371537
errorTree(tree,
1538-
i"""cannot turn method type $mt into closure
1539-
|because it has internal parameter dependencies""")
1538+
em"""cannot turn method type $mt into closure
1539+
|because it has internal parameter dependencies""")
15401540
else if ((tree.tpt `eq` untpd.ContextualEmptyTree) && mt.paramNames.isEmpty)
15411541
// Note implicitness of function in target type since there are no method parameters that indicate it.
15421542
TypeTree(defn.FunctionOf(Nil, mt.resType, isContextual = true, isErased = false))
@@ -1784,7 +1784,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
17841784
var body1 = typedType(cdef.body, pt)
17851785
if !body1.isType then
17861786
assert(ctx.reporter.errorsReported)
1787-
body1 = TypeTree(errorType("<error: not a type>", cdef.srcPos))
1787+
body1 = TypeTree(errorType(em"<error: not a type>", cdef.srcPos))
17881788
assignType(cpy.CaseDef(cdef)(pat2, EmptyTree, body1), pat2, body1)
17891789
}
17901790
caseRest(using ctx.fresh.setFreshGADTBounds.setNewScope)
@@ -1932,7 +1932,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19321932
.withType(
19331933
if isFullyDefined(pt, ForceDegree.flipBottom) then pt
19341934
else if ctx.reporter.errorsReported then UnspecifiedErrorType
1935-
else errorType(i"cannot infer type; expected type $pt is not fully defined", tree.srcPos))
1935+
else errorType(em"cannot infer type; expected type $pt is not fully defined", tree.srcPos))
19361936

19371937
def typedTypeTree(tree: untpd.TypeTree, pt: Type)(using Context): Tree =
19381938
tree match
@@ -1946,7 +1946,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19461946
// untyped tree is no longer accessed after all
19471947
// accesses with typedTypeTree are done.
19481948
case None =>
1949-
errorTree(tree, "Something's wrong: missing original symbol for type tree")
1949+
errorTree(tree, em"Something's wrong: missing original symbol for type tree")
19501950
}
19511951
case _ =>
19521952
completeTypeTree(InferredTypeTree(), pt, tree)
@@ -1987,9 +1987,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
19871987
tree.args match
19881988
case arg :: _ if arg.isTerm =>
19891989
if Feature.dependentEnabled then
1990-
return errorTree(tree, i"Not yet implemented: T(...)")
1990+
return errorTree(tree, em"Not yet implemented: T(...)")
19911991
else
1992-
return errorTree(tree, dependentStr)
1992+
return errorTree(tree, dependentMsg)
19931993
case _ =>
19941994

19951995
val tpt1 = withoutMode(Mode.Pattern) {
@@ -2128,9 +2128,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
21282128

21292129
def typedTermLambdaTypeTree(tree: untpd.TermLambdaTypeTree)(using Context): Tree =
21302130
if Feature.dependentEnabled then
2131-
errorTree(tree, i"Not yet implemented: (...) =>> ...")
2131+
errorTree(tree, em"Not yet implemented: (...) =>> ...")
21322132
else
2133-
errorTree(tree, dependentStr)
2133+
errorTree(tree, dependentMsg)
21342134

21352135
def typedMatchTypeTree(tree: untpd.MatchTypeTree, pt: Type)(using Context): Tree = {
21362136
val bound1 =
@@ -2162,7 +2162,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
21622162

21632163
def typedBind(tree: untpd.Bind, pt: Type)(using Context): Tree = {
21642164
if !isFullyDefined(pt, ForceDegree.all) then
2165-
return errorTree(tree, i"expected type of $tree is not fully defined")
2165+
return errorTree(tree, em"expected type of $tree is not fully defined")
21662166
val body1 = typed(tree.body, pt)
21672167
body1 match {
21682168
case UnApply(fn, Nil, arg :: Nil)
@@ -3780,7 +3780,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
37803780
else
37813781
val meth = methPart(tree).symbol
37823782
if meth.isAllOf(DeferredInline) && !Inlines.inInlineMethod then
3783-
errorTree(tree, i"Deferred inline ${meth.showLocated} cannot be invoked")
3783+
errorTree(tree, em"Deferred inline ${meth.showLocated} cannot be invoked")
37843784
else if Inlines.needsInlining(tree) then
37853785
tree.tpe <:< wildApprox(pt)
37863786
val errorCount = ctx.reporter.errorCount

0 commit comments

Comments
 (0)