Skip to content

Commit a4fd953

Browse files
committed
Copy current version of compiler to tests
1 parent e25362d commit a4fd953

File tree

150 files changed

+4925
-4082
lines changed

Some content is hidden

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

150 files changed

+4925
-4082
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/Run.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import java.nio.charset.StandardCharsets
3131
import scala.collection.mutable
3232
import scala.util.control.NonFatal
3333
import scala.io.Codec
34-
import caps.unsafe.unsafeUnbox
3534

3635
/** A compiler run. Exports various methods to compile source files */
3736
class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with ConstraintRunInfo {
@@ -271,7 +270,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
271270
Rewrites.writeBack()
272271
suppressions.runFinished(hasErrors = ctx.reporter.hasErrors)
273272
while (finalizeActions.nonEmpty) {
274-
val action = finalizeActions.remove(0).unsafeUnbox
273+
val action = finalizeActions.remove(0)
275274
action()
276275
}
277276
compiling = false

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

Lines changed: 33 additions & 26 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 {
@@ -673,7 +683,7 @@ object desugar {
673683
else (Nil, Nil)
674684
}
675685

676-
var parents1: List[untpd.Tree] = parents // !cc! need explicit type to make capture checking pass
686+
var parents1 = parents
677687
if (isEnumCase && parents.isEmpty)
678688
parents1 = enumClassTypeRef :: Nil
679689
if (isNonEnumCase)
@@ -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
@@ -1779,10 +1789,7 @@ object desugar {
17791789
val elems = segments flatMap {
17801790
case ts: Thicket => ts.trees.tail
17811791
case t => Nil
1782-
} map { (t: Tree) => t match
1783-
// !cc! explicitly typed parameter (t: Tree) is needed since otherwise
1784-
// we get an error similar to #16268. (The explicit type constrains the type of `segments`
1785-
// which is otherwise List[{*} tree])
1792+
} map {
17861793
case Block(Nil, EmptyTree) => Literal(Constant(())) // for s"... ${} ..."
17871794
case Block(Nil, expr) => expr // important for interpolated string as patterns, see i1773.scala
17881795
case t => t

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/Positioned.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import annotation.internal.sharable
1515

1616
/** A base class for things that have positions (currently: modifiers and trees)
1717
*/
18-
abstract class Positioned(implicit @constructorOnly src: SourceFile) extends SrcPos, Product, Cloneable, caps.Pure {
18+
abstract class Positioned(implicit @constructorOnly src: SourceFile) extends SrcPos, Product, Cloneable {
1919
import Positioned.{ids, nextId, debugId}
2020

2121
private var mySpan: Span = _

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/TreeTypeMap.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import Types._, Contexts._, Flags._
77
import Symbols._, Annotations._, Trees._, Symbols._, Constants.Constant
88
import Decorators._
99
import dotty.tools.dotc.transform.SymUtils._
10-
import language.experimental.pureFunctions
1110

1211
/** A map that applies three functions and a substitution together to a tree and
1312
* makes sure they are coordinated so that the result is well-typed. The functions are
@@ -33,8 +32,8 @@ import language.experimental.pureFunctions
3332
* set, we would get a data race assertion error.
3433
*/
3534
class TreeTypeMap(
36-
val typeMap: Type -> Type = IdentityTypeMap,
37-
val treeMap: tpd.Tree -> tpd.Tree = identity[tpd.Tree](_), // !cc! need explicit instantiation of default argument
35+
val typeMap: Type => Type = IdentityTypeMap,
36+
val treeMap: tpd.Tree => tpd.Tree = identity _,
3837
val oldOwners: List[Symbol] = Nil,
3938
val newOwners: List[Symbol] = Nil,
4039
val substFrom: List[Symbol] = Nil,
@@ -43,8 +42,8 @@ class TreeTypeMap(
4342
import tpd._
4443

4544
def copy(
46-
typeMap: Type -> Type,
47-
treeMap: tpd.Tree -> tpd.Tree,
45+
typeMap: Type => Type,
46+
treeMap: tpd.Tree => tpd.Tree,
4847
oldOwners: List[Symbol],
4948
newOwners: List[Symbol],
5049
substFrom: List[Symbol],

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import annotation.unchecked.uncheckedVariance
1717
import annotation.constructorOnly
1818
import compiletime.uninitialized
1919
import Decorators._
20-
import annotation.retains
21-
import language.experimental.pureFunctions
2220

2321
object Trees {
2422

@@ -49,7 +47,7 @@ object Trees {
4947
* nodes.
5048
*/
5149
abstract class Tree[+T <: Untyped](implicit @constructorOnly src: SourceFile)
52-
extends Positioned, SrcPos, Product, Attachment.Container, printing.Showable, caps.Pure {
50+
extends Positioned, SrcPos, Product, Attachment.Container, printing.Showable {
5351

5452
if (Stats.enabled) ntrees += 1
5553

@@ -433,7 +431,7 @@ object Trees {
433431
def isBackquoted: Boolean = hasAttachment(Backquoted)
434432
}
435433

436-
class SearchFailureIdent[+T <: Untyped] private[ast] (name: Name, expl: -> String)(implicit @constructorOnly src: SourceFile)
434+
class SearchFailureIdent[+T <: Untyped] private[ast] (name: Name, expl: => String)(implicit @constructorOnly src: SourceFile)
437435
extends Ident[T](name) {
438436
def explanation = expl
439437
override def toString: String = s"SearchFailureIdent($explanation)"
@@ -1520,7 +1518,7 @@ object Trees {
15201518
}
15211519
}
15221520

1523-
abstract class TreeAccumulator[X] { self: TreeAccumulator[X] @retains(caps.*) =>
1521+
abstract class TreeAccumulator[X] { self =>
15241522
// Ties the knot of the traversal: call `foldOver(x, tree))` to dive in the `tree` node.
15251523
def apply(x: X, tree: Tree)(using Context): X
15261524

@@ -1747,7 +1745,7 @@ object Trees {
17471745
val denot = receiver.tpe.member(method)
17481746
if !denot.exists then
17491747
overload.println(i"members = ${receiver.tpe.decls}")
1750-
report.error(i"no member $receiver . $method", receiver.srcPos)
1748+
report.error(em"no member $receiver . $method", receiver.srcPos)
17511749
val selected =
17521750
if (denot.isOverloaded) {
17531751
def typeParamCount(tp: Type) = tp.widen match {

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import typer.ConstFold
1818

1919
import scala.annotation.tailrec
2020
import scala.collection.mutable.ListBuffer
21-
import language.experimental.pureFunctions
2221

2322
/** Some creators for typed trees */
2423
object tpd extends Trees.Instance[Type] with TypedTreeInfo {
@@ -429,7 +428,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
429428
else
430429
val res = Select(TypeTree(pre), tp)
431430
if needLoad && !res.symbol.isStatic then
432-
throw new TypeError(em"cannot establish a reference to $res")
431+
throw TypeError(em"cannot establish a reference to $res")
433432
res
434433

435434
def ref(sym: Symbol)(using Context): Tree =
@@ -1297,7 +1296,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
12971296
else if (tree.tpe.widen isRef numericCls)
12981297
tree
12991298
else {
1300-
report.warning(i"conversion from ${tree.tpe.widen} to ${numericCls.typeRef} will always fail at runtime.")
1299+
report.warning(em"conversion from ${tree.tpe.widen} to ${numericCls.typeRef} will always fail at runtime.")
13011300
Throw(New(defn.ClassCastExceptionClass.typeRef, Nil)).withSpan(tree.span)
13021301
}
13031302
}
@@ -1455,7 +1454,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
14551454
* @return The symbols imported.
14561455
*/
14571456
def importedSymbols(imp: Import,
1458-
selectorPredicate: untpd.ImportSelector -> Boolean = util.common.alwaysTrue)
1457+
selectorPredicate: untpd.ImportSelector => Boolean = util.common.alwaysTrue)
14591458
(using Context): List[Symbol] =
14601459
imp.selectors.find(selectorPredicate) match
14611460
case Some(sel) => importedSymbols(imp.expr, sel.name)

0 commit comments

Comments
 (0)