Skip to content

Commit 918705d

Browse files
authored
Merge branch 'master' into fail-if-scalac-not-found-fixes-12962
2 parents c62a1a3 + d7d70c0 commit 918705d

File tree

285 files changed

+2064
-566
lines changed

Some content is hidden

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

285 files changed

+2064
-566
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,6 @@ jobs:
124124
github.event_name == 'push'
125125
&& github.ref != 'refs/heads/master'
126126
)
127-
|| (
128-
github.event_name == 'pull_request'
129-
&& !contains(github.event.pull_request.body, '[skip ci]')
130-
)
131127
|| (
132128
github.event_name == 'pull_request'
133129
&& !contains(github.event.pull_request.body, '[skip ci]')

.github/workflows/scaladoc.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ jobs:
3939
run: ./project/scripts/sbt scaladoc-js/test
4040

4141
- name: Compile and test
42-
run: ./project/scripts/sbt scaladoc/test
42+
run: |
43+
./project/scripts/sbt scaladoc/test
44+
./project/scripts/cmdScaladocTests
4345
4446
- name: Locally publish self
4547
run: ./project/scripts/sbt scaladoc/publishLocal

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@
180180
[submodule "community-build/community-projects/protoquill"]
181181
path = community-build/community-projects/protoquill
182182
url = https://github.com/dotty-staging/protoquill.git
183+
[submodule "community-build/community-projects/Monocle"]
184+
path = community-build/community-projects/Monocle
185+
url = https://github.com/dotty-staging/Monocle.git
183186
[submodule "community-build/community-projects/onnx-scala"]
184187
path = community-build/community-projects/onnx-scala
185188
url = https://github.com/dotty-staging/onnx-scala.git
Submodule Monocle added at 4613aff

community-build/src/scala/dotty/communitybuild/projects.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,12 @@ object projects:
660660
dependencies = List(scalatest, scalatestplusJunit, scalatestplusScalacheck)
661661
)
662662

663+
lazy val monocle = SbtCommunityProject(
664+
project = "Monocle",
665+
sbtTestCommand = "coreJVM/test; macrosJVM/test; testJVM/test",
666+
dependencies = List(cats, munit, discipline, disciplineMunit)
667+
)
668+
663669
lazy val protoquill = SbtCommunityProject(
664670
project = "protoquill",
665671
sbtTestCommand = "test",
@@ -777,6 +783,7 @@ def allProjects = List(
777783
projects.izumiReflect,
778784
projects.perspective,
779785
projects.akka,
786+
projects.monocle,
780787
projects.protoquill,
781788
projects.onnxScala,
782789
projects.playJson,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class CommunityBuildTestB extends CommunityBuildTest:
127127
@Test def scalacheckEffect = projects.scalacheckEffect.run()
128128
@Test def scodec = projects.scodec.run()
129129
@Test def scodecBits = projects.scodecBits.run()
130+
@Test def monocle = projects.monocle.run()
130131
@Test def simulacrumScalafixAnnotations = projects.simulacrumScalafixAnnotations.run()
131132
end CommunityBuildTestB
132133

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,12 @@ class Definitions {
764764
@tu lazy val SelectableClass: ClassSymbol = requiredClass("scala.Selectable")
765765
@tu lazy val WithoutPreciseParameterTypesClass: Symbol = requiredClass("scala.Selectable.WithoutPreciseParameterTypes")
766766

767+
@tu lazy val ManifestClass: ClassSymbol = requiredClass("scala.reflect.Manifest")
768+
@tu lazy val ManifestFactoryModule: Symbol = requiredModule("scala.reflect.ManifestFactory")
769+
@tu lazy val ClassManifestFactoryModule: Symbol = requiredModule("scala.reflect.ClassManifestFactory")
770+
@tu lazy val OptManifestClass: ClassSymbol = requiredClass("scala.reflect.OptManifest")
771+
@tu lazy val NoManifestModule: Symbol = requiredModule("scala.reflect.NoManifest")
772+
767773
@tu lazy val ReflectPackageClass: Symbol = requiredPackage("scala.reflect.package").moduleClass
768774
@tu lazy val ClassTagClass: ClassSymbol = requiredClass("scala.reflect.ClassTag")
769775
@tu lazy val ClassTagModule: Symbol = ClassTagClass.companionModule
@@ -1433,6 +1439,8 @@ class Definitions {
14331439

14341440
@tu lazy val SpecialClassTagClasses: Set[Symbol] = Set(UnitClass, AnyClass, AnyValClass)
14351441

1442+
@tu lazy val SpecialManifestClasses: Set[Symbol] = Set(AnyClass, AnyValClass, ObjectClass, NullClass, NothingClass)
1443+
14361444
/** Classes that are known not to have an initializer irrespective of
14371445
* whether NoInits is set. Note: FunctionXXLClass is in this set
14381446
* because if it is compiled by Scala2, it does not get a NoInit flag.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,6 @@ object StdNames {
367367
val EnumValue: N = "EnumValue"
368368
val ExistentialTypeTree: N = "ExistentialTypeTree"
369369
val Flag : N = "Flag"
370-
val floatHash: N = "floatHash"
371370
val Ident: N = "Ident"
372371
val Import: N = "Import"
373372
val Literal: N = "Literal"
@@ -414,6 +413,7 @@ object StdNames {
414413
val argv : N = "argv"
415414
val arrayClass: N = "arrayClass"
416415
val arrayElementClass: N = "arrayElementClass"
416+
val arrayType: N = "arrayType"
417417
val arrayValue: N = "arrayValue"
418418
val array_apply : N = "array_apply"
419419
val array_clone : N = "array_clone"
@@ -440,6 +440,7 @@ object StdNames {
440440
val checkInitialized: N = "checkInitialized"
441441
val ClassManifestFactory: N = "ClassManifestFactory"
442442
val classOf: N = "classOf"
443+
val classType: N = "classType"
443444
val clone_ : N = "clone"
444445
val common: N = "common"
445446
val compiletime : N = "compiletime"
@@ -481,6 +482,7 @@ object StdNames {
481482
val find_ : N = "find"
482483
val flagsFromBits : N = "flagsFromBits"
483484
val flatMap: N = "flatMap"
485+
val floatHash: N = "floatHash"
484486
val foreach: N = "foreach"
485487
val format: N = "format"
486488
val fromDigits: N = "fromDigits"
@@ -626,6 +628,7 @@ object StdNames {
626628
val values: N = "values"
627629
val view_ : N = "view"
628630
val wait_ : N = "wait"
631+
val wildcardType: N = "wildcardType"
629632
val withFilter: N = "withFilter"
630633
val withFilterIfRefutable: N = "withFilterIfRefutable$"
631634
val WorksheetWrapper: N = "WorksheetWrapper"

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,11 +1140,10 @@ object SymDenotations {
11401140
else NoSymbol
11411141

11421142
/** The closest enclosing extension method containing this definition,
1143-
* provided the extension method appears in the same class.
1143+
* including methods outside the current class.
11441144
*/
11451145
final def enclosingExtensionMethod(using Context): Symbol =
11461146
if this.is(ExtensionMethod) then symbol
1147-
else if this.isClass then NoSymbol
11481147
else if this.exists then owner.enclosingExtensionMethod
11491148
else NoSymbol
11501149

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4417,6 +4417,8 @@ object Types {
44174417

44184418
private final class RecThisImpl(binder: RecType) extends RecThis(binder)
44194419

4420+
// @sharable private var skid: Int = 0
4421+
44204422
// ----- Skolem types -----------------------------------------------
44214423

44224424
/** A skolem type reference with underlying type `info`.
@@ -4434,6 +4436,10 @@ object Types {
44344436

44354437
def withName(name: Name): this.type = { myRepr = name; this }
44364438

4439+
//skid += 1
4440+
//val id = skid
4441+
//assert(id != 10)
4442+
44374443
private var myRepr: Name = null
44384444
def repr(using Context): Name = {
44394445
if (myRepr == null) myRepr = SkolemName.fresh()

compiler/src/dotty/tools/dotc/parsing/JavaTokens.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object JavaTokens extends TokensCommon {
1010

1111
final val javaOnlyKeywords: TokenSet = tokenRange(INSTANCEOF, ASSERT)
1212
final val sharedKeywords: BitSet = BitSet( IF, FOR, ELSE, THIS, NULL, NEW, SUPER, ABSTRACT, FINAL, PRIVATE, PROTECTED,
13-
OVERRIDE, EXTENDS, TRUE, FALSE, CLASS, IMPORT, PACKAGE, DO, THROW, TRY, CATCH, FINALLY, WHILE, RETURN )
13+
EXTENDS, TRUE, FALSE, CLASS, IMPORT, PACKAGE, DO, THROW, TRY, CATCH, FINALLY, WHILE, RETURN )
1414
final val primTypes: TokenSet = tokenRange(VOID, DOUBLE)
1515
final val keywords: BitSet = sharedKeywords | javaOnlyKeywords | primTypes
1616

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 48 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ object Parsers {
330330
else if in.token == END then
331331
if endSeen then syntaxError("duplicate end marker")
332332
checkEndMarker(stats)
333-
recur(sepSeen, true)
333+
recur(sepSeen, endSeen = true)
334334
else if isStatSeqEnd || in.token == altEnd then
335335
false
336336
else if sepSeen || endSeen then
@@ -537,15 +537,13 @@ object Parsers {
537537
def inBrackets[T](body: => T): T = enclosed(LBRACKET, body)
538538

539539
def inBracesOrIndented[T](body: => T, rewriteWithColon: Boolean = false): T =
540-
if (in.token == INDENT) {
541-
val rewriteToBraces =
542-
in.rewriteNoIndent &&
543-
!testChars(in.lastOffset - 3, " =>") // braces are always optional after `=>` so none should be inserted
544-
if (rewriteToBraces) indentedToBraces(body)
540+
if in.token == INDENT then
541+
val rewriteToBraces = in.rewriteNoIndent
542+
&& !testChars(in.lastOffset - 3, " =>") // braces are always optional after `=>` so none should be inserted
543+
if rewriteToBraces then indentedToBraces(body)
545544
else enclosed(INDENT, body)
546-
}
547545
else
548-
if (in.rewriteToIndent) bracesToIndented(body, rewriteWithColon)
546+
if in.rewriteToIndent then bracesToIndented(body, rewriteWithColon)
549547
else inBraces(body)
550548

551549
def inDefScopeBraces[T](body: => T, rewriteWithColon: Boolean = false): T =
@@ -635,68 +633,62 @@ object Parsers {
635633
else idx
636634

637635
/** Parse indentation region `body` and rewrite it to be in braces instead */
638-
def indentedToBraces[T](body: => T): T = {
639-
val enclRegion = in.currentRegion.enclosing
640-
def indentWidth = enclRegion.indentWidth
636+
def indentedToBraces[T](body: => T): T =
637+
val enclRegion = in.currentRegion.enclosing // capture on entry
638+
def indentWidth = enclRegion.indentWidth
641639
val followsColon = testChar(in.lastOffset - 1, ':')
642-
val startOpening =
643-
if (followsColon)
644-
if (testChar(in.lastOffset - 2, ' ')) in.lastOffset - 2
645-
else in.lastOffset - 1
646-
else in.lastOffset
647-
val endOpening = in.lastOffset
648-
649-
val t = enclosed(INDENT, body)
650640

651641
/** Is `expr` a tree that lacks a final `else`? Put such trees in `{...}` to make
652642
* sure we don't accidentally merge them with a following `else`.
653643
*/
654644
def isPartialIf(expr: Tree): Boolean = expr match {
655645
case If(_, _, EmptyTree) => true
656-
case If(_, _, e) => isPartialIf(e)
657-
case _ => false
646+
case If(_, _, e) => isPartialIf(e)
647+
case _ => false
658648
}
659649

660650
/** Is `expr` a (possibly curried) function that has a multi-statement block
661651
* as body? Put such trees in `{...}` since we don't enclose statements following
662652
* a `=>` in braces.
663653
*/
664654
def isBlockFunction[T](expr: T): Boolean = expr match {
665-
case Function(_, body) => isBlockFunction(body)
655+
case Function(_, body) => isBlockFunction(body)
666656
case Block(stats, expr) => stats.nonEmpty || isBlockFunction(expr)
667-
case _ => false
657+
case _ => false
668658
}
669659

670660
/** Start of first line after in.lastOffset that does not have a comment
671661
* at indent width greater than the indent width of the closing brace.
672662
*/
673663
def closingOffset(lineStart: Offset): Offset =
674-
if (in.lineOffset >= 0 && lineStart >= in.lineOffset) in.lineOffset
675-
else {
676-
val candidate = source.nextLine(lineStart)
664+
if in.lineOffset >= 0 && lineStart >= in.lineOffset then in.lineOffset
665+
else
677666
val commentStart = skipBlanks(lineStart)
678-
if (testChar(commentStart, '/') && indentWidth < in.indentWidth(commentStart))
679-
closingOffset(source.nextLine(lineStart))
680-
else
681-
lineStart
682-
}
667+
if testChar(commentStart, '/') && indentWidth < in.indentWidth(commentStart)
668+
then closingOffset(source.nextLine(lineStart))
669+
else lineStart
683670

684671
def needsBraces(t: Any): Boolean = t match {
685672
case Match(EmptyTree, _) => true
686-
case Block(stats, expr) =>
687-
stats.nonEmpty || needsBraces(expr)
688-
case expr: Tree =>
689-
followsColon ||
690-
isPartialIf(expr) && in.token == ELSE ||
691-
isBlockFunction(expr)
692-
case _ => true
693-
}
694-
if (needsBraces(t)) {
673+
case Block(stats, expr) => stats.nonEmpty || needsBraces(expr)
674+
case expr: Tree => followsColon
675+
|| isPartialIf(expr) && in.token == ELSE
676+
|| isBlockFunction(expr)
677+
case _ => true
678+
}
679+
// begin indentedToBraces
680+
val startOpening =
681+
if followsColon then
682+
if testChar(in.lastOffset - 2, ' ') then in.lastOffset - 2
683+
else in.lastOffset - 1
684+
else in.lastOffset
685+
val endOpening = in.lastOffset
686+
val t = enclosed(INDENT, body)
687+
if needsBraces(t) then
695688
patch(source, Span(startOpening, endOpening), " {")
696689
patch(source, Span(closingOffset(source.nextLine(in.lastOffset))), indentWidth.toPrefix ++ "}\n")
697-
}
698690
t
699-
}
691+
end indentedToBraces
700692

701693
/** The region to eliminate when replacing an opening `(` or `{` that ends a line.
702694
* The `(` or `{` is at in.offset.
@@ -1304,17 +1296,21 @@ object Parsers {
13041296
case _: (ForYield | ForDo) => in.token == FOR
13051297
case _ => false
13061298

1307-
def matchesAndSetEnd(last: T): Boolean = {
1299+
def endName = if in.token == IDENTIFIER then in.name.toString else tokenString(in.token)
1300+
1301+
def matchesAndSetEnd(last: T): Boolean =
13081302
val didMatch = matches(last)
13091303
if didMatch then
13101304
updateSpanOfLast(last)
13111305
didMatch
1312-
}
13131306

13141307
if in.token == END then
13151308
val start = in.skipToken()
13161309
if stats.isEmpty || !matchesAndSetEnd(stats.last) then
13171310
syntaxError("misaligned end marker", Span(start, in.lastCharOffset))
1311+
else if overlapsPatch(source, Span(start, start)) then
1312+
patch(source, Span(start, start), "")
1313+
patch(source, Span(start, in.lastCharOffset), s"} // end $endName")
13181314
in.token = IDENTIFIER // Leaving it as the original token can confuse newline insertion
13191315
in.nextToken()
13201316
end checkEndMarker
@@ -2509,9 +2505,9 @@ object Parsers {
25092505
GenFrom(pat, subExpr(), checkMode)
25102506
}
25112507

2512-
/** ForExpr ::= `for' (`(' Enumerators `)' | `{' Enumerators `}')
2513-
* {nl} [`yield'] Expr
2514-
* | `for' Enumerators (`do' Expr | `yield' Expr)
2508+
/** ForExpr ::= for’ ‘(’ Enumerators ‘)’ {nl} [‘do‘ | ‘yield’] Expr
2509+
* | ‘for’ ‘{’ Enumerators ‘}’ {nl} [‘do‘ | ‘yield] Expr
2510+
* | forEnumerators (‘do‘ | ‘yield’) Expr
25152511
*/
25162512
def forExpr(): Tree =
25172513
atSpan(in.skipToken()) {
@@ -3631,7 +3627,7 @@ object Parsers {
36313627
finalizeDef(gdef, mods1, start)
36323628
}
36333629

3634-
/** Extension ::= ‘extension’ [DefTypeParamClause] ‘(’ DefParam ‘)’
3630+
/** Extension ::= ‘extension’ [DefTypeParamClause] {UsingParamClause} ‘(’ DefParam ‘)’
36353631
* {UsingParamClause} ExtMethods
36363632
*/
36373633
def extension(): ExtMethods =
@@ -3854,9 +3850,9 @@ object Parsers {
38543850
def templateStatSeq(): (ValDef, List[Tree]) = checkNoEscapingPlaceholders {
38553851
var self: ValDef = EmptyValDef
38563852
val stats = new ListBuffer[Tree]
3857-
if (isExprIntro && !isDefIntro(modifierTokens)) {
3853+
if isExprIntro && !isDefIntro(modifierTokens) then
38583854
val first = expr1()
3859-
if (in.token == ARROW) {
3855+
if in.token == ARROW then
38603856
first match {
38613857
case Typed(tree @ This(EmptyTypeIdent), tpt) =>
38623858
self = makeSelfDef(nme.WILDCARD, tpt).withSpan(first.span)
@@ -3867,11 +3863,10 @@ object Parsers {
38673863
}
38683864
in.token = SELFARROW // suppresses INDENT insertion after `=>`
38693865
in.nextToken()
3870-
}
38713866
else
38723867
stats += first
38733868
statSepOrEnd(stats)
3874-
}
3869+
end if
38753870
while
38763871
var empty = false
38773872
if (in.token == IMPORT)
@@ -3888,7 +3883,7 @@ object Parsers {
38883883
empty = true
38893884
statSepOrEnd(stats, empty)
38903885
do ()
3891-
(self, if (stats.isEmpty) List(EmptyTree) else stats.toList)
3886+
(self, if stats.isEmpty then List(EmptyTree) else stats.toList)
38923887
}
38933888

38943889
/** RefineStatSeq ::= RefineStat {semi RefineStat}

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ object Scanners {
612612
prev.copyFrom(this)
613613
lastOffset = lastCharOffset
614614
fetchToken()
615+
if token == END && !isEndMarker then token = IDENTIFIER
615616
}
616617

617618
def reset() = {

0 commit comments

Comments
 (0)