Skip to content

Commit ef8cc3e

Browse files
authored
CC-UPDATE: Update test compiler to latest version (#16413)
2 parents ce38da4 + a6749fa commit ef8cc3e

File tree

107 files changed

+4721
-3788
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+4721
-3788
lines changed

tests/pos-with-compiler-cc/dotc/CompilationUnit.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ object CompilationUnit {
131131
if (!mustExist)
132132
source
133133
else if (source.file.isDirectory) {
134-
report.error(s"expected file, received directory '${source.file.path}'")
134+
report.error(em"expected file, received directory '${source.file.path}'")
135135
NoSource
136136
}
137137
else if (!source.file.exists) {
138-
report.error(s"source file not found: ${source.file.path}")
138+
report.error(em"source file not found: ${source.file.path}")
139139
NoSource
140140
}
141141
else source

tests/pos-with-compiler-cc/dotc/Driver.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,18 @@ class Driver {
9494
val newEntries: List[String] = files
9595
.flatMap { file =>
9696
if !file.exists then
97-
report.error(s"File does not exist: ${file.path}")
97+
report.error(em"File does not exist: ${file.path}")
9898
None
9999
else file.extension match
100100
case "jar" => Some(file.path)
101101
case "tasty" =>
102102
TastyFileUtil.getClassPath(file) match
103103
case Some(classpath) => Some(classpath)
104104
case _ =>
105-
report.error(s"Could not load classname from: ${file.path}")
105+
report.error(em"Could not load classname from: ${file.path}")
106106
None
107107
case _ =>
108-
report.error(s"File extension is not `tasty` or `jar`: ${file.path}")
108+
report.error(em"File extension is not `tasty` or `jar`: ${file.path}")
109109
None
110110
}
111111
.distinct

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

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import core._
66
import util.Spans._, Types._, Contexts._, Constants._, Names._, NameOps._, Flags._
77
import Symbols._, StdNames._, Trees._, ContextOps._
88
import Decorators._, transform.SymUtils._
9+
import Annotations.Annotation
910
import NameKinds.{UniqueName, EvidenceParamName, DefaultGetterName, WildcardParamName}
1011
import typer.{Namer, Checking}
1112
import util.{Property, SourceFile, SourcePosition, Chars}
@@ -117,7 +118,7 @@ object desugar {
117118
if (local.exists) (defctx.owner.thisType select local).dealiasKeepAnnots
118119
else {
119120
def msg =
120-
s"no matching symbol for ${tp.symbol.showLocated} in ${defctx.owner} / ${defctx.effectiveScope.toList}"
121+
em"no matching symbol for ${tp.symbol.showLocated} in ${defctx.owner} / ${defctx.effectiveScope.toList}"
121122
ErrorType(msg).assertingErrorsReported(msg)
122123
}
123124
case _ =>
@@ -165,32 +166,41 @@ object desugar {
165166
*
166167
* Generate setter where needed
167168
*/
168-
def valDef(vdef0: ValDef)(using Context): Tree = {
169+
def valDef(vdef0: ValDef)(using Context): Tree =
169170
val vdef @ ValDef(_, tpt, rhs) = vdef0
170-
val mods = vdef.mods
171-
172171
val valName = normalizeName(vdef, tpt).asTermName
173-
val vdef1 = cpy.ValDef(vdef)(name = valName)
172+
var mods1 = vdef.mods
173+
174+
def dropInto(tpt: Tree): Tree = tpt match
175+
case Into(tpt1) =>
176+
mods1 = vdef.mods.withAddedAnnotation(
177+
TypedSplice(
178+
Annotation(defn.AllowConversionsAnnot).tree.withSpan(tpt.span.startPos)))
179+
tpt1
180+
case ByNameTypeTree(tpt1) =>
181+
cpy.ByNameTypeTree(tpt)(dropInto(tpt1))
182+
case PostfixOp(tpt1, op) if op.name == tpnme.raw.STAR =>
183+
cpy.PostfixOp(tpt)(dropInto(tpt1), op)
184+
case _ =>
185+
tpt
186+
187+
val vdef1 = cpy.ValDef(vdef)(name = valName, tpt = dropInto(tpt))
188+
.withMods(mods1)
174189

175-
if (isSetterNeeded(vdef)) {
176-
// TODO: copy of vdef as getter needed?
177-
// val getter = ValDef(mods, name, tpt, rhs) withPos vdef.pos?
178-
// right now vdef maps via expandedTree to a thicket which concerns itself.
179-
// I don't see a problem with that but if there is one we can avoid it by making a copy here.
190+
if isSetterNeeded(vdef) then
180191
val setterParam = makeSyntheticParameter(tpt = SetterParamTree().watching(vdef))
181192
// The rhs gets filled in later, when field is generated and getter has parameters (see Memoize miniphase)
182193
val setterRhs = if (vdef.rhs.isEmpty) EmptyTree else unitLiteral
183194
val setter = cpy.DefDef(vdef)(
184-
name = valName.setterName,
185-
paramss = (setterParam :: Nil) :: Nil,
186-
tpt = TypeTree(defn.UnitType),
187-
rhs = setterRhs
188-
).withMods((mods | Accessor) &~ (CaseAccessor | GivenOrImplicit | Lazy))
189-
.dropEndMarker() // the end marker should only appear on the getter definition
195+
name = valName.setterName,
196+
paramss = (setterParam :: Nil) :: Nil,
197+
tpt = TypeTree(defn.UnitType),
198+
rhs = setterRhs
199+
).withMods((vdef.mods | Accessor) &~ (CaseAccessor | GivenOrImplicit | Lazy))
200+
.dropEndMarker() // the end marker should only appear on the getter definition
190201
Thicket(vdef1, setter)
191-
}
192202
else vdef1
193-
}
203+
end valDef
194204

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

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

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

11431153
def isTuplePattern(arity: Int): Boolean = pat match {
@@ -1237,7 +1247,7 @@ object desugar {
12371247
def checkOpaqueAlias(tree: MemberDef)(using Context): MemberDef =
12381248
def check(rhs: Tree): MemberDef = rhs match
12391249
case bounds: TypeBoundsTree if bounds.alias.isEmpty =>
1240-
report.error(i"opaque type must have a right-hand side", tree.srcPos)
1250+
report.error(em"opaque type must have a right-hand side", tree.srcPos)
12411251
tree.withMods(tree.mods.withoutFlags(Opaque))
12421252
case LambdaTypeTree(_, body) => check(body)
12431253
case _ => tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ object DesugarEnums {
216216
case Ident(name) =>
217217
val matches = tparamNames.contains(name)
218218
if (matches && (caseTypeParams.nonEmpty || vparamss.isEmpty))
219-
report.error(i"illegal reference to type parameter $name from enum case", tree.srcPos)
219+
report.error(em"illegal reference to type parameter $name from enum case", tree.srcPos)
220220
matches
221221
case LambdaTypeTree(lambdaParams, body) =>
222222
underBinders(lambdaParams, foldOver(x, tree))

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ object MainProxies {
5656

5757
def addArgs(call: untpd.Tree, mt: MethodType, idx: Int): untpd.Tree =
5858
if (mt.isImplicitMethod) {
59-
report.error(s"@main method cannot have implicit parameters", pos)
59+
report.error(em"@main method cannot have implicit parameters", pos)
6060
call
6161
}
6262
else {
@@ -74,7 +74,7 @@ object MainProxies {
7474
mt.resType match {
7575
case restpe: MethodType =>
7676
if (mt.paramInfos.lastOption.getOrElse(NoType).isRepeatedParam)
77-
report.error(s"varargs parameter of @main method must come last", pos)
77+
report.error(em"varargs parameter of @main method must come last", pos)
7878
addArgs(call1, restpe, idx + args.length)
7979
case _ =>
8080
call1
@@ -83,17 +83,17 @@ object MainProxies {
8383

8484
var result: List[TypeDef] = Nil
8585
if (!mainFun.owner.isStaticOwner)
86-
report.error(s"@main method is not statically accessible", pos)
86+
report.error(em"@main method is not statically accessible", pos)
8787
else {
8888
var call = ref(mainFun.termRef)
8989
mainFun.info match {
9090
case _: ExprType =>
9191
case mt: MethodType =>
9292
call = addArgs(call, mt, 0)
9393
case _: PolyType =>
94-
report.error(s"@main method cannot have type parameters", pos)
94+
report.error(em"@main method cannot have type parameters", pos)
9595
case _ =>
96-
report.error(s"@main can only annotate a method", pos)
96+
report.error(em"@main can only annotate a method", pos)
9797
}
9898
val errVar = Ident(nme.error)
9999
val handler = CaseDef(
@@ -203,7 +203,7 @@ object MainProxies {
203203
))
204204
(sym, paramAnnotations.toVector, defaultValueSymbols(scope, sym), stat.rawComment) :: Nil
205205
case mainAnnot :: others =>
206-
report.error(s"method cannot have multiple main annotations", mainAnnot.tree)
206+
report.error(em"method cannot have multiple main annotations", mainAnnot.tree)
207207
Nil
208208
}
209209
case stat @ TypeDef(_, impl: Template) if stat.symbol.is(Module) =>
@@ -379,26 +379,26 @@ object MainProxies {
379379
end generateMainClass
380380

381381
if (!mainFun.owner.isStaticOwner)
382-
report.error(s"main method is not statically accessible", pos)
382+
report.error(em"main method is not statically accessible", pos)
383383
None
384384
else mainFun.info match {
385385
case _: ExprType =>
386386
Some(generateMainClass(unitToValue(ref(mainFun.termRef)), Nil, Nil))
387387
case mt: MethodType =>
388388
if (mt.isImplicitMethod)
389-
report.error(s"main method cannot have implicit parameters", pos)
389+
report.error(em"main method cannot have implicit parameters", pos)
390390
None
391391
else mt.resType match
392392
case restpe: MethodType =>
393-
report.error(s"main method cannot be curried", pos)
393+
report.error(em"main method cannot be curried", pos)
394394
None
395395
case _ =>
396396
Some(generateMainClass(unitToValue(Apply(ref(mainFun.termRef), argRefs(mt))), argValDefs(mt), parameterInfos(mt)))
397397
case _: PolyType =>
398-
report.error(s"main method cannot have type parameters", pos)
398+
report.error(em"main method cannot have type parameters", pos)
399399
None
400400
case _ =>
401-
report.error(s"main can only annotate a method", pos)
401+
report.error(em"main can only annotate a method", pos)
402402
None
403403
}
404404
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,6 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
743743
Some(meth)
744744
case Block(Nil, expr) =>
745745
unapply(expr)
746-
case Inlined(_, bindings, expr) if bindings.forall(isPureBinding) =>
747-
unapply(expr)
748746
case _ =>
749747
None
750748
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ object Trees {
4949
* nodes.
5050
*/
5151
abstract class Tree[+T <: Untyped](implicit @constructorOnly src: SourceFile)
52-
extends Positioned, SrcPos, Product, Attachment.Container, printing.Showable, caps.Pure {
52+
extends Positioned, SrcPos, Product, Attachment.Container, printing.Showable {
5353

5454
if (Stats.enabled) ntrees += 1
5555

@@ -1747,7 +1747,7 @@ object Trees {
17471747
val denot = receiver.tpe.member(method)
17481748
if !denot.exists then
17491749
overload.println(i"members = ${receiver.tpe.decls}")
1750-
report.error(i"no member $receiver . $method", receiver.srcPos)
1750+
report.error(em"no member $receiver . $method", receiver.srcPos)
17511751
val selected =
17521752
if (denot.isOverloaded) {
17531753
def typeParamCount(tp: Type) = tp.widen match {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
429429
else
430430
val res = Select(TypeTree(pre), tp)
431431
if needLoad && !res.symbol.isStatic then
432-
throw new TypeError(em"cannot establish a reference to $res")
432+
throw TypeError(em"cannot establish a reference to $res")
433433
res
434434

435435
def ref(sym: Symbol)(using Context): Tree =
@@ -1297,7 +1297,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
12971297
else if (tree.tpe.widen isRef numericCls)
12981298
tree
12991299
else {
1300-
report.warning(i"conversion from ${tree.tpe.widen} to ${numericCls.typeRef} will always fail at runtime.")
1300+
report.warning(em"conversion from ${tree.tpe.widen} to ${numericCls.typeRef} will always fail at runtime.")
13011301
Throw(New(defn.ClassCastExceptionClass.typeRef, Nil)).withSpan(tree.span)
13021302
}
13031303
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
119119
case class ContextBounds(bounds: TypeBoundsTree, cxBounds: List[Tree])(implicit @constructorOnly src: SourceFile) extends TypTree
120120
case class PatDef(mods: Modifiers, pats: List[Tree], tpt: Tree, rhs: Tree)(implicit @constructorOnly src: SourceFile) extends DefTree
121121
case class ExtMethods(paramss: List[ParamClause], methods: List[Tree])(implicit @constructorOnly src: SourceFile) extends Tree
122+
case class Into(tpt: Tree)(implicit @constructorOnly src: SourceFile) extends Tree
122123
case class MacroTree(expr: Tree)(implicit @constructorOnly src: SourceFile) extends Tree
123124

124125
case class ImportSelector(imported: Ident, renamed: Tree = EmptyTree, bound: Tree = EmptyTree)(implicit @constructorOnly src: SourceFile) extends Tree {
@@ -651,6 +652,9 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
651652
def ExtMethods(tree: Tree)(paramss: List[ParamClause], methods: List[Tree])(using Context): Tree = tree match
652653
case tree: ExtMethods if (paramss eq tree.paramss) && (methods == tree.methods) => tree
653654
case _ => finalize(tree, untpd.ExtMethods(paramss, methods)(tree.source))
655+
def Into(tree: Tree)(tpt: Tree)(using Context): Tree = tree match
656+
case tree: Into if tpt eq tree.tpt => tree
657+
case _ => finalize(tree, untpd.Into(tpt)(tree.source))
654658
def ImportSelector(tree: Tree)(imported: Ident, renamed: Tree, bound: Tree)(using Context): Tree = tree match {
655659
case tree: ImportSelector if (imported eq tree.imported) && (renamed eq tree.renamed) && (bound eq tree.bound) => tree
656660
case _ => finalize(tree, untpd.ImportSelector(imported, renamed, bound)(tree.source))
@@ -720,6 +724,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
720724
cpy.PatDef(tree)(mods, transform(pats), transform(tpt), transform(rhs))
721725
case ExtMethods(paramss, methods) =>
722726
cpy.ExtMethods(tree)(transformParamss(paramss), transformSub(methods))
727+
case Into(tpt) =>
728+
cpy.Into(tree)(transform(tpt))
723729
case ImportSelector(imported, renamed, bound) =>
724730
cpy.ImportSelector(tree)(transformSub(imported), transform(renamed), transform(bound))
725731
case Number(_, _) | TypedSplice(_) =>
@@ -780,6 +786,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
780786
this(this(this(x, pats), tpt), rhs)
781787
case ExtMethods(paramss, methods) =>
782788
this(paramss.foldLeft(x)(apply), methods)
789+
case Into(tpt) =>
790+
this(x, tpt)
783791
case ImportSelector(imported, renamed, bound) =>
784792
this(this(this(x, imported), renamed), bound)
785793
case Number(_, _) =>

tests/pos-with-compiler-cc/dotc/cc/CaptureSet.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ object CaptureSet:
549549
else CompareResult.fail(this)
550550
}
551551
.andAlso {
552-
if (origin ne source) && mapIsIdempotent then
552+
if (origin ne source) && (origin ne initial) && mapIsIdempotent then
553553
// `tm` is idempotent, propagate back elems from image set.
554554
// This is sound, since we know that for `r in newElems: tm(r) = r`, hence
555555
// `r` is _one_ possible solution in `source` that would make an `r` appear in this set.
@@ -562,7 +562,7 @@ object CaptureSet:
562562
// elements from variable sources in contra- and non-variant positions. In essence,
563563
// we approximate types resulting from such maps by returning a possible super type
564564
// from the actual type. But this is neither sound nor complete.
565-
report.warning(i"trying to add elems ${CaptureSet(newElems)} from unrecognized source $origin of mapped set $this$whereCreated")
565+
report.warning(em"trying to add elems ${CaptureSet(newElems)} from unrecognized source $origin of mapped set $this$whereCreated")
566566
CompareResult.fail(this)
567567
else
568568
CompareResult.OK

0 commit comments

Comments
 (0)