Skip to content

Commit 8713944

Browse files
committed
Merge with main at #17340
2 parents 9533931 + 7a6dc76 commit 8713944

File tree

159 files changed

+1997
-525
lines changed

Some content is hidden

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

159 files changed

+1997
-525
lines changed

.github/PULL_REQUEST_TEMPLATE/fix-issue.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ assignees: ''
66

77
---
88

9-
<!--
10-
TODO first sign the CLA
9+
<!--
10+
TODO first sign the CLA
1111
https://www.lightbend.com/contribute/cla/scala
1212
-->
1313

1414
## Fix #XYZ
1515

16-
<!-- TODO description of the change -->
16+
<!-- TODO description of the change -->
1717

1818

1919
<!-- Ideally should have a called "Fix #XYZ: A SHORT FIX DESCRIPTION" -->

.github/PULL_REQUEST_TEMPLATE/other-pr.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ assignees: ''
66

77
---
88

9-
<!--
10-
TODO first sign the CLA
9+
<!--
10+
TODO first sign the CLA
1111
https://www.lightbend.com/contribute/cla/scala
1212
-->
1313

1414
## Description
1515

16-
<!-- TODO description of the change -->
16+
<!-- TODO description of the change -->
1717

1818

1919
<!-- Ideally should have a single commit -->

.github/workflows/releases.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
options: --cpu-shares 4096
1414

1515
env:
16-
SDKMAN_KEY: ${{ secrets.SDKMAN_KEY }}
16+
SDKMAN_KEY: ${{ secrets.SDKMAN_KEY }}
1717
SDKMAN_TOKEN: ${{ secrets.SDKMAN_TOKEN }}
18-
18+
1919
steps:
2020
- name: Reset existing repo
2121
run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true

.github/workflows/scripts/publish-sdkman.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
set -u
1111

12-
# latest stable dotty version
12+
# latest stable dotty version
1313
DOTTY_VERSION=$(curl -s https://api.github.com/repos/lampepfl/dotty/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
1414
DOTTY_URL="https://github.com/lampepfl/dotty/releases/download/$DOTTY_VERSION/scala3-$DOTTY_VERSION.zip"
1515

16-
# checking if dotty version is available
16+
# checking if dotty version is available
1717
if ! curl --output /dev/null --silent --head --fail "$DOTTY_URL"; then
1818
echo "URL doesn't exist: $DOTTY_URL"
1919
exit 1

bench-micro/src/main/scala/dotty/tools/benchmarks/lazyvals/InitializedAccess.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class InitializedAccess {
1818

1919
@Setup
2020
def prepare: Unit = {
21-
holder = new LazyHolder
21+
holder = new LazyHolder
2222
holder.value
2323
}
2424

bench-micro/src/main/scala/dotty/tools/benchmarks/lazyvals/InitializedAccessAny.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class InitializedAccessAny {
1818

1919
@Setup
2020
def prepare: Unit = {
21-
holder = new LazyAnyHolder
21+
holder = new LazyAnyHolder
2222
holder.value
2323
}
2424

bench-micro/src/main/scala/dotty/tools/benchmarks/lazyvals/InitializedAccessGeneric.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class InitializedAccessGeneric {
1818

1919
@Setup
2020
def prepare: Unit = {
21-
holder = new LazyGenericHolder[String]("foo")
21+
holder = new LazyGenericHolder[String]("foo")
2222
holder.value
2323
}
2424

bench-micro/src/main/scala/dotty/tools/benchmarks/lazyvals/InitializedAccessString.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class InitializedAccessString {
1818

1919
@Setup
2020
def prepare: Unit = {
21-
holder = new LazyStringHolder
21+
holder = new LazyStringHolder
2222
holder.value
2323
}
2424

bench-micro/src/main/scala/dotty/tools/benchmarks/lazyvals/LazyVals.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ object LazyVals {
2121
}
2222
}
2323
}
24-
24+
2525
class LazyHolder {
2626

2727
lazy val value: List[Int] = {

compiler/src/dotty/tools/backend/jvm/BackendUtils.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class BackendUtils(val postProcessor: PostProcessor) {
3535
case "18" => asm.Opcodes.V18
3636
case "19" => asm.Opcodes.V19
3737
case "20" => asm.Opcodes.V20
38+
case "21" => asm.Opcodes.V21
3839
}
3940

4041
lazy val extraProc: Int = {

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Compiler {
3535
protected def frontendPhases: List[List[Phase]] =
3636
List(new Parser) :: // Compiler frontend: scanner, parser
3737
List(new TyperPhase) :: // Compiler frontend: namer, typer
38-
List(new CheckUnused) :: // Check for unused elements
38+
List(new CheckUnused.PostTyper) :: // Check for unused elements
3939
List(new YCheckPositions) :: // YCheck positions
4040
List(new sbt.ExtractDependencies) :: // Sends information on classes' dependencies to sbt via callbacks
4141
List(new semanticdb.ExtractSemanticDB) :: // Extract info into .semanticdb files
@@ -50,6 +50,7 @@ class Compiler {
5050
List(new Pickler) :: // Generate TASTY info
5151
List(new Inlining) :: // Inline and execute macros
5252
List(new PostInlining) :: // Add mirror support for inlined code
53+
List(new CheckUnused.PostInlining) :: // Check for unused elements
5354
List(new Staging) :: // Check staging levels and heal staged types
5455
List(new Splicing) :: // Replace level 1 splices with holes
5556
List(new PickleQuotes) :: // Turn quoted trees into explicit run-time data structures
@@ -58,7 +59,8 @@ class Compiler {
5859
/** Phases dealing with the transformation from pickled trees to backend trees */
5960
protected def transformPhases: List[List[Phase]] =
6061
List(new InstrumentCoverage) :: // Perform instrumentation for code coverage (if -coverage-out is set)
61-
List(new FirstTransform, // Some transformations to put trees into a canonical form
62+
List(new CrossVersionChecks, // Check issues related to deprecated and experimental
63+
new FirstTransform, // Some transformations to put trees into a canonical form
6264
new CheckReentrant, // Internal use only: Check that compiled program has no data races involving global vars
6365
new ElimPackagePrefixes, // Eliminate references to package prefixes in Select nodes
6466
new CookComments, // Cook the comments: expand variables, doc, etc.
@@ -70,8 +72,7 @@ class Compiler {
7072
new ElimRepeated, // Rewrite vararg parameters and arguments
7173
new RefChecks) :: // Various checks mostly related to abstract members and overriding
7274
List(new init.Checker) :: // Check initialization of objects
73-
List(new CrossVersionChecks, // Check issues related to deprecated and experimental
74-
new ProtectedAccessors, // Add accessors for protected members
75+
List(new ProtectedAccessors, // Add accessors for protected members
7576
new ExtensionMethods, // Expand methods of value classes with extension methods
7677
new UncacheGivenAliases, // Avoid caching RHS of simple parameterless given aliases
7778
new ElimByName, // Map by-name parameters to functions
@@ -89,7 +90,7 @@ class Compiler {
8990
new ExplicitOuter, // Add accessors to outer classes from nested ones.
9091
new ExplicitSelf, // Make references to non-trivial self types explicit as casts
9192
new StringInterpolatorOpt, // Optimizes raw and s and f string interpolators by rewriting them to string concatenations or formats
92-
new DropBreaks) :: // Optimize local Break throws by rewriting them
93+
new DropBreaks) :: // Optimize local Break throws by rewriting them
9394
List(new PruneErasedDefs, // Drop erased definitions from scopes and simplify erased expressions
9495
new UninitializedDefs, // Replaces `compiletime.uninitialized` by `_`
9596
new InlinePatterns, // Remove placeholders of inlined patterns

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,10 @@ class TreeMapWithImplicits extends tpd.TreeMapWithPreciseStatContexts {
3030

3131
private def patternScopeCtx(pattern: Tree)(using Context): Context = {
3232
val nestedCtx = ctx.fresh.setNewScope
33-
new TreeTraverser {
34-
def traverse(tree: Tree)(using Context): Unit = {
35-
tree match {
36-
case d: DefTree if d.symbol.isOneOf(GivenOrImplicitVal) =>
37-
nestedCtx.enter(d.symbol)
38-
case _ =>
39-
}
40-
traverseChildren(tree)
41-
}
42-
}.traverse(pattern)
33+
pattern.foreachSubTree {
34+
case d: DefTree if d.symbol.isOneOf(GivenOrImplicitVal) => nestedCtx.enter(d.symbol)
35+
case _ =>
36+
}
4337
nestedCtx
4438
}
4539

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -855,9 +855,9 @@ object Trees {
855855
}
856856

857857
/** extends parents { self => body }
858-
* @param parentsOrDerived A list of parents followed by a list of derived classes,
859-
* if this is of class untpd.DerivingTemplate.
860-
* Typed templates only have parents.
858+
* @param preParentsOrDerived A list of parents followed by a list of derived classes,
859+
* if this is of class untpd.DerivingTemplate.
860+
* Typed templates only have parents.
861861
*/
862862
case class Template[+T <: Untyped] private[ast] (constr: DefDef[T], private var preParentsOrDerived: LazyTreeList[T], self: ValDef[T], private var preBody: LazyTreeList[T])(implicit @constructorOnly src: SourceFile)
863863
extends DefTree[T] with WithLazyFields {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
15481548
*
15491549
* @param trees the elements the list represented by
15501550
* the resulting tree should contain.
1551-
* @param tpe the type of the elements of the resulting list.
1551+
* @param tpt the type of the elements of the resulting list.
15521552
*
15531553
*/
15541554
def mkList(trees: List[Tree], tpt: Tree)(using Context): Tree =

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ extends tpd.TreeTraverser:
262262
// hard-coded expansion since $throws aliases in stdlib are defined with `?=>` rather than `?->`
263263
defn.FunctionOf(
264264
AnnotatedType(
265-
defn.CanThrowClass.typeRef.appliedTo(exc),
265+
defn.CanThrowClass.typeRef.appliedTo(exc),
266266
Annotation(defn.ErasedParamAnnot, defn.CanThrowClass.span)) :: Nil,
267267
res,
268268
isContextual = true

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ object Feature:
2929
val fewerBraces = experimental("fewerBraces")
3030
val saferExceptions = experimental("saferExceptions")
3131
val clauseInterleaving = experimental("clauseInterleaving")
32+
val relaxedExtensionImports = experimental("relaxedExtensionImports")
3233
val pureFunctions = experimental("pureFunctions")
3334
val captureChecking = experimental("captureChecking")
3435
val into = experimental("into")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class PathResolver(using c: Context) {
211211
import classPathFactory._
212212

213213
// Assemble the elements!
214-
def basis: List[Traversable[ClassPath]] =
214+
def basis: List[Iterable[ClassPath]] =
215215
val release = Option(ctx.settings.javaOutputVersion.value).filter(_.nonEmpty)
216216

217217
List(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ScalaSettings extends SettingGroup with AllScalaSettings
1818
object ScalaSettings:
1919
// Keep synchronized with `classfileVersion` in `BackendUtils`
2020
private val minTargetVersion = 8
21-
private val maxTargetVersion = 20
21+
private val maxTargetVersion = 21
2222

2323
def supportedTargetVersions: List[String] =
2424
(minTargetVersion to maxTargetVersion).toList.map(_.toString)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ object Annotations {
194194
object Annotation {
195195

196196
def apply(tree: Tree): ConcreteAnnotation = ConcreteAnnotation(tree)
197-
197+
198198
def apply(cls: ClassSymbol, span: Span)(using Context): Annotation =
199199
apply(cls, Nil, span)
200200

@@ -206,7 +206,7 @@ object Annotations {
206206

207207
def apply(atp: Type, arg: Tree, span: Span)(using Context): Annotation =
208208
apply(atp, arg :: Nil, span)
209-
209+
210210
def apply(atp: Type, args: List[Tree], span: Span)(using Context): Annotation =
211211
apply(New(atp, args).withSpan(span))
212212

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,12 @@ object Contexts {
444444
def useColors: Boolean =
445445
base.settings.color.value == "always"
446446

447+
def withColors: FreshContext =
448+
fresh.setSetting(ctx.settings.color, "always")
449+
450+
def withoutColors: FreshContext =
451+
fresh.setSetting(ctx.settings.color, "never")
452+
447453
/** Is the explicit nulls option set? */
448454
def explicitNulls: Boolean = base.settings.YexplicitNulls.value
449455

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,6 @@ class Definitions {
15091509

15101510
/** Is an context function class.
15111511
* - ContextFunctionN for N >= 0
1512-
* - ErasedContextFunctionN for N > 0
15131512
*/
15141513
def isContextFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isContextFunction
15151514

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ object SymDenotations {
299299
}
300300

301301
/** Add all given annotations to this symbol */
302-
final def addAnnotations(annots: TraversableOnce[Annotation])(using Context): Unit =
302+
final def addAnnotations(annots: IterableOnce[Annotation])(using Context): Unit =
303303
annots.iterator.foreach(addAnnotation)
304304

305305
@tailrec
@@ -1407,9 +1407,9 @@ object SymDenotations {
14071407
case Nil => Iterator.empty
14081408
}
14091409

1410-
/** The symbol overriding this symbol in given subclass `ofclazz`.
1410+
/** The symbol overriding this symbol in given subclass `inClass`.
14111411
*
1412-
* @param ofclazz is a subclass of this symbol's owner
1412+
* @pre `inClass` is a subclass of this symbol's owner
14131413
*/
14141414
final def overridingSymbol(inClass: ClassSymbol)(using Context): Symbol =
14151415
if (canMatchInheritedSymbols) matchingDecl(inClass, inClass.thisType)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ object Symbols {
4040
val Ids: Property.Key[Array[String]] = new Property.Key
4141

4242
/** A Symbol represents a Scala definition/declaration or a package.
43-
* @param coord The coordinates of the symbol (a position or an index)
43+
* @param myCoord The coordinates of the symbol (a position or an index)
4444
* @param id A unique identifier of the symbol (unique per ContextBase)
4545
*/
4646
class Symbol private[Symbols] (private var myCoord: Coord, val id: Int, val nestingLevel: Int)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
591591
val base = nonExprBaseType(tp1, cls2)
592592
if (base.typeSymbol == cls2) return true
593593
}
594-
else if tp1.isLambdaSub && !tp1.isAnyKind then
594+
else if tp1.typeParams.nonEmpty && !tp1.isAnyKind then
595595
return recur(tp1, EtaExpansion(tp2))
596596
fourthTry
597597
}

0 commit comments

Comments
 (0)