Skip to content

CC-UPDATE: Update test compiler to latest version #16413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/pos-with-compiler-cc/dotc/CompilationUnit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ object CompilationUnit {
if (!mustExist)
source
else if (source.file.isDirectory) {
report.error(s"expected file, received directory '${source.file.path}'")
report.error(em"expected file, received directory '${source.file.path}'")
NoSource
}
else if (!source.file.exists) {
report.error(s"source file not found: ${source.file.path}")
report.error(em"source file not found: ${source.file.path}")
NoSource
}
else source
Expand Down
6 changes: 3 additions & 3 deletions tests/pos-with-compiler-cc/dotc/Driver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ class Driver {
val newEntries: List[String] = files
.flatMap { file =>
if !file.exists then
report.error(s"File does not exist: ${file.path}")
report.error(em"File does not exist: ${file.path}")
None
else file.extension match
case "jar" => Some(file.path)
case "tasty" =>
TastyFileUtil.getClassPath(file) match
case Some(classpath) => Some(classpath)
case _ =>
report.error(s"Could not load classname from: ${file.path}")
report.error(em"Could not load classname from: ${file.path}")
None
case _ =>
report.error(s"File extension is not `tasty` or `jar`: ${file.path}")
report.error(em"File extension is not `tasty` or `jar`: ${file.path}")
None
}
.distinct
Expand Down
52 changes: 31 additions & 21 deletions tests/pos-with-compiler-cc/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import core._
import util.Spans._, Types._, Contexts._, Constants._, Names._, NameOps._, Flags._
import Symbols._, StdNames._, Trees._, ContextOps._
import Decorators._, transform.SymUtils._
import Annotations.Annotation
import NameKinds.{UniqueName, EvidenceParamName, DefaultGetterName, WildcardParamName}
import typer.{Namer, Checking}
import util.{Property, SourceFile, SourcePosition, Chars}
Expand Down Expand Up @@ -117,7 +118,7 @@ object desugar {
if (local.exists) (defctx.owner.thisType select local).dealiasKeepAnnots
else {
def msg =
s"no matching symbol for ${tp.symbol.showLocated} in ${defctx.owner} / ${defctx.effectiveScope.toList}"
em"no matching symbol for ${tp.symbol.showLocated} in ${defctx.owner} / ${defctx.effectiveScope.toList}"
ErrorType(msg).assertingErrorsReported(msg)
}
case _ =>
Expand Down Expand Up @@ -165,32 +166,41 @@ object desugar {
*
* Generate setter where needed
*/
def valDef(vdef0: ValDef)(using Context): Tree = {
def valDef(vdef0: ValDef)(using Context): Tree =
val vdef @ ValDef(_, tpt, rhs) = vdef0
val mods = vdef.mods

val valName = normalizeName(vdef, tpt).asTermName
val vdef1 = cpy.ValDef(vdef)(name = valName)
var mods1 = vdef.mods

def dropInto(tpt: Tree): Tree = tpt match
case Into(tpt1) =>
mods1 = vdef.mods.withAddedAnnotation(
TypedSplice(
Annotation(defn.AllowConversionsAnnot).tree.withSpan(tpt.span.startPos)))
tpt1
case ByNameTypeTree(tpt1) =>
cpy.ByNameTypeTree(tpt)(dropInto(tpt1))
case PostfixOp(tpt1, op) if op.name == tpnme.raw.STAR =>
cpy.PostfixOp(tpt)(dropInto(tpt1), op)
case _ =>
tpt

val vdef1 = cpy.ValDef(vdef)(name = valName, tpt = dropInto(tpt))
.withMods(mods1)

if (isSetterNeeded(vdef)) {
// TODO: copy of vdef as getter needed?
// val getter = ValDef(mods, name, tpt, rhs) withPos vdef.pos?
// right now vdef maps via expandedTree to a thicket which concerns itself.
// I don't see a problem with that but if there is one we can avoid it by making a copy here.
if isSetterNeeded(vdef) then
val setterParam = makeSyntheticParameter(tpt = SetterParamTree().watching(vdef))
// The rhs gets filled in later, when field is generated and getter has parameters (see Memoize miniphase)
val setterRhs = if (vdef.rhs.isEmpty) EmptyTree else unitLiteral
val setter = cpy.DefDef(vdef)(
name = valName.setterName,
paramss = (setterParam :: Nil) :: Nil,
tpt = TypeTree(defn.UnitType),
rhs = setterRhs
).withMods((mods | Accessor) &~ (CaseAccessor | GivenOrImplicit | Lazy))
.dropEndMarker() // the end marker should only appear on the getter definition
name = valName.setterName,
paramss = (setterParam :: Nil) :: Nil,
tpt = TypeTree(defn.UnitType),
rhs = setterRhs
).withMods((vdef.mods | Accessor) &~ (CaseAccessor | GivenOrImplicit | Lazy))
.dropEndMarker() // the end marker should only appear on the getter definition
Thicket(vdef1, setter)
}
else vdef1
}
end valDef

def makeImplicitParameters(tpts: List[Tree], implicitFlag: FlagSet, forPrimaryConstructor: Boolean = false)(using Context): List[ValDef] =
for (tpt <- tpts) yield {
Expand Down Expand Up @@ -911,7 +921,7 @@ object desugar {
case params :: paramss1 => // `params` must have a single parameter and without `given` flag

def badRightAssoc(problem: String) =
report.error(i"right-associative extension method $problem", mdef.srcPos)
report.error(em"right-associative extension method $problem", mdef.srcPos)
extParamss ++ mdef.paramss

params match
Expand Down Expand Up @@ -1137,7 +1147,7 @@ object desugar {
def errorOnGivenBinding(bind: Bind)(using Context): Boolean =
report.error(
em"""${hl("given")} patterns are not allowed in a ${hl("val")} definition,
|please bind to an identifier and use an alias given.""".stripMargin, bind)
|please bind to an identifier and use an alias given.""", bind)
false

def isTuplePattern(arity: Int): Boolean = pat match {
Expand Down Expand Up @@ -1237,7 +1247,7 @@ object desugar {
def checkOpaqueAlias(tree: MemberDef)(using Context): MemberDef =
def check(rhs: Tree): MemberDef = rhs match
case bounds: TypeBoundsTree if bounds.alias.isEmpty =>
report.error(i"opaque type must have a right-hand side", tree.srcPos)
report.error(em"opaque type must have a right-hand side", tree.srcPos)
tree.withMods(tree.mods.withoutFlags(Opaque))
case LambdaTypeTree(_, body) => check(body)
case _ => tree
Expand Down
2 changes: 1 addition & 1 deletion tests/pos-with-compiler-cc/dotc/ast/DesugarEnums.scala
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ object DesugarEnums {
case Ident(name) =>
val matches = tparamNames.contains(name)
if (matches && (caseTypeParams.nonEmpty || vparamss.isEmpty))
report.error(i"illegal reference to type parameter $name from enum case", tree.srcPos)
report.error(em"illegal reference to type parameter $name from enum case", tree.srcPos)
matches
case LambdaTypeTree(lambdaParams, body) =>
underBinders(lambdaParams, foldOver(x, tree))
Expand Down
22 changes: 11 additions & 11 deletions tests/pos-with-compiler-cc/dotc/ast/MainProxies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ object MainProxies {

def addArgs(call: untpd.Tree, mt: MethodType, idx: Int): untpd.Tree =
if (mt.isImplicitMethod) {
report.error(s"@main method cannot have implicit parameters", pos)
report.error(em"@main method cannot have implicit parameters", pos)
call
}
else {
Expand All @@ -74,7 +74,7 @@ object MainProxies {
mt.resType match {
case restpe: MethodType =>
if (mt.paramInfos.lastOption.getOrElse(NoType).isRepeatedParam)
report.error(s"varargs parameter of @main method must come last", pos)
report.error(em"varargs parameter of @main method must come last", pos)
addArgs(call1, restpe, idx + args.length)
case _ =>
call1
Expand All @@ -83,17 +83,17 @@ object MainProxies {

var result: List[TypeDef] = Nil
if (!mainFun.owner.isStaticOwner)
report.error(s"@main method is not statically accessible", pos)
report.error(em"@main method is not statically accessible", pos)
else {
var call = ref(mainFun.termRef)
mainFun.info match {
case _: ExprType =>
case mt: MethodType =>
call = addArgs(call, mt, 0)
case _: PolyType =>
report.error(s"@main method cannot have type parameters", pos)
report.error(em"@main method cannot have type parameters", pos)
case _ =>
report.error(s"@main can only annotate a method", pos)
report.error(em"@main can only annotate a method", pos)
}
val errVar = Ident(nme.error)
val handler = CaseDef(
Expand Down Expand Up @@ -203,7 +203,7 @@ object MainProxies {
))
(sym, paramAnnotations.toVector, defaultValueSymbols(scope, sym), stat.rawComment) :: Nil
case mainAnnot :: others =>
report.error(s"method cannot have multiple main annotations", mainAnnot.tree)
report.error(em"method cannot have multiple main annotations", mainAnnot.tree)
Nil
}
case stat @ TypeDef(_, impl: Template) if stat.symbol.is(Module) =>
Expand Down Expand Up @@ -379,26 +379,26 @@ object MainProxies {
end generateMainClass

if (!mainFun.owner.isStaticOwner)
report.error(s"main method is not statically accessible", pos)
report.error(em"main method is not statically accessible", pos)
None
else mainFun.info match {
case _: ExprType =>
Some(generateMainClass(unitToValue(ref(mainFun.termRef)), Nil, Nil))
case mt: MethodType =>
if (mt.isImplicitMethod)
report.error(s"main method cannot have implicit parameters", pos)
report.error(em"main method cannot have implicit parameters", pos)
None
else mt.resType match
case restpe: MethodType =>
report.error(s"main method cannot be curried", pos)
report.error(em"main method cannot be curried", pos)
None
case _ =>
Some(generateMainClass(unitToValue(Apply(ref(mainFun.termRef), argRefs(mt))), argValDefs(mt), parameterInfos(mt)))
case _: PolyType =>
report.error(s"main method cannot have type parameters", pos)
report.error(em"main method cannot have type parameters", pos)
None
case _ =>
report.error(s"main can only annotate a method", pos)
report.error(em"main can only annotate a method", pos)
None
}
}
Expand Down
2 changes: 0 additions & 2 deletions tests/pos-with-compiler-cc/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,6 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
Some(meth)
case Block(Nil, expr) =>
unapply(expr)
case Inlined(_, bindings, expr) if bindings.forall(isPureBinding) =>
unapply(expr)
case _ =>
None
}
Expand Down
4 changes: 2 additions & 2 deletions tests/pos-with-compiler-cc/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ object Trees {
* nodes.
*/
abstract class Tree[+T <: Untyped](implicit @constructorOnly src: SourceFile)
extends Positioned, SrcPos, Product, Attachment.Container, printing.Showable, caps.Pure {
extends Positioned, SrcPos, Product, Attachment.Container, printing.Showable {

if (Stats.enabled) ntrees += 1

Expand Down Expand Up @@ -1747,7 +1747,7 @@ object Trees {
val denot = receiver.tpe.member(method)
if !denot.exists then
overload.println(i"members = ${receiver.tpe.decls}")
report.error(i"no member $receiver . $method", receiver.srcPos)
report.error(em"no member $receiver . $method", receiver.srcPos)
val selected =
if (denot.isOverloaded) {
def typeParamCount(tp: Type) = tp.widen match {
Expand Down
4 changes: 2 additions & 2 deletions tests/pos-with-compiler-cc/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
else
val res = Select(TypeTree(pre), tp)
if needLoad && !res.symbol.isStatic then
throw new TypeError(em"cannot establish a reference to $res")
throw TypeError(em"cannot establish a reference to $res")
res

def ref(sym: Symbol)(using Context): Tree =
Expand Down Expand Up @@ -1297,7 +1297,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
else if (tree.tpe.widen isRef numericCls)
tree
else {
report.warning(i"conversion from ${tree.tpe.widen} to ${numericCls.typeRef} will always fail at runtime.")
report.warning(em"conversion from ${tree.tpe.widen} to ${numericCls.typeRef} will always fail at runtime.")
Throw(New(defn.ClassCastExceptionClass.typeRef, Nil)).withSpan(tree.span)
}
}
Expand Down
8 changes: 8 additions & 0 deletions tests/pos-with-compiler-cc/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
case class ContextBounds(bounds: TypeBoundsTree, cxBounds: List[Tree])(implicit @constructorOnly src: SourceFile) extends TypTree
case class PatDef(mods: Modifiers, pats: List[Tree], tpt: Tree, rhs: Tree)(implicit @constructorOnly src: SourceFile) extends DefTree
case class ExtMethods(paramss: List[ParamClause], methods: List[Tree])(implicit @constructorOnly src: SourceFile) extends Tree
case class Into(tpt: Tree)(implicit @constructorOnly src: SourceFile) extends Tree
case class MacroTree(expr: Tree)(implicit @constructorOnly src: SourceFile) extends Tree

case class ImportSelector(imported: Ident, renamed: Tree = EmptyTree, bound: Tree = EmptyTree)(implicit @constructorOnly src: SourceFile) extends Tree {
Expand Down Expand Up @@ -651,6 +652,9 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
def ExtMethods(tree: Tree)(paramss: List[ParamClause], methods: List[Tree])(using Context): Tree = tree match
case tree: ExtMethods if (paramss eq tree.paramss) && (methods == tree.methods) => tree
case _ => finalize(tree, untpd.ExtMethods(paramss, methods)(tree.source))
def Into(tree: Tree)(tpt: Tree)(using Context): Tree = tree match
case tree: Into if tpt eq tree.tpt => tree
case _ => finalize(tree, untpd.Into(tpt)(tree.source))
def ImportSelector(tree: Tree)(imported: Ident, renamed: Tree, bound: Tree)(using Context): Tree = tree match {
case tree: ImportSelector if (imported eq tree.imported) && (renamed eq tree.renamed) && (bound eq tree.bound) => tree
case _ => finalize(tree, untpd.ImportSelector(imported, renamed, bound)(tree.source))
Expand Down Expand Up @@ -720,6 +724,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
cpy.PatDef(tree)(mods, transform(pats), transform(tpt), transform(rhs))
case ExtMethods(paramss, methods) =>
cpy.ExtMethods(tree)(transformParamss(paramss), transformSub(methods))
case Into(tpt) =>
cpy.Into(tree)(transform(tpt))
case ImportSelector(imported, renamed, bound) =>
cpy.ImportSelector(tree)(transformSub(imported), transform(renamed), transform(bound))
case Number(_, _) | TypedSplice(_) =>
Expand Down Expand Up @@ -780,6 +786,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
this(this(this(x, pats), tpt), rhs)
case ExtMethods(paramss, methods) =>
this(paramss.foldLeft(x)(apply), methods)
case Into(tpt) =>
this(x, tpt)
case ImportSelector(imported, renamed, bound) =>
this(this(this(x, imported), renamed), bound)
case Number(_, _) =>
Expand Down
4 changes: 2 additions & 2 deletions tests/pos-with-compiler-cc/dotc/cc/CaptureSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ object CaptureSet:
else CompareResult.fail(this)
}
.andAlso {
if (origin ne source) && mapIsIdempotent then
if (origin ne source) && (origin ne initial) && mapIsIdempotent then
// `tm` is idempotent, propagate back elems from image set.
// This is sound, since we know that for `r in newElems: tm(r) = r`, hence
// `r` is _one_ possible solution in `source` that would make an `r` appear in this set.
Expand All @@ -562,7 +562,7 @@ object CaptureSet:
// elements from variable sources in contra- and non-variant positions. In essence,
// we approximate types resulting from such maps by returning a possible super type
// from the actual type. But this is neither sound nor complete.
report.warning(i"trying to add elems ${CaptureSet(newElems)} from unrecognized source $origin of mapped set $this$whereCreated")
report.warning(em"trying to add elems ${CaptureSet(newElems)} from unrecognized source $origin of mapped set $this$whereCreated")
CompareResult.fail(this)
else
CompareResult.OK
Expand Down
Loading