From 818aab1d36679cb2ded05d6e4314e3dd36c8caca Mon Sep 17 00:00:00 2001 From: odersky Date: Sat, 26 Nov 2022 11:45:55 +0100 Subject: [PATCH 1/2] Drop String overloads in errorTree and errorType This was forgotten in the last big error message refactoring --- .../dotty/tools/dotc/ast/DesugarEnums.scala | 4 ++-- .../dotty/tools/dotc/inlines/Inliner.scala | 2 +- .../tools/dotc/transform/PostTyper.scala | 2 +- .../dotty/tools/dotc/typer/Applications.scala | 6 ++--- .../src/dotty/tools/dotc/typer/Checking.scala | 2 +- .../src/dotty/tools/dotc/typer/Dynamic.scala | 2 +- .../tools/dotc/typer/ErrorReporting.scala | 16 ++++--------- .../dotty/tools/dotc/typer/TypeAssigner.scala | 10 ++++---- .../src/dotty/tools/dotc/typer/Typer.scala | 24 +++++++++---------- 9 files changed, 31 insertions(+), 37 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala b/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala index 467bd8c7b420..a1c3c0ed0775 100644 --- a/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala +++ b/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala @@ -75,8 +75,8 @@ object DesugarEnums { def problem = if (!tparam.isOneOf(VarianceFlags)) "is invariant" else "has bounds that depend on a type parameter in the same parameter list" - errorType(i"""cannot determine type argument for enum parent $enumClass, - |type parameter $tparam $problem""", ctx.source.atSpan(span)) + errorType(em"""cannot determine type argument for enum parent $enumClass, + |type parameter $tparam $problem""", ctx.source.atSpan(span)) } } TypeTree(enumClass.typeRef.appliedTo(targs)).withSpan(span) diff --git a/compiler/src/dotty/tools/dotc/inlines/Inliner.scala b/compiler/src/dotty/tools/dotc/inlines/Inliner.scala index 92ca9b6ed724..69d3047b3bbb 100644 --- a/compiler/src/dotty/tools/dotc/inlines/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/inlines/Inliner.scala @@ -892,7 +892,7 @@ class Inliner(val call: tpd.Tree)(using Context): private def inlineIfNeeded(tree: Tree)(using Context): Tree = val meth = tree.symbol if meth.isAllOf(DeferredInline) then - errorTree(tree, i"Deferred inline ${meth.showLocated} cannot be invoked") + errorTree(tree, em"Deferred inline ${meth.showLocated} cannot be invoked") else if Inlines.needsInlining(tree) then Inlines.inlineCall(tree) else tree diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala index 05aaa745bb18..a669be3d1e3c 100644 --- a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala @@ -269,7 +269,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase def checkNotPackage(tree: Tree)(using Context): Tree = if !tree.symbol.is(Package) then tree - else errorTree(tree, i"${tree.symbol} cannot be used as a type") + else errorTree(tree, em"${tree.symbol} cannot be used as a type") override def transform(tree: Tree)(using Context): Tree = try tree match { diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 637ed53e25fc..8dad9247a6e9 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -46,7 +46,7 @@ object Applications { def extractorMemberType(tp: Type, name: Name, errorPos: SrcPos)(using Context): Type = { val ref = extractorMember(tp, name) if (ref.isOverloaded) - errorType(i"Overloaded reference to $ref is not allowed in extractor", errorPos) + errorType(em"Overloaded reference to $ref is not allowed in extractor", errorPos) ref.info.widenExpr.annotatedToRepeated } @@ -1134,14 +1134,14 @@ trait Applications extends Compatibility { def typedTypeApply(tree: untpd.TypeApply, pt: Type)(using Context): Tree = { if (ctx.mode.is(Mode.Pattern)) - return errorTree(tree, "invalid pattern") + return errorTree(tree, em"invalid pattern") val isNamed = hasNamedArg(tree.args) val typedArgs = if (isNamed) typedNamedArgs(tree.args) else tree.args.mapconserve(typedType(_)) record("typedTypeApply") typedExpr(tree.fun, PolyProto(typedArgs, pt)) match { case _: TypeApply if !ctx.isAfterTyper => - errorTree(tree, "illegal repeated type application") + errorTree(tree, em"illegal repeated type application") case typedFn => typedFn.tpe.widen match { case pt: PolyType => diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index 6dc61efc513a..a1ee2c539622 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -155,7 +155,7 @@ object Checking { checker.traverse(tpt.tpe) def checkNoWildcard(tree: Tree)(using Context): Tree = tree.tpe match { - case tpe: TypeBounds => errorTree(tree, "no wildcard type allowed here") + case tpe: TypeBounds => errorTree(tree, em"no wildcard type allowed here") case _ => tree } diff --git a/compiler/src/dotty/tools/dotc/typer/Dynamic.scala b/compiler/src/dotty/tools/dotc/typer/Dynamic.scala index 1630ce31e4c6..b69d83b2dcd5 100644 --- a/compiler/src/dotty/tools/dotc/typer/Dynamic.scala +++ b/compiler/src/dotty/tools/dotc/typer/Dynamic.scala @@ -80,7 +80,7 @@ trait Dynamic { val args = tree.args val dynName = if (args.exists(isNamedArg)) nme.applyDynamicNamed else nme.applyDynamic if (dynName == nme.applyDynamicNamed && untpd.isWildcardStarArgList(args)) - errorTree(tree, "applyDynamicNamed does not support passing a vararg parameter") + errorTree(tree, em"applyDynamicNamed does not support passing a vararg parameter") else { def namedArgTuple(name: String, arg: untpd.Tree) = untpd.Tuple(List(Literal(Constant(name)), arg)) def namedArgs = args.map { diff --git a/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala b/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala index 764d247280d4..32b5fde689ec 100644 --- a/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala +++ b/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala @@ -24,9 +24,6 @@ object ErrorReporting { def errorTree(tree: untpd.Tree, msg: Message)(using Context): tpd.Tree = errorTree(tree, msg, tree.srcPos) - def errorTree(tree: untpd.Tree, msg: => String)(using Context): tpd.Tree = - errorTree(tree, msg.toMessage) - def errorTree(tree: untpd.Tree, msg: TypeError, pos: SrcPos)(using Context): tpd.Tree = tree.withType(errorType(msg, pos)) @@ -35,9 +32,6 @@ object ErrorReporting { ErrorType(msg) } - def errorType(msg: => String, pos: SrcPos)(using Context): ErrorType = - errorType(msg.toMessage, pos) - def errorType(ex: TypeError, pos: SrcPos)(using Context): ErrorType = { report.error(ex, pos) ErrorType(ex.toMessage) @@ -147,11 +141,11 @@ object ErrorReporting { def exprStr(tree: Tree): String = refStr(tree.tpe) - def takesNoParamsStr(tree: Tree, kind: String): String = + def takesNoParamsMsg(tree: Tree, kind: String): Message = if (tree.tpe.widen.exists) - i"${exprStr(tree)} does not take ${kind}parameters" + em"${exprStr(tree)} does not take ${kind}parameters" else { - i"undefined: $tree # ${tree.uniqueId}: ${tree.tpe.toString} at ${ctx.phase}" + em"undefined: $tree # ${tree.uniqueId}: ${tree.tpe.toString} at ${ctx.phase}" } def patternConstrStr(tree: Tree): String = ??? @@ -272,9 +266,9 @@ object ErrorReporting { ownerSym.typeRef.nonClassTypeMembers.map(_.symbol) }.toList - def dependentStr = + def dependentMsg = """Term-dependent types are experimental, - |they must be enabled with a `experimental.dependent` language import or setting""".stripMargin + |they must be enabled with a `experimental.dependent` language import or setting""".stripMargin.toMessage def err(using Context): Errors = new Errors } diff --git a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala index 68bdd4f4970a..6d225e2c7629 100644 --- a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -226,7 +226,7 @@ trait TypeAssigner { val cls = qualifyingClass(tree, tree.qual.name, packageOK = false) tree.withType( if (cls.isClass) cls.thisType - else errorType("not a legal qualifying class for this", tree.srcPos)) + else errorType(em"not a legal qualifying class for this", tree.srcPos)) } def superType(qualType: Type, mix: untpd.Ident, mixinClass: Symbol, pos: SrcPos)(using Context) = @@ -240,7 +240,7 @@ trait TypeAssigner { case Nil => errorType(SuperQualMustBeParent(mix, cls), pos) case p :: q :: _ => - errorType("ambiguous parent class qualifier", pos) + errorType(em"ambiguous parent class qualifier", pos) } val owntype = if (mixinClass.exists) mixinClass.typeRef @@ -288,16 +288,16 @@ trait TypeAssigner { if (fntpe.paramInfos.hasSameLengthAs(args) || ctx.phase.prev.relaxedTyping) safeSubstMethodParams(fntpe, args.tpes) else - errorType(i"wrong number of arguments at ${ctx.phase.prev} for $fntpe: ${fn.tpe}, expected: ${fntpe.paramInfos.length}, found: ${args.length}", tree.srcPos) + errorType(em"wrong number of arguments at ${ctx.phase.prev} for $fntpe: ${fn.tpe}, expected: ${fntpe.paramInfos.length}, found: ${args.length}", tree.srcPos) case t => if (ctx.settings.Ydebug.value) new FatalError("").printStackTrace() - errorType(err.takesNoParamsStr(fn, ""), tree.srcPos) + errorType(err.takesNoParamsMsg(fn, ""), tree.srcPos) } ConstFold.Apply(tree.withType(ownType)) } def assignType(tree: untpd.TypeApply, fn: Tree, args: List[Tree])(using Context): TypeApply = { - def fail = tree.withType(errorType(err.takesNoParamsStr(fn, "type "), tree.srcPos)) + def fail = tree.withType(errorType(err.takesNoParamsMsg(fn, "type "), tree.srcPos)) ConstFold(fn.tpe.widen match { case pt: TypeLambda => tree.withType { diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 51d1641038be..9616344558a2 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -675,7 +675,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer javaSelectOnType(qual2) case _ => - errorTree(tree, "cannot convert to type selection") // will never be printed due to fallback + errorTree(tree, em"cannot convert to type selection") // will never be printed due to fallback } def selectWithFallback(fallBack: Context ?=> Tree) = @@ -1534,8 +1534,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer case _ => if (mt.isParamDependent) errorTree(tree, - i"""cannot turn method type $mt into closure - |because it has internal parameter dependencies""") + em"""cannot turn method type $mt into closure + |because it has internal parameter dependencies""") else if ((tree.tpt `eq` untpd.ContextualEmptyTree) && mt.paramNames.isEmpty) // Note implicitness of function in target type since there are no method parameters that indicate it. TypeTree(defn.FunctionOf(Nil, mt.resType, isContextual = true, isErased = false)) @@ -1783,7 +1783,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer var body1 = typedType(cdef.body, pt) if !body1.isType then assert(ctx.reporter.errorsReported) - body1 = TypeTree(errorType("", cdef.srcPos)) + body1 = TypeTree(errorType(em"", cdef.srcPos)) assignType(cpy.CaseDef(cdef)(pat2, EmptyTree, body1), pat2, body1) } caseRest(using ctx.fresh.setFreshGADTBounds.setNewScope) @@ -1931,7 +1931,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer .withType( if isFullyDefined(pt, ForceDegree.flipBottom) then pt else if ctx.reporter.errorsReported then UnspecifiedErrorType - else errorType(i"cannot infer type; expected type $pt is not fully defined", tree.srcPos)) + else errorType(em"cannot infer type; expected type $pt is not fully defined", tree.srcPos)) def typedTypeTree(tree: untpd.TypeTree, pt: Type)(using Context): Tree = tree match @@ -1945,7 +1945,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer // untyped tree is no longer accessed after all // accesses with typedTypeTree are done. case None => - errorTree(tree, "Something's wrong: missing original symbol for type tree") + errorTree(tree, em"Something's wrong: missing original symbol for type tree") } case _ => completeTypeTree(InferredTypeTree(), pt, tree) @@ -1986,9 +1986,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer tree.args match case arg :: _ if arg.isTerm => if Feature.dependentEnabled then - return errorTree(tree, i"Not yet implemented: T(...)") + return errorTree(tree, em"Not yet implemented: T(...)") else - return errorTree(tree, dependentStr) + return errorTree(tree, dependentMsg) case _ => val tpt1 = withoutMode(Mode.Pattern) { @@ -2127,9 +2127,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer def typedTermLambdaTypeTree(tree: untpd.TermLambdaTypeTree)(using Context): Tree = if Feature.dependentEnabled then - errorTree(tree, i"Not yet implemented: (...) =>> ...") + errorTree(tree, em"Not yet implemented: (...) =>> ...") else - errorTree(tree, dependentStr) + errorTree(tree, dependentMsg) def typedMatchTypeTree(tree: untpd.MatchTypeTree, pt: Type)(using Context): Tree = { val bound1 = @@ -2161,7 +2161,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer def typedBind(tree: untpd.Bind, pt: Type)(using Context): Tree = { if !isFullyDefined(pt, ForceDegree.all) then - return errorTree(tree, i"expected type of $tree is not fully defined") + return errorTree(tree, em"expected type of $tree is not fully defined") val body1 = typed(tree.body, pt) body1 match { case UnApply(fn, Nil, arg :: Nil) @@ -3779,7 +3779,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer else val meth = methPart(tree).symbol if meth.isAllOf(DeferredInline) && !Inlines.inInlineMethod then - errorTree(tree, i"Deferred inline ${meth.showLocated} cannot be invoked") + errorTree(tree, em"Deferred inline ${meth.showLocated} cannot be invoked") else if Inlines.needsInlining(tree) then tree.tpe <:< wildApprox(pt) val errorCount = ctx.reporter.errorCount From c7998917654ab6d26ffab5e1c1727ef446b272cd Mon Sep 17 00:00:00 2001 From: odersky Date: Sat, 26 Nov 2022 11:59:34 +0100 Subject: [PATCH 2/2] Apply same changes to test compiler --- .../dotc/ast/DesugarEnums.scala | 4 ++-- .../dotc/inlines/Inliner.scala | 2 +- .../dotc/transform/PostTyper.scala | 2 +- .../dotc/typer/Applications.scala | 6 ++--- .../dotc/typer/Checking.scala | 2 +- .../dotc/typer/Dynamic.scala | 2 +- .../dotc/typer/ErrorReporting.scala | 16 ++++--------- .../dotc/typer/TypeAssigner.scala | 10 ++++---- .../dotc/typer/Typer.scala | 24 +++++++++---------- 9 files changed, 31 insertions(+), 37 deletions(-) diff --git a/tests/pos-with-compiler-cc/dotc/ast/DesugarEnums.scala b/tests/pos-with-compiler-cc/dotc/ast/DesugarEnums.scala index 467bd8c7b420..a1c3c0ed0775 100644 --- a/tests/pos-with-compiler-cc/dotc/ast/DesugarEnums.scala +++ b/tests/pos-with-compiler-cc/dotc/ast/DesugarEnums.scala @@ -75,8 +75,8 @@ object DesugarEnums { def problem = if (!tparam.isOneOf(VarianceFlags)) "is invariant" else "has bounds that depend on a type parameter in the same parameter list" - errorType(i"""cannot determine type argument for enum parent $enumClass, - |type parameter $tparam $problem""", ctx.source.atSpan(span)) + errorType(em"""cannot determine type argument for enum parent $enumClass, + |type parameter $tparam $problem""", ctx.source.atSpan(span)) } } TypeTree(enumClass.typeRef.appliedTo(targs)).withSpan(span) diff --git a/tests/pos-with-compiler-cc/dotc/inlines/Inliner.scala b/tests/pos-with-compiler-cc/dotc/inlines/Inliner.scala index d59fbad670ca..ecbecb3dc429 100644 --- a/tests/pos-with-compiler-cc/dotc/inlines/Inliner.scala +++ b/tests/pos-with-compiler-cc/dotc/inlines/Inliner.scala @@ -893,7 +893,7 @@ class Inliner(val call: tpd.Tree)(using Context): private def inlineIfNeeded(tree: Tree)(using Context): Tree = val meth = tree.symbol if meth.isAllOf(DeferredInline) then - errorTree(tree, i"Deferred inline ${meth.showLocated} cannot be invoked") + errorTree(tree, em"Deferred inline ${meth.showLocated} cannot be invoked") else if Inlines.needsInlining(tree) then Inlines.inlineCall(tree) else tree diff --git a/tests/pos-with-compiler-cc/dotc/transform/PostTyper.scala b/tests/pos-with-compiler-cc/dotc/transform/PostTyper.scala index 05aaa745bb18..a669be3d1e3c 100644 --- a/tests/pos-with-compiler-cc/dotc/transform/PostTyper.scala +++ b/tests/pos-with-compiler-cc/dotc/transform/PostTyper.scala @@ -269,7 +269,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase def checkNotPackage(tree: Tree)(using Context): Tree = if !tree.symbol.is(Package) then tree - else errorTree(tree, i"${tree.symbol} cannot be used as a type") + else errorTree(tree, em"${tree.symbol} cannot be used as a type") override def transform(tree: Tree)(using Context): Tree = try tree match { diff --git a/tests/pos-with-compiler-cc/dotc/typer/Applications.scala b/tests/pos-with-compiler-cc/dotc/typer/Applications.scala index f0cccd0dbde3..228ca6ca7b33 100644 --- a/tests/pos-with-compiler-cc/dotc/typer/Applications.scala +++ b/tests/pos-with-compiler-cc/dotc/typer/Applications.scala @@ -46,7 +46,7 @@ object Applications { def extractorMemberType(tp: Type, name: Name, errorPos: SrcPos)(using Context): Type = { val ref = extractorMember(tp, name) if (ref.isOverloaded) - errorType(i"Overloaded reference to $ref is not allowed in extractor", errorPos) + errorType(em"Overloaded reference to $ref is not allowed in extractor", errorPos) ref.info.widenExpr.annotatedToRepeated } @@ -1134,14 +1134,14 @@ trait Applications extends Compatibility { def typedTypeApply(tree: untpd.TypeApply, pt: Type)(using Context): Tree = { if (ctx.mode.is(Mode.Pattern)) - return errorTree(tree, "invalid pattern") + return errorTree(tree, em"invalid pattern") val isNamed = hasNamedArg(tree.args) val typedArgs = if (isNamed) typedNamedArgs(tree.args) else tree.args.mapconserve(typedType(_)) record("typedTypeApply") typedExpr(tree.fun, PolyProto(typedArgs, pt)) match { case _: TypeApply if !ctx.isAfterTyper => - errorTree(tree, "illegal repeated type application") + errorTree(tree, em"illegal repeated type application") case typedFn => typedFn.tpe.widen match { case pt: PolyType => diff --git a/tests/pos-with-compiler-cc/dotc/typer/Checking.scala b/tests/pos-with-compiler-cc/dotc/typer/Checking.scala index d8095130e206..a29a7dc73685 100644 --- a/tests/pos-with-compiler-cc/dotc/typer/Checking.scala +++ b/tests/pos-with-compiler-cc/dotc/typer/Checking.scala @@ -156,7 +156,7 @@ object Checking { checker.traverse(tpt.tpe) def checkNoWildcard(tree: Tree)(using Context): Tree = tree.tpe match { - case tpe: TypeBounds => errorTree(tree, "no wildcard type allowed here") + case tpe: TypeBounds => errorTree(tree, em"no wildcard type allowed here") case _ => tree } diff --git a/tests/pos-with-compiler-cc/dotc/typer/Dynamic.scala b/tests/pos-with-compiler-cc/dotc/typer/Dynamic.scala index 1630ce31e4c6..b69d83b2dcd5 100644 --- a/tests/pos-with-compiler-cc/dotc/typer/Dynamic.scala +++ b/tests/pos-with-compiler-cc/dotc/typer/Dynamic.scala @@ -80,7 +80,7 @@ trait Dynamic { val args = tree.args val dynName = if (args.exists(isNamedArg)) nme.applyDynamicNamed else nme.applyDynamic if (dynName == nme.applyDynamicNamed && untpd.isWildcardStarArgList(args)) - errorTree(tree, "applyDynamicNamed does not support passing a vararg parameter") + errorTree(tree, em"applyDynamicNamed does not support passing a vararg parameter") else { def namedArgTuple(name: String, arg: untpd.Tree) = untpd.Tuple(List(Literal(Constant(name)), arg)) def namedArgs = args.map { diff --git a/tests/pos-with-compiler-cc/dotc/typer/ErrorReporting.scala b/tests/pos-with-compiler-cc/dotc/typer/ErrorReporting.scala index 16f39131372b..bfc31b7e3f7d 100644 --- a/tests/pos-with-compiler-cc/dotc/typer/ErrorReporting.scala +++ b/tests/pos-with-compiler-cc/dotc/typer/ErrorReporting.scala @@ -24,9 +24,6 @@ object ErrorReporting { def errorTree(tree: untpd.Tree, msg: Message)(using Context): tpd.Tree = errorTree(tree, msg, tree.srcPos) - def errorTree(tree: untpd.Tree, msg: -> String)(using Context): tpd.Tree = - errorTree(tree, msg.toMessage) - def errorTree(tree: untpd.Tree, msg: TypeError, pos: SrcPos)(using Context): tpd.Tree = tree.withType(errorType(msg, pos)) @@ -35,9 +32,6 @@ object ErrorReporting { ErrorType(msg) } - def errorType(msg: -> String, pos: SrcPos)(using Context): ErrorType = - errorType(msg.toMessage, pos) - def errorType(ex: TypeError, pos: SrcPos)(using Context): ErrorType = { report.error(ex, pos) ErrorType(ex.toMessage) @@ -147,11 +141,11 @@ object ErrorReporting { def exprStr(tree: Tree): String = refStr(tree.tpe) - def takesNoParamsStr(tree: Tree, kind: String): String = + def takesNoParamsMsg(tree: Tree, kind: String): Message = if (tree.tpe.widen.exists) - i"${exprStr(tree)} does not take ${kind}parameters" + em"${exprStr(tree)} does not take ${kind}parameters" else { - i"undefined: $tree # ${tree.uniqueId}: ${tree.tpe.toString} at ${ctx.phase}" + em"undefined: $tree # ${tree.uniqueId}: ${tree.tpe.toString} at ${ctx.phase}" } def patternConstrStr(tree: Tree): String = ??? @@ -272,9 +266,9 @@ object ErrorReporting { ownerSym.typeRef.nonClassTypeMembers.map(_.symbol) }.toList - def dependentStr = + def dependentMsg = """Term-dependent types are experimental, - |they must be enabled with a `experimental.dependent` language import or setting""".stripMargin + |they must be enabled with a `experimental.dependent` language import or setting""".stripMargin.toMessage def err(using Context): Errors = new Errors } diff --git a/tests/pos-with-compiler-cc/dotc/typer/TypeAssigner.scala b/tests/pos-with-compiler-cc/dotc/typer/TypeAssigner.scala index 68bdd4f4970a..6d225e2c7629 100644 --- a/tests/pos-with-compiler-cc/dotc/typer/TypeAssigner.scala +++ b/tests/pos-with-compiler-cc/dotc/typer/TypeAssigner.scala @@ -226,7 +226,7 @@ trait TypeAssigner { val cls = qualifyingClass(tree, tree.qual.name, packageOK = false) tree.withType( if (cls.isClass) cls.thisType - else errorType("not a legal qualifying class for this", tree.srcPos)) + else errorType(em"not a legal qualifying class for this", tree.srcPos)) } def superType(qualType: Type, mix: untpd.Ident, mixinClass: Symbol, pos: SrcPos)(using Context) = @@ -240,7 +240,7 @@ trait TypeAssigner { case Nil => errorType(SuperQualMustBeParent(mix, cls), pos) case p :: q :: _ => - errorType("ambiguous parent class qualifier", pos) + errorType(em"ambiguous parent class qualifier", pos) } val owntype = if (mixinClass.exists) mixinClass.typeRef @@ -288,16 +288,16 @@ trait TypeAssigner { if (fntpe.paramInfos.hasSameLengthAs(args) || ctx.phase.prev.relaxedTyping) safeSubstMethodParams(fntpe, args.tpes) else - errorType(i"wrong number of arguments at ${ctx.phase.prev} for $fntpe: ${fn.tpe}, expected: ${fntpe.paramInfos.length}, found: ${args.length}", tree.srcPos) + errorType(em"wrong number of arguments at ${ctx.phase.prev} for $fntpe: ${fn.tpe}, expected: ${fntpe.paramInfos.length}, found: ${args.length}", tree.srcPos) case t => if (ctx.settings.Ydebug.value) new FatalError("").printStackTrace() - errorType(err.takesNoParamsStr(fn, ""), tree.srcPos) + errorType(err.takesNoParamsMsg(fn, ""), tree.srcPos) } ConstFold.Apply(tree.withType(ownType)) } def assignType(tree: untpd.TypeApply, fn: Tree, args: List[Tree])(using Context): TypeApply = { - def fail = tree.withType(errorType(err.takesNoParamsStr(fn, "type "), tree.srcPos)) + def fail = tree.withType(errorType(err.takesNoParamsMsg(fn, "type "), tree.srcPos)) ConstFold(fn.tpe.widen match { case pt: TypeLambda => tree.withType { diff --git a/tests/pos-with-compiler-cc/dotc/typer/Typer.scala b/tests/pos-with-compiler-cc/dotc/typer/Typer.scala index 706750345801..0e7a134f9aef 100644 --- a/tests/pos-with-compiler-cc/dotc/typer/Typer.scala +++ b/tests/pos-with-compiler-cc/dotc/typer/Typer.scala @@ -676,7 +676,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer javaSelectOnType(qual2) case _ => - errorTree(tree, "cannot convert to type selection") // will never be printed due to fallback + errorTree(tree, em"cannot convert to type selection") // will never be printed due to fallback } def selectWithFallback(fallBack: Context ?-> Tree) = @@ -1535,8 +1535,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer case _ => if (mt.isParamDependent) errorTree(tree, - i"""cannot turn method type $mt into closure - |because it has internal parameter dependencies""") + em"""cannot turn method type $mt into closure + |because it has internal parameter dependencies""") else if ((tree.tpt `eq` untpd.ContextualEmptyTree) && mt.paramNames.isEmpty) // Note implicitness of function in target type since there are no method parameters that indicate it. TypeTree(defn.FunctionOf(Nil, mt.resType, isContextual = true, isErased = false)) @@ -1784,7 +1784,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer var body1 = typedType(cdef.body, pt) if !body1.isType then assert(ctx.reporter.errorsReported) - body1 = TypeTree(errorType("", cdef.srcPos)) + body1 = TypeTree(errorType(em"", cdef.srcPos)) assignType(cpy.CaseDef(cdef)(pat2, EmptyTree, body1), pat2, body1) } caseRest(using ctx.fresh.setFreshGADTBounds.setNewScope) @@ -1932,7 +1932,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer .withType( if isFullyDefined(pt, ForceDegree.flipBottom) then pt else if ctx.reporter.errorsReported then UnspecifiedErrorType - else errorType(i"cannot infer type; expected type $pt is not fully defined", tree.srcPos)) + else errorType(em"cannot infer type; expected type $pt is not fully defined", tree.srcPos)) def typedTypeTree(tree: untpd.TypeTree, pt: Type)(using Context): Tree = tree match @@ -1946,7 +1946,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer // untyped tree is no longer accessed after all // accesses with typedTypeTree are done. case None => - errorTree(tree, "Something's wrong: missing original symbol for type tree") + errorTree(tree, em"Something's wrong: missing original symbol for type tree") } case _ => completeTypeTree(InferredTypeTree(), pt, tree) @@ -1987,9 +1987,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer tree.args match case arg :: _ if arg.isTerm => if Feature.dependentEnabled then - return errorTree(tree, i"Not yet implemented: T(...)") + return errorTree(tree, em"Not yet implemented: T(...)") else - return errorTree(tree, dependentStr) + return errorTree(tree, dependentMsg) case _ => val tpt1 = withoutMode(Mode.Pattern) { @@ -2128,9 +2128,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer def typedTermLambdaTypeTree(tree: untpd.TermLambdaTypeTree)(using Context): Tree = if Feature.dependentEnabled then - errorTree(tree, i"Not yet implemented: (...) =>> ...") + errorTree(tree, em"Not yet implemented: (...) =>> ...") else - errorTree(tree, dependentStr) + errorTree(tree, dependentMsg) def typedMatchTypeTree(tree: untpd.MatchTypeTree, pt: Type)(using Context): Tree = { val bound1 = @@ -2162,7 +2162,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer def typedBind(tree: untpd.Bind, pt: Type)(using Context): Tree = { if !isFullyDefined(pt, ForceDegree.all) then - return errorTree(tree, i"expected type of $tree is not fully defined") + return errorTree(tree, em"expected type of $tree is not fully defined") val body1 = typed(tree.body, pt) body1 match { case UnApply(fn, Nil, arg :: Nil) @@ -3780,7 +3780,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer else val meth = methPart(tree).symbol if meth.isAllOf(DeferredInline) && !Inlines.inInlineMethod then - errorTree(tree, i"Deferred inline ${meth.showLocated} cannot be invoked") + errorTree(tree, em"Deferred inline ${meth.showLocated} cannot be invoked") else if Inlines.needsInlining(tree) then tree.tpe <:< wildApprox(pt) val errorCount = ctx.reporter.errorCount