Skip to content

Commit 663d334

Browse files
authored
Merge pull request #10658 from dotty-staging/fix-#10648
Fix #10648: Fixes of syntax documentation
2 parents ab5db76 + 3b45151 commit 663d334

Some content is hidden

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

59 files changed

+734
-308
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import scala.quoted.Type
55
class FieldsDsl[V](v: V):
66
inline def of[T]: Seq[T] = FieldsImpl.fieldsOfType[V, T](v)
77

8-
extension [V](on: V):
8+
extension [V](on: V)
99
def reflectedFields = FieldsDsl(on)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
275275
* object T { def f { object U } }
276276
* the owner of U is T, so UModuleClass.isStatic is true. Phase travel does not help here.
277277
*/
278-
extension (sym: Symbol):
278+
extension (sym: Symbol)
279279
private def isOriginallyStaticOwner: Boolean =
280280
sym.is(PackageClass) || sym.is(ModuleClass) && sym.originalOwner.originalLexicallyEnclosingClass.isOriginallyStaticOwner
281281

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ object DottyBackendInterface {
125125
}
126126

127127
given symExtensions: AnyRef with
128-
extension (sym: Symbol):
128+
extension (sym: Symbol)
129129

130130
def isInterface(using Context): Boolean = (sym.is(PureInterface)) || sym.is(Trait)
131131

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
11481148
!(sym.is(Method) && sym.info.isInstanceOf[MethodOrPoly]) // if is a method it is parameterless
11491149
}
11501150

1151-
extension (xs: List[tpd.Tree]):
1151+
extension (xs: List[tpd.Tree])
11521152
def tpes: List[Type] = xs match {
11531153
case x :: xs1 => x.tpe :: xs1.tpes
11541154
case nil => Nil

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import ast.untpd
99
/** Extension methods for contexts where we want to keep the ctx.<methodName> syntax */
1010
object ContextOps:
1111

12-
extension (ctx: Context):
12+
extension (ctx: Context)
1313

1414
/** Enter symbol into current class, if current class is owner of current context,
1515
* or into current scope, if not. Should always be called instead of scope.enter

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ object Contexts {
650650
}
651651

652652
given ops: AnyRef with
653-
extension (c: Context):
653+
extension (c: Context)
654654
def addNotNullInfo(info: NotNullInfo) =
655655
c.withNotNullInfos(c.notNullInfos.extendWith(info))
656656

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object Decorators {
2828
case s: String => typeName(s)
2929
case n: Name => n.toTypeName
3030

31-
extension (s: String):
31+
extension (s: String)
3232
def splitWhere(f: Char => Boolean, doDropIndex: Boolean): Option[(String, String)] =
3333
def splitAt(idx: Int, doDropIndex: Boolean): Option[(String, String)] =
3434
if (idx == -1) None
@@ -61,7 +61,7 @@ object Decorators {
6161
/** Implements a findSymbol method on iterators of Symbols that
6262
* works like find but avoids Option, replacing None with NoSymbol.
6363
*/
64-
extension (it: Iterator[Symbol]):
64+
extension (it: Iterator[Symbol])
6565
final def findSymbol(p: Symbol => Boolean): Symbol = {
6666
while (it.hasNext) {
6767
val sym = it.next()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2571,7 +2571,7 @@ object TypeComparer {
25712571
*/
25722572
val Fresh: Repr = 4
25732573

2574-
extension (approx: Repr):
2574+
extension (approx: Repr)
25752575
def low: Boolean = (approx & LoApprox) != 0
25762576
def high: Boolean = (approx & HiApprox) != 0
25772577
def addLow: Repr = approx | LoApprox

compiler/src/dotty/tools/dotc/interactive/Completion.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ object Completion {
241241
}
242242
}
243243

244-
// There are four possible ways for an extension method to be applicable:
244+
// There are four possible ways for an extension method to be applicable
245245

246246
// 1. The extension method is visible under a simple name, by being defined or inherited or imported in a scope enclosing the reference.
247247
val extMethodsInScope =

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ object Parsers {
6464
val Spliced = 2
6565
}
6666

67-
extension (buf: ListBuffer[Tree]):
67+
extension (buf: ListBuffer[Tree])
6868
def +++=(x: Tree) = x match {
6969
case x: Thicket => buf ++= x.trees
7070
case x => buf += x
@@ -3565,8 +3565,9 @@ object Parsers {
35653565
val tparams = typeParamClauseOpt(ParamOwner.Def)
35663566
val extParams = paramClause(0, prefix = true)
35673567
val givenParamss = paramClauses(givenOnly = true)
3568-
in.observeColonEOL()
3569-
if (in.token == COLONEOL) in.nextToken()
3568+
if in.token == COLON then
3569+
syntaxError("no `:` expected here")
3570+
in.nextToken()
35703571
val methods =
35713572
if isDefIntro(modifierTokens) then
35723573
extMethod() :: Nil

compiler/src/dotty/tools/dotc/printing/Texts.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ object Texts {
168168
/** The given texts `xs`, each on a separate line */
169169
def lines(xs: Traversable[Text]): Vertical = Vertical(xs.toList.reverse)
170170

171-
extension (text: => Text):
171+
extension (text: => Text)
172172
def provided(cond: Boolean): Text = if (cond) text else Str("")
173173

174174
}

compiler/src/dotty/tools/dotc/printing/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ package object printing {
2222
val XprintMode: Key[Unit] = new Key
2323

2424
/** @pre `nel` is non-empty list */
25-
extension [A](nel: List[A]):
25+
extension [A](nel: List[A])
2626
private[printing] def intersperse(a: A): List[A] =
2727
nel.flatMap(a :: _ :: Nil).tail
2828

compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class ExtractSemanticDB extends Phase:
259259

260260
case _ => None
261261

262-
extension (tpe: Types.Type):
262+
extension (tpe: Types.Type)
263263
private inline def isAnnotatedByUnchecked(using Context) = tpe match
264264
case Types.AnnotatedType(_, annot) => annot.symbol == defn.UncheckedAnnot
265265
case _ => false
@@ -490,12 +490,12 @@ class ExtractSemanticDB extends Phase:
490490
val start = if idx >= 0 then idx else span.start
491491
Span(start, start + sym.name.show.length, start)
492492

493-
extension (list: List[List[ValDef]]):
493+
extension (list: List[List[ValDef]])
494494
private inline def isSingleArg = list match
495495
case (_::Nil)::Nil => true
496496
case _ => false
497497

498-
extension (tree: DefDef):
498+
extension (tree: DefDef)
499499
private def isSetterDef(using Context): Boolean =
500500
tree.name.isSetterName && tree.mods.is(Accessor) && tree.vparamss.isSingleArg
501501

@@ -521,21 +521,21 @@ class ExtractSemanticDB extends Phase:
521521
else limit
522522
Span(start max limit, end)
523523

524-
extension (span: Span):
524+
extension (span: Span)
525525
private def hasLength: Boolean = span.exists && !span.isZeroExtent
526526

527527
/**Consume head while not an import statement.
528528
* Returns the rest of the list after the first import, or else the empty list
529529
*/
530-
extension (body: List[Tree]):
530+
extension (body: List[Tree])
531531
@tailrec private def foreachUntilImport(op: Tree => Unit): List[Tree] = body match
532532
case ((_: Import) :: rest) => rest
533533
case stat :: rest =>
534534
op(stat)
535535
rest.foreachUntilImport(op)
536536
case Nil => Nil
537537

538-
extension (sym: Symbol):
538+
extension (sym: Symbol)
539539
private def adjustIfCtorTyparam(using Context) =
540540
if sym.isType && sym.owner.exists && sym.owner.isConstructor then
541541
matchingMemberType(sym, sym.owner.owner)

compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ object Scala3:
6969

7070

7171
given NameOps: AnyRef with
72-
extension (name: Name):
72+
extension (name: Name)
7373
def isWildcard = name match
7474
case nme.WILDCARD | WILDCARDTypeName => true
7575
case _ => name.is(NameKinds.WildcardParamName)
@@ -90,7 +90,7 @@ object Scala3:
9090
end NameOps
9191

9292
given SymbolOps: AnyRef with
93-
extension (sym: Symbol):
93+
extension (sym: Symbol)
9494

9595
def ifExists(using Context): Option[Symbol] = if sym.exists then Some(sym) else None
9696

@@ -140,13 +140,13 @@ object Scala3:
140140

141141
end LocalSymbol
142142

143-
extension (char: Char):
143+
extension (char: Char)
144144
private inline def isGlobalTerminal = (char: @switch) match
145145
case '/' | '.' | '#' | ']' | ')' => true
146146
case _ => false
147147

148148
given StringOps: AnyRef with
149-
extension (symbol: String):
149+
extension (symbol: String)
150150
def isSymbol: Boolean = !symbol.isEmpty
151151
def isRootPackage: Boolean = RootPackage == symbol
152152
def isEmptyPackage: Boolean = EmptyPackage == symbol
@@ -170,7 +170,7 @@ object Scala3:
170170
end StringOps
171171

172172
given InfoOps: AnyRef with
173-
extension (info: SymbolInformation):
173+
extension (info: SymbolInformation)
174174
def isAbstract: Boolean = (info.properties & SymbolInformation.Property.ABSTRACT.value) != 0
175175
def isFinal: Boolean = (info.properties & SymbolInformation.Property.FINAL.value) != 0
176176
def isSealed: Boolean = (info.properties & SymbolInformation.Property.SEALED.value) != 0
@@ -205,7 +205,7 @@ object Scala3:
205205
end InfoOps
206206

207207
given RangeOps: AnyRef with
208-
extension (range: Range):
208+
extension (range: Range)
209209
def hasLength = range.endLine > range.startLine || range.endCharacter > range.startCharacter
210210
end RangeOps
211211

compiler/src/dotty/tools/dotc/semanticdb/Tools.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,5 @@ object Tools:
144144
sb.append(if occ.role.isReference then " -> " else " <- ").append(occ.symbol).nl
145145
end processOccurrence
146146

147-
extension (sb: StringBuilder):
147+
extension (sb: StringBuilder)
148148
private inline def nl = sb.append(System.lineSeparator)

compiler/src/dotty/tools/dotc/typer/ImportInfo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ object ImportInfo {
3535

3636
ImportInfo(sym, selectors, None, isRootImport = true)
3737

38-
extension (c: Context):
38+
extension (c: Context)
3939
def withRootImports(rootRefs: List[RootRef])(using Context): Context =
4040
rootRefs.foldLeft(c)((ctx, ref) => ctx.fresh.setImportInfo(rootImport(ref)))
4141

compiler/src/dotty/tools/dotc/typer/Nullables.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ object Nullables:
339339
}.traverse(tree)
340340
end extension
341341

342-
extension (tree: Assign):
342+
extension (tree: Assign)
343343
def computeAssignNullable()(using Context): tree.type = tree.lhs match
344344
case TrackedRef(ref) =>
345345
val rhstp = tree.rhs.typeOpt

compiler/src/dotty/tools/dotc/util/LinearMap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ object LinearMap:
1515
def empty[K <: AnyRef, V >: Null <: AnyRef]: LinearMap[K, V] =
1616
immutable.Map.empty[K, V]
1717

18-
extension [K <: AnyRef, V >: Null <: AnyRef](m: LinearMap[K, V]):
18+
extension [K <: AnyRef, V >: Null <: AnyRef](m: LinearMap[K, V])
1919

2020
def lookup(key: K): V /*| Null*/ = (m: @unchecked) match
2121
case m: immutable.AbstractMap[K, V] @unchecked =>

compiler/src/dotty/tools/dotc/util/LinearSet.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ object LinearSet:
1212

1313
def empty[Elem >: Null <: AnyRef]: LinearSet[Elem] = immutable.Set.empty[Elem]
1414

15-
extension [Elem >: Null <: AnyRef](s: LinearSet[Elem]):
15+
extension [Elem >: Null <: AnyRef](s: LinearSet[Elem])
1616

1717
def contains(elem: Elem): Boolean = (s: @unchecked) match
1818
case s: immutable.AbstractSet[Elem] @unchecked => s.contains(elem)

compiler/src/dotty/tools/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ package object tools {
2525
throw new UnsupportedOperationException(methodName)
2626

2727
/** Forward-ported from the explicit-nulls branch. */
28-
extension [T](x: T | Null):
28+
extension [T](x: T | Null)
2929

3030
/** Assert `x` is non null and strip `Null` from type */
3131
inline def nn: T =

compiler/src/dotty/tools/repl/Rendering.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) {
142142

143143
object Rendering {
144144

145-
extension (s: Symbol):
145+
extension (s: Symbol)
146146
def showUser(using Context): String = {
147147
val printer = new ReplPrinter(ctx)
148148
val text = printer.dclText(s)

compiler/src/dotty/tools/repl/results.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ object results {
1414
/** Result is a type alias for an Either with left value `Errors` */
1515
type Result[+A] = scala.util.Either[Errors, A]
1616

17-
extension [A](a: A):
17+
extension [A](a: A)
1818
def result: Result[A] = scala.util.Right(a)
1919

20-
extension [A](xs: Errors):
20+
extension [A](xs: Errors)
2121
def errors: Result[A] = scala.util.Left(xs)
2222

2323
}

compiler/src/scala/quoted/runtime/impl/Matcher.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ object Matcher {
135135
case _ => notMatched
136136
}
137137

138-
extension (scrutinees: List[Tree]):
138+
extension (scrutinees: List[Tree])
139139
/** Check that all trees match with =?= and concatenate the results with &&& */
140140
private def =?= (patterns: List[Tree])(using Env): Matching =
141141
matchLists(scrutinees, patterns)(_ =?= _)
142142

143-
extension (scrutinee0: Tree):
143+
extension (scrutinee0: Tree)
144144
/** Check that the trees match and return the contents from the pattern holes.
145145
* Return None if the trees do not match otherwise return Some of a tuple containing all the contents in the holes.
146146
*
@@ -408,7 +408,7 @@ object Matcher {
408408
val matched: Matching = Some(Tuple())
409409
def matched(x: Any): Matching = Some(Tuple1(x))
410410

411-
extension (self: Matching):
411+
extension (self: Matching)
412412
def asOptionOfTuple: Option[Tuple] = self
413413

414414
/** Concatenates the contents of two successful matchings or return a `notMatched` */

0 commit comments

Comments
 (0)