Skip to content

Commit 8f485dc

Browse files
committed
merge upstream changes
2 parents 4edb70f + 898d62b commit 8f485dc

File tree

143 files changed

+943
-711
lines changed

Some content is hidden

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

143 files changed

+943
-711
lines changed

community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def exec(projectDir: Path, binary: String, arguments: String*): Int =
3131
exitCode
3232

3333

34-
sealed trait CommunityProject
34+
sealed trait CommunityProject:
3535
private var published = false
3636

3737
val project: String
@@ -77,17 +77,23 @@ sealed trait CommunityProject
7777
published = true
7878
end CommunityProject
7979

80-
final case class MillCommunityProject(project: String, baseCommand: String,
81-
dependencies: List[CommunityProject] = Nil) extends CommunityProject
80+
final case class MillCommunityProject(
81+
project: String,
82+
baseCommand: String,
83+
dependencies: List[CommunityProject] = Nil) extends CommunityProject:
8284
override val binaryName: String = "./mill"
8385
override val updateCommand = s"$baseCommand.compileClasspath"
8486
override val testCommand = s"$baseCommand.test"
8587
override val publishCommand = s"$baseCommand.publishLocal"
8688
override val runCommandsArgs = List("-i", "-D", s"dottyVersion=$compilerVersion")
8789

88-
final case class SbtCommunityProject(project: String, sbtTestCommand: String,
89-
sbtUpdateCommand: String, extraSbtArgs: List[String] = Nil,
90-
dependencies: List[CommunityProject] = Nil, sbtPublishCommand: String = null) extends CommunityProject
90+
final case class SbtCommunityProject(
91+
project: String,
92+
sbtTestCommand: String,
93+
sbtUpdateCommand: String,
94+
extraSbtArgs: List[String] = Nil,
95+
dependencies: List[CommunityProject] = Nil,
96+
sbtPublishCommand: String = null) extends CommunityProject:
9197
override val binaryName: String = "sbt"
9298
private val baseCommand = s";clean ;set updateOptions in Global ~= (_.withLatestSnapshots(false)) ;++$compilerVersion! "
9399
override val testCommand = s"$baseCommand$sbtTestCommand"
@@ -103,7 +109,7 @@ final case class SbtCommunityProject(project: String, sbtTestCommand: String,
103109
"-sbt-version", "1.3.6",
104110
s"--addPluginSbtFile=$sbtPluginFilePath")
105111

106-
object projects
112+
object projects:
107113
lazy val utest = MillCommunityProject(
108114
project = "utest",
109115
baseCommand = s"utest.jvm[$compilerVersion]",
@@ -271,7 +277,7 @@ object projects
271277
end projects
272278

273279
@Category(Array(classOf[TestCategory]))
274-
class CommunityBuildTest {
280+
class CommunityBuildTest:
275281
given CommunityBuildTest = this
276282

277283
/** Build the given project with the published local compiler and sbt plugin.
@@ -342,7 +348,7 @@ class CommunityBuildTest {
342348
@Test def effpi = projects.effpi.run()
343349
@Test def sconfig = projects.sconfig.run()
344350
@Test def zio = projects.zio.run()
345-
}
351+
end CommunityBuildTest
346352

347353
class TestCategory
348354
class UpdateCategory

compiler/src/dotty/tools/dotc/CompilationUnit.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class CompilationUnit protected (val source: SourceFile) {
4343

4444
var suspended: Boolean = false
4545

46-
def suspend()(given ctx: Context): Nothing =
46+
def suspend()(using ctx: Context): Nothing =
4747
if !suspended then
4848
if (ctx.settings.XprintSuspension.value)
4949
ctx.echo(i"suspended: $this")
@@ -57,7 +57,7 @@ class CompilationUnit protected (val source: SourceFile) {
5757
* that can be tracked for being not null to the list of spans of assignments
5858
* to these variables.
5959
*/
60-
def assignmentSpans(given Context): Map[Int, List[Span]] =
60+
def assignmentSpans(using Context): Map[Int, List[Span]] =
6161
if myAssignmentSpans == null then myAssignmentSpans = Nullables.assignmentSpans
6262
myAssignmentSpans
6363
}

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ object desugar {
488488
if (isEnum) {
489489
val (enumCases, enumStats) = stats.partition(DesugarEnums.isEnumCase)
490490
if (enumCases.isEmpty)
491-
ctx.error("Enumerations must contain at least one case", namePos)
491+
ctx.error(EnumerationsShouldNotBeEmpty(cdef), namePos)
492492
val enumCompanionRef = TermRefTree()
493493
val enumImport =
494494
Import(enumCompanionRef, enumCases.flatMap(caseIds).map(ImportSelector(_)))
@@ -883,12 +883,12 @@ object desugar {
883883
def flagSourcePos(flag: FlagSet) = mods.mods.find(_.flags == flag).fold(mdef.sourcePos)(_.sourcePos)
884884

885885
if (mods.is(Abstract))
886-
ctx.error(em"${hl("abstract")} modifier cannot be used for objects", flagSourcePos(Abstract))
886+
ctx.error(AbstractCannotBeUsedForObjects(mdef), flagSourcePos(Abstract))
887887
if (mods.is(Sealed))
888-
ctx.error(em"${hl("sealed")} modifier is redundant for objects", flagSourcePos(Sealed))
888+
ctx.error(ModifierRedundantForObjects(mdef, "sealed"), flagSourcePos(Sealed))
889889
// Maybe this should be an error; see https://github.com/scala/bug/issues/11094.
890890
if (mods.is(Final) && !mods.is(Synthetic))
891-
ctx.warning(em"${hl("final")} modifier is redundant for objects", flagSourcePos(Final))
891+
ctx.warning(ModifierRedundantForObjects(mdef, "final"), flagSourcePos(Final))
892892

893893
if (mods.is(Package))
894894
packageModuleDef(mdef)
@@ -929,7 +929,7 @@ object desugar {
929929
*/
930930

931931
def makeExtensionDef(mdef: Tree, tparams: List[TypeDef], leadingParams: List[ValDef],
932-
givenParamss: List[List[ValDef]])(given ctx: Context): Tree = {
932+
givenParamss: List[List[ValDef]])(using ctx: Context): Tree = {
933933
val allowed = "allowed here, since collective parameters are given"
934934
mdef match {
935935
case mdef: DefDef =>
@@ -986,7 +986,7 @@ object desugar {
986986
}
987987

988988
/** Invent a name for an anonympus given or extension of type or template `impl`. */
989-
def inventGivenOrExtensionName(impl: Tree)(given ctx: Context): SimpleName =
989+
def inventGivenOrExtensionName(impl: Tree)(using ctx: Context): SimpleName =
990990
val str = impl match
991991
case impl: Template =>
992992
if impl.parents.isEmpty then
@@ -1253,7 +1253,7 @@ object desugar {
12531253
else Apply(ref(tupleTypeRef.classSymbol.companionModule.termRef), ts)
12541254
}
12551255

1256-
private def isTopLevelDef(stat: Tree)(given Context): Boolean = stat match
1256+
private def isTopLevelDef(stat: Tree)(using Context): Boolean = stat match
12571257
case _: ValDef | _: PatDef | _: DefDef | _: Export => true
12581258
case stat: ModuleDef =>
12591259
stat.mods.isOneOf(GivenOrImplicit)

compiler/src/dotty/tools/dotc/ast/MainProxies.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import ast.Trees._
2626
*/
2727
object MainProxies {
2828

29-
def mainProxies(stats: List[tpd.Tree])(given Context): List[untpd.Tree] = {
29+
def mainProxies(stats: List[tpd.Tree])(using Context): List[untpd.Tree] = {
3030
import tpd._
3131
def mainMethods(stats: List[Tree]): List[Symbol] = stats.flatMap {
3232
case stat: DefDef if stat.symbol.hasAnnotation(defn.MainAnnot) =>
@@ -40,7 +40,7 @@ object MainProxies {
4040
}
4141

4242
import untpd._
43-
def mainProxy(mainFun: Symbol)(given ctx: Context): List[TypeDef] = {
43+
def mainProxy(mainFun: Symbol)(using ctx: Context): List[TypeDef] = {
4444
val mainAnnotSpan = mainFun.getAnnotation(defn.MainAnnot).get.tree.span
4545
def pos = mainFun.sourcePos
4646
val argsRef = Ident(nme.args)

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,10 +869,10 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
869869
* A not-null assertion for reference `x` has the form `x.$asInstanceOf$[x.type & T]`.
870870
*/
871871
object AssertNotNull with
872-
def apply(tree: tpd.Tree, tpnn: Type)(given Context): tpd.Tree =
872+
def apply(tree: tpd.Tree, tpnn: Type)(using Context): tpd.Tree =
873873
tree.select(defn.Any_typeCast).appliedToType(AndType(tree.tpe, tpnn))
874874

875-
def unapply(tree: tpd.TypeApply)(given Context): Option[tpd.Tree] = tree match
875+
def unapply(tree: tpd.TypeApply)(using Context): Option[tpd.Tree] = tree match
876876
case TypeApply(Select(qual: RefTree, nme.asInstanceOfPM), arg :: Nil) =>
877877
arg.tpe match
878878
case AndType(ref, _) if qual.tpe eq ref => Some(qual)

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
878878
Apply(tree, args)
879879

880880
/** An applied node that accepts only varargs as arguments */
881-
def appliedToVarargs(args: List[Tree], tpt: Tree)(given Context): Tree =
881+
def appliedToVarargs(args: List[Tree], tpt: Tree)(using Context): Tree =
882882
appliedTo(repeated(args, tpt))
883883

884884
/** The current tree applied to given argument lists:
@@ -1378,7 +1378,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
13781378
/** Convert a list of trees to a vararg-compatible tree.
13791379
* Used to make arguments for methods that accept varargs.
13801380
*/
1381-
def repeated(trees: List[Tree], tpt: Tree)(given ctx: Context): Tree =
1381+
def repeated(trees: List[Tree], tpt: Tree)(using ctx: Context): Tree =
13821382
ctx.typeAssigner.arrayToRepeated(JavaSeqLiteral(trees, tpt))
13831383

13841384
/** Create a tree representing a list containing all
@@ -1390,7 +1390,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
13901390
* @param tpe the type of the elements of the resulting list.
13911391
*
13921392
*/
1393-
def mkList(trees: List[Tree], tpe: Tree)(given Context): Tree =
1393+
def mkList(trees: List[Tree], tpe: Tree)(using Context): Tree =
13941394
ref(defn.ListModule).select(nme.apply)
13951395
.appliedToTypeTree(tpe)
13961396
.appliedToVarargs(trees, tpe)

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
246246
* describe the core of a construct whereas the existing set are the modifiers
247247
* given in the source.
248248
*/
249-
def withAddedFlags(flags: FlagSet, span: Span)(given ctx: Context): Modifiers =
249+
def withAddedFlags(flags: FlagSet, span: Span)(using ctx: Context): Modifiers =
250250
if this.flags.isAllOf(flags) then this
251251
else if compatible(this.flags, flags) then this | flags
252252
else

compiler/src/dotty/tools/dotc/config/Config.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,6 @@ object Config {
160160
/** Assume -indent by default */
161161
final val defaultIndent = true
162162

163-
/** Assume indentation is significant after a class, object, ... signature */
164-
final val silentTemplateIndent = true
165-
166163
/** If set, prints a trace of all symbol completions */
167164
final val showCompletions = false
168165

compiler/src/dotty/tools/dotc/core/Annotations.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import util.Spans.Span
1010

1111
object Annotations {
1212

13-
def annotClass(tree: Tree)(given Context) =
13+
def annotClass(tree: Tree)(using Context) =
1414
if (tree.symbol.isConstructor) tree.symbol.owner
1515
else tree.tpe.typeSymbol
1616

@@ -118,25 +118,25 @@ object Annotations {
118118
apply(New(atp, args))
119119

120120
/** Create an annotation where the tree is computed lazily. */
121-
def deferred(sym: Symbol)(treeFn: (given Context) => Tree)(implicit ctx: Context): Annotation =
121+
def deferred(sym: Symbol)(treeFn: Context ?=> Tree)(implicit ctx: Context): Annotation =
122122
new LazyAnnotation {
123123
override def symbol(implicit ctx: Context): Symbol = sym
124-
def complete(implicit ctx: Context) = treeFn(given ctx)
124+
def complete(implicit ctx: Context) = treeFn(using ctx)
125125
}
126126

127127
/** Create an annotation where the symbol and the tree are computed lazily. */
128-
def deferredSymAndTree(symf: (given Context) => Symbol)(treeFn: (given Context) => Tree)(implicit ctx: Context): Annotation =
128+
def deferredSymAndTree(symf: Context ?=> Symbol)(treeFn: Context ?=> Tree)(implicit ctx: Context): Annotation =
129129
new LazyAnnotation {
130130
private var mySym: Symbol = _
131131

132132
override def symbol(implicit ctx: Context): Symbol = {
133133
if (mySym == null || mySym.defRunId != ctx.runId) {
134-
mySym = symf(given ctx)
134+
mySym = symf(using ctx)
135135
assert(mySym != null)
136136
}
137137
mySym
138138
}
139-
def complete(implicit ctx: Context) = treeFn(given ctx)
139+
def complete(implicit ctx: Context) = treeFn(using ctx)
140140
}
141141

142142
def deferred(atp: Type, args: List[Tree])(implicit ctx: Context): Annotation =
@@ -153,8 +153,8 @@ object Annotations {
153153
object Child {
154154

155155
/** A deferred annotation to the result of a given child computation */
156-
def later(delayedSym: (given Context) => Symbol, span: Span)(implicit ctx: Context): Annotation = {
157-
def makeChildLater(given ctx: Context) = {
156+
def later(delayedSym: Context ?=> Symbol, span: Span)(implicit ctx: Context): Annotation = {
157+
def makeChildLater(using ctx: Context) = {
158158
val sym = delayedSym
159159
New(defn.ChildAnnot.typeRef.appliedTo(sym.owner.thisType.select(sym.name, sym)), Nil)
160160
.withSpan(span)

compiler/src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ object Contexts {
5151
private val initialStore = store8
5252

5353
/** The current context */
54-
def curCtx(given ctx: Context): Context = ctx
54+
def curCtx(using ctx: Context): Context = ctx
5555

5656
/** A context is passed basically everywhere in dotc.
5757
* This is convenient but carries the risk of captured contexts in
@@ -319,7 +319,7 @@ object Contexts {
319319
/** Run `op` as if it was run in a fresh explore typer state, but possibly
320320
* optimized to re-use the current typer state.
321321
*/
322-
final def test[T](op: (given Context) => T): T = typerState.test(op)(this)
322+
final def test[T](op: Context ?=> T): T = typerState.test(op)(this)
323323

324324
/** Is this a context for the members of a class definition? */
325325
def isClassDefContext: Boolean =
@@ -599,7 +599,7 @@ object Contexts {
599599
def setDebug: this.type = setSetting(base.settings.Ydebug, true)
600600
}
601601

602-
given ops: extension (c: Context) with
602+
extension ops on (c: Context) with
603603
def addNotNullInfo(info: NotNullInfo) =
604604
c.withNotNullInfos(c.notNullInfos.extendWith(info))
605605

compiler/src/dotty/tools/dotc/core/Decorators.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ object Decorators {
188188

189189
implicit class reportDeco[T](x: T) extends AnyVal {
190190
def reporting(
191-
op: (given WrappedResult[T]) => String,
191+
op: WrappedResult[T] ?=> String,
192192
printer: config.Printers.Printer = config.Printers.default): T = {
193-
printer.println(op(given WrappedResult(x)))
193+
printer.println(op(using WrappedResult(x)))
194194
x
195195
}
196196
}

0 commit comments

Comments
 (0)