Skip to content

Commit fecd60e

Browse files
committed
Merge branch 'master' into scaladoc-color-themes
# Conflicts: # scaladoc/resources/dotty_res/styles/scalastyle.css
2 parents 55b2a40 + 0cbaccb commit fecd60e

File tree

276 files changed

+5697
-1729
lines changed

Some content is hidden

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

276 files changed

+5697
-1729
lines changed

NOTICE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ major authors were omitted by oversight.
8282
modifications. They were originally authored by Lex Spoon, Som Snytt,
8383
Adriaan Moors, Paul Phillips and others.
8484

85-
* dotty.tools.dottydoc: The Dottydoc documentation utility ships some
85+
* dotty.tools.scaladoc: The Scaladoc documentation utility ships some
8686
third-party JavaScript and CSS libraries which are located under
87-
dotty-doc/resources/css/, dotty-doc/resources/js/, docs/css/ and
87+
scaladoc/resources/dotty_res/styles/, scaladoc/resources/dotty_res/scripts/, docs/css/ and
8888
docs/js/. Please refer to the license header of the concerned files for
8989
details.
9090

Submodule protoquill updated 112 files

compiler/src/dotty/tools/backend/sjs/JSDefinitions.scala

+3
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ final class JSDefinitions()(using Context) {
9595
def JSExportStaticAnnot(using Context) = JSExportStaticAnnotType.symbol.asClass
9696
@threadUnsafe lazy val JSExportAllAnnotType: TypeRef = requiredClassRef("scala.scalajs.js.annotation.JSExportAll")
9797
def JSExportAllAnnot(using Context) = JSExportAllAnnotType.symbol.asClass
98+
99+
def JSAnnotPackage(using Context) = JSGlobalAnnot.owner.asClass
100+
98101
@threadUnsafe lazy val JSTypeAnnotType: TypeRef = requiredClassRef("scala.scalajs.js.annotation.internal.JSType")
99102
def JSTypeAnnot(using Context) = JSTypeAnnotType.symbol.asClass
100103
@threadUnsafe lazy val JSOptionalAnnotType: TypeRef = requiredClassRef("scala.scalajs.js.annotation.internal.JSOptional")

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

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class Compiler {
121121
new ElimStaticThis, // Replace `this` references to static objects by global identifiers
122122
new CountOuterAccesses) :: // Identify outer accessors that can be dropped
123123
List(new DropOuterAccessors, // Drop unused outer accessors
124+
new CheckNoSuperThis, // Check that supercalls don't contain references to `this`
124125
new Flatten, // Lift all inner classes to package scope
125126
new RenameLifted, // Renames lifted classes to local numbering scheme
126127
new TransformWildcards, // Replace wildcards with default values

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

+39-10
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ object desugar {
182182
tpt = TypeTree(defn.UnitType),
183183
rhs = setterRhs
184184
).withMods((mods | Accessor) &~ (CaseAccessor | GivenOrImplicit | Lazy))
185+
.dropEndMarker() // the end marker should only appear on the getter definition
185186
Thicket(vdef1, setter)
186187
}
187188
else vdef1
@@ -883,6 +884,7 @@ object desugar {
883884
val clsTmpl = cpy.Template(impl)(self = clsSelf, body = impl.body)
884885
val cls = TypeDef(clsName, clsTmpl)
885886
.withMods(mods.toTypeFlags & RetainedModuleClassFlags | ModuleClassCreationFlags)
887+
.withEndMarker(copyFrom = mdef) // copy over the end marker position to the module class def
886888
Thicket(modul, classDef(cls).withSpan(mdef.span))
887889
}
888890
}
@@ -1091,6 +1093,16 @@ object desugar {
10911093
case IdPattern(named, tpt) =>
10921094
derivedValDef(original, named, tpt, rhs, mods)
10931095
case _ =>
1096+
1097+
def filterWildcardGivenBinding(givenPat: Bind): Boolean =
1098+
givenPat.name != nme.WILDCARD
1099+
1100+
def errorOnGivenBinding(bind: Bind)(using Context): Boolean =
1101+
report.error(
1102+
em"""${hl("given")} patterns are not allowed in a ${hl("val")} definition,
1103+
|please bind to an identifier and use an alias given.""".stripMargin, bind)
1104+
false
1105+
10941106
def isTuplePattern(arity: Int): Boolean = pat match {
10951107
case Tuple(pats) if pats.size == arity =>
10961108
pats.forall(isVarPattern)
@@ -1106,13 +1118,23 @@ object desugar {
11061118
// - `pat` is a tuple of N variables or wildcard patterns like `(x1, x2, ..., xN)`
11071119
val tupleOptimizable = forallResults(rhs, isMatchingTuple)
11081120

1121+
val inAliasGenerator = original match
1122+
case _: GenAlias => true
1123+
case _ => false
1124+
11091125
val vars =
11101126
if (tupleOptimizable) // include `_`
1111-
pat match {
1112-
case Tuple(pats) =>
1113-
pats.map { case id: Ident => id -> TypeTree() }
1114-
}
1115-
else getVariables(pat) // no `_`
1127+
pat match
1128+
case Tuple(pats) => pats.map { case id: Ident => id -> TypeTree() }
1129+
else
1130+
getVariables(
1131+
tree = pat,
1132+
shouldAddGiven =
1133+
if inAliasGenerator then
1134+
filterWildcardGivenBinding
1135+
else
1136+
errorOnGivenBinding
1137+
) // no `_`
11161138

11171139
val ids = for ((named, _) <- vars) yield Ident(named.name)
11181140
val caseDef = CaseDef(pat, EmptyTree, makeTuple(ids))
@@ -1299,7 +1321,9 @@ object desugar {
12991321
if (nestedStats.isEmpty) pdef
13001322
else {
13011323
val name = packageObjectName(ctx.source)
1302-
val grouped = ModuleDef(name, Template(emptyConstructor, Nil, Nil, EmptyValDef, nestedStats))
1324+
val grouped =
1325+
ModuleDef(name, Template(emptyConstructor, Nil, Nil, EmptyValDef, nestedStats))
1326+
.withMods(Modifiers(Synthetic))
13031327
cpy.PackageDef(pdef)(pdef.pid, topStats :+ grouped)
13041328
}
13051329
}
@@ -1796,16 +1820,21 @@ object desugar {
17961820
/** Returns list of all pattern variables, possibly with their types,
17971821
* without duplicates
17981822
*/
1799-
private def getVariables(tree: Tree)(using Context): List[VarInfo] = {
1823+
private def getVariables(tree: Tree, shouldAddGiven: Context ?=> Bind => Boolean)(using Context): List[VarInfo] = {
18001824
val buf = ListBuffer[VarInfo]()
18011825
def seenName(name: Name) = buf exists (_._1.name == name)
18021826
def add(named: NameTree, t: Tree): Unit =
18031827
if (!seenName(named.name) && named.name.isTermName) buf += ((named, t))
18041828
def collect(tree: Tree): Unit = tree match {
1805-
case Bind(nme.WILDCARD, tree1) =>
1829+
case tree @ Bind(nme.WILDCARD, tree1) =>
1830+
if tree.mods.is(Given) then
1831+
val Typed(_, tpt) = tree1: @unchecked
1832+
if shouldAddGiven(tree) then
1833+
add(tree, tpt)
18061834
collect(tree1)
18071835
case tree @ Bind(_, Typed(tree1, tpt)) =>
1808-
add(tree, tpt)
1836+
if !(tree.mods.is(Given) && !shouldAddGiven(tree)) then
1837+
add(tree, tpt)
18091838
collect(tree1)
18101839
case tree @ Bind(_, tree1) =>
18111840
add(tree, TypeTree())
@@ -1823,7 +1852,7 @@ object desugar {
18231852
case SeqLiteral(elems, _) =>
18241853
elems foreach collect
18251854
case Alternative(trees) =>
1826-
for (tree <- trees; (vble, _) <- getVariables(tree))
1855+
for (tree <- trees; (vble, _) <- getVariables(tree, shouldAddGiven))
18271856
report.error(IllegalVariableInPatternAlternative(), vble.srcPos)
18281857
case Annotated(arg, _) =>
18291858
collect(arg)

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

+4-5
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,11 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Src
6565
if (span == mySpan) this
6666
else {
6767
val newpd: this.type =
68-
if (mySpan.isSynthetic) {
69-
if (!mySpan.exists && span.exists)
70-
envelope(source, span.startPos) // fill in children spans
68+
if !mySpan.exists then
69+
if span.exists then envelope(source, span.startPos) // fill in children spans
7170
this
72-
}
73-
else cloneIn(source)
71+
else
72+
cloneIn(source)
7473
newpd.span = span
7574
newpd
7675
}

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

+53-3
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,58 @@ object Trees {
327327

328328
extension (mdef: untpd.DefTree) def mods: untpd.Modifiers = mdef.rawMods
329329

330-
abstract class NamedDefTree[-T >: Untyped](implicit @constructorOnly src: SourceFile) extends NameTree[T] with DefTree[T] {
330+
sealed trait WithEndMarker[-T >: Untyped]:
331+
self: PackageDef[T] | NamedDefTree[T] =>
332+
333+
import WithEndMarker.*
334+
335+
final def endSpan(using Context): Span =
336+
if hasEndMarker then
337+
val realName = srcName.stripModuleClassSuffix.lastPart
338+
span.withStart(span.end - realName.length)
339+
else
340+
NoSpan
341+
342+
/** The name in source code that represents this construct,
343+
* and is the name that the user must write to create a valid
344+
* end marker.
345+
* e.g. a constructor definition is terminated in the source
346+
* code by `end this`, so it's `srcName` should return `this`.
347+
*/
348+
protected def srcName(using Context): Name
349+
350+
final def withEndMarker(): self.type =
351+
self.withAttachment(HasEndMarker, ())
352+
353+
final def withEndMarker(copyFrom: WithEndMarker[?]): self.type =
354+
if copyFrom.hasEndMarker then
355+
this.withEndMarker()
356+
else
357+
this
358+
359+
final def dropEndMarker(): self.type =
360+
self.removeAttachment(HasEndMarker)
361+
this
362+
363+
protected def hasEndMarker: Boolean = self.hasAttachment(HasEndMarker)
364+
365+
object WithEndMarker:
366+
/** Property key that signals the tree was terminated
367+
* with an `end` marker in the source code
368+
*/
369+
private val HasEndMarker: Property.StickyKey[Unit] = Property.StickyKey()
370+
371+
end WithEndMarker
372+
373+
abstract class NamedDefTree[-T >: Untyped](implicit @constructorOnly src: SourceFile)
374+
extends NameTree[T] with DefTree[T] with WithEndMarker[T] {
331375
type ThisTree[-T >: Untyped] <: NamedDefTree[T]
332376

377+
protected def srcName(using Context): Name =
378+
if name == nme.CONSTRUCTOR then nme.this_
379+
else if symbol.isPackageObject then symbol.owner.name
380+
else name
381+
333382
/** The position of the name defined by this definition.
334383
* This is a point position if the definition is synthetic, or a range position
335384
* if the definition comes from source.
@@ -342,7 +391,7 @@ object Trees {
342391
val point = span.point
343392
if (rawMods.is(Synthetic) || span.isSynthetic || name.toTermName == nme.ERROR) Span(point)
344393
else {
345-
val realName = name.stripModuleClassSuffix.lastPart
394+
val realName = srcName.stripModuleClassSuffix.lastPart
346395
Span(point, point + realName.length, point)
347396
}
348397
}
@@ -857,9 +906,10 @@ object Trees {
857906

858907
/** package pid { stats } */
859908
case class PackageDef[-T >: Untyped] private[ast] (pid: RefTree[T], stats: List[Tree[T]])(implicit @constructorOnly src: SourceFile)
860-
extends ProxyTree[T] {
909+
extends ProxyTree[T] with WithEndMarker[T] {
861910
type ThisTree[-T >: Untyped] = PackageDef[T]
862911
def forwardTo: RefTree[T] = pid
912+
protected def srcName(using Context): Name = pid.name
863913
}
864914

865915
/** arg @annot */

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

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ trait CliCommand:
6363
}
6464

6565
sg.processArguments(expandedArguments, processAll = true, settingsState = ss)
66+
end distill
6667

6768
/** Creates a help message for a subset of options based on cond */
6869
protected def availableOptionsMsg(cond: Setting[?] => Boolean)(using settings: ConcreteSettings)(using SettingsState): String =
@@ -108,6 +109,7 @@ trait CliCommand:
108109
""
109110
s"${formatName(s.name)} ${formatDescription(s.description)}${formatSetting("Default", defaultValue)}${formatSetting("Choices", s.legalChoices)}"
110111
ss.map(helpStr).mkString("", "\n", s"\n${formatName("@<file>")} ${formatDescription("A text file containing compiler arguments (options and source files).")}\n")
112+
end availableOptionsMsg
111113

112114
protected def shortUsage: String = s"Usage: $cmdName <options> <source files>"
113115

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ object Printers {
2020
val debug = noPrinter
2121
val derive = noPrinter
2222
val desugar = noPrinter
23-
val dottydoc = noPrinter
23+
val scaladoc = noPrinter
2424
val exhaustivity = noPrinter
2525
val gadts = noPrinter
2626
val gadtsConstr = noPrinter

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ trait PropertiesTrait {
8484

8585
/** Whether the current version of compiler is experimental
8686
*
87-
* 1. Snapshot and nightly releases are experimental.
87+
* 1. Snapshot, nightly releases and non-bootstrapped compiler are experimental.
8888
* 2. Features supported by experimental versions of the compiler:
8989
* - research plugins
9090
*/
91-
val experimental: Boolean = versionString.contains("SNAPSHOT") || versionString.contains("NIGHTLY")
91+
val experimental: Boolean = versionString.contains("SNAPSHOT") || versionString.contains("NIGHTLY") || versionString.contains("nonbootstrapped")
9292

9393
val copyrightString: String = scalaPropOrElse("copyright.string", "(c) 2002-2017 LAMP/EPFL")
9494

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

-3
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,6 @@ trait AllScalaSettings extends CommonScalaSettings { self: Settings.SettingGroup
214214

215215
val YforceInlineWhileTyping: Setting[Boolean] = BooleanSetting("-Yforce-inline-while-typing", "Make non-transparent inline methods inline when typing. Emulates the old inlining behavior of 3.0.0-M3.")
216216

217-
/** Dottydoc specific settings that are not used in scaladoc */
218-
val docSnapshot: Setting[Boolean] = BooleanSetting("-doc-snapshot", "Generate a documentation snapshot for the current Dotty version")
219-
220217
val projectUrl: Setting[String] = StringSetting (
221218
"-project-url",
222219
"project repository homepage",

0 commit comments

Comments
 (0)