Skip to content

Commit 46fcfd6

Browse files
committed
Update docs
1 parent 9b530c6 commit 46fcfd6

20 files changed

+55
-54
lines changed

docs/docs/contributing/workflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type stealer:
4545
```bash
4646
$ sbt
4747
> repl
48-
scala> import dotty.tools.DottyTypeStealer._; import dotty.tools.dotc.core._; import Contexts._,Types._
48+
scala> import dotty.tools.DottyTypeStealer.*; import dotty.tools.dotc.core.*; import Contexts.*,Types.*
4949
```
5050

5151
Now, you can define types and access their representation. For example:

docs/docs/reference/changed-features/compiler-plugins.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ zero as errors.
5252
```scala
5353
package dividezero
5454

55-
import dotty.tools.dotc.ast.Trees._
55+
import dotty.tools.dotc.ast.Trees.*
5656
import dotty.tools.dotc.ast.tpd
5757
import dotty.tools.dotc.core.Constants.Constant
5858
import dotty.tools.dotc.core.Contexts.Context
59-
import dotty.tools.dotc.core.Decorators._
60-
import dotty.tools.dotc.core.StdNames._
61-
import dotty.tools.dotc.core.Symbols._
59+
import dotty.tools.dotc.core.Decorators.*
60+
import dotty.tools.dotc.core.StdNames.*
61+
import dotty.tools.dotc.core.Symbols.*
6262
import dotty.tools.dotc.plugins.{PluginPhase, StandardPlugin}
6363
import dotty.tools.dotc.transform.{Pickler, Staging}
6464

@@ -70,7 +70,7 @@ class DivideZero extends StandardPlugin:
7070
(new DivideZeroPhase) :: Nil
7171

7272
class DivideZeroPhase extends PluginPhase:
73-
import tpd._
73+
import tpd.*
7474

7575
val phaseName = "divideZero"
7676

docs/docs/reference/changed-features/main-functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ For instance, the `happyBirthDay` method above would generate additional code eq
6262

6363
```scala
6464
final class happyBirthday:
65-
import scala.util.{CommandLineParser => CLP}
65+
import scala.util.CommandLineParser => CLP
6666
<static> def main(args: Array[String]): Unit =
6767
try
6868
happyBirthday(

docs/docs/reference/contextual/conversions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ conversion from `Int` to `java.lang.Integer` can be defined as follows:
6363
given fromFuture : Conversion[Future[HttpResponse], CompletionArg] = Response(_)
6464
given fromStatusCode: Conversion[Future[StatusCode], CompletionArg] = Status(_)
6565
end CompletionArg
66-
import CompletionArg._
66+
import CompletionArg.*
6767

6868
def complete[T](arg: CompletionArg) = arg match
6969
case Error(s) => ...

docs/docs/reference/contextual/derivation-macro.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ from the signature. The body of the `derived` method is shown below:
4141

4242
```scala
4343
given derived[T: Type](using Quotes): Expr[Eq[T]] =
44-
import quotes.reflect._
44+
import quotes.reflect.*
4545

4646
val ev: Expr[Mirror.Of[T]] = Expr.summon[Mirror.Of[T]].get
4747

@@ -135,8 +135,8 @@ enum Opt[+T]:
135135
The full code is shown below:
136136

137137
```scala
138-
import scala.deriving._
139-
import scala.quoted._
138+
import scala.deriving.*
139+
import scala.quoted.*
140140

141141

142142
trait Eq[T]:
@@ -165,7 +165,7 @@ object Eq:
165165
case '[EmptyTuple] => Nil
166166

167167
given derived[T: Type](using q: Quotes): Expr[Eq[T]] =
168-
import quotes.reflect._
168+
import quotes.reflect.*
169169

170170
val ev: Expr[Mirror.Of[T]] = Expr.summon[Mirror.Of[T]].get
171171

docs/docs/reference/contextual/derivation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def eqProduct[T](p: Mirror.ProductOf[T], elems: List[Eq[_]]): Eq[T] =
231231
Pulling this all together we have the following complete implementation,
232232

233233
```scala
234-
import scala.deriving._
234+
import scala.deriving.*
235235
import scala.compiletime.{erasedValue, summonInline}
236236

237237
inline def summonAll[T <: Tuple]: List[Eq[_]] =
@@ -280,7 +280,7 @@ enum Opt[+T] derives Eq:
280280
case Nn
281281

282282
@main def test =
283-
import Opt._
283+
import Opt.*
284284
val eqoi = summon[Eq[Opt[Int]]]
285285
assert(eqoi.eqv(Sm(23), Sm(23)))
286286
assert(!eqoi.eqv(Sm(23), Sm(13)))

docs/docs/reference/contextual/extension-methods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ object IntOpsEx extends IntOps:
189189
else Some(i / x)
190190

191191
trait SafeDiv:
192-
import IntOpsEx._ // brings safeDiv and safeMod into scope
192+
import IntOpsEx.* // brings safeDiv and safeMod into scope
193193

194194
extension (i: Int) def divide(d: Int): Option[(Int, Int)] =
195195
// extension methods imported and thus in scope

docs/docs/reference/contextual/given-imports.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ object A:
1212
def f(using TC) = ???
1313

1414
object B:
15-
import A._
15+
import A.*
1616
import A.given
1717
...
1818
```
1919

20-
In the code above, the `import A._` clause in object `B` imports all members
20+
In the code above, the `import A.*` clause in object `B` imports all members
2121
of `A` _except_ the given instance `tc`. Conversely, the second import `import A.given` will import _only_ that given instance.
2222
The two import clauses can also be merged into one:
2323

2424
```scala
2525
object B:
26-
import A.{given, _}
26+
import A.{given, *}
2727
...
2828
```
2929

@@ -44,7 +44,7 @@ There are two main benefits arising from these rules:
4444
Since givens can be anonymous it is not always practical to import them by their name, and wildcard imports are typically used instead. By-type imports provide a more specific alternative to wildcard imports, which makes it clearer what is imported. Example:
4545

4646
```scala
47-
import A.{given TC}
47+
import A.given TC
4848
```
4949

5050
This imports any given in `A` that has a type which conforms to `TC`. Importing givens of several types `T1,...,Tn`
@@ -104,14 +104,13 @@ given instances once their user base has migrated.
104104

105105
```
106106
Import ::= ‘import’ ImportExpr {‘,’ ImportExpr}
107-
ImportExpr ::= StableId ‘.’ ImportSpec
108-
ImportSpec ::= id
109-
| ‘_’
110-
| ‘given’
111-
| ‘{’ ImportSelectors) ‘}’
112-
ImportSelectors ::= id [‘=>’ id | ‘=>’ ‘_’] [‘,’ ImportSelectors]
113-
| WildCardSelector {‘,’ WildCardSelector}
114-
WildCardSelector ::= ‘_'
115-
| ‘given’ [InfixType]
116107
Export ::= ‘export’ ImportExpr {‘,’ ImportExpr}
108+
ImportExpr ::= SimpleRef {‘.’ id} ‘.’ ImportSpec
109+
ImportSpec ::= NamedSelector
110+
| WildcardSelector
111+
| ‘{’ ImportSelectors) ‘}’
112+
NamedSelector ::= id [‘as’ (id | ‘_’)]
113+
WildCardSelector ::= ‘*' | ‘given’ [InfixType]
114+
ImportSelectors ::= NamedSelector [‘,’ ImportSelectors]
115+
| WildCardSelector {‘,’ WildCardSelector}
117116
```

docs/docs/reference/dropped-features/nonlocal-returns.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Nonlocal returns are implemented by throwing and catching `scala.runtime.NonLoca
1010
A drop-in library replacement is provided in [`scala.util.control.NonLocalReturns`](http://dotty.epfl.ch/api/scala/util/control/NonLocalReturns$.html). Example:
1111

1212
```scala
13-
import scala.util.control.NonLocalReturns._
13+
import scala.util.control.NonLocalReturns.*
1414

1515
extension [T](xs: List[T])
1616
def has(elem: T): Boolean = returning {

docs/docs/reference/metaprogramming/erased-terms.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ matches. `erasedValue` is implemented with `erased`, so the state machine above
157157
can be encoded as follows:
158158

159159
```scala
160-
import scala.compiletime._
160+
import scala.compiletime.*
161161

162162
sealed trait State
163163
final class On extends State

docs/docs/reference/metaprogramming/inline.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ primitive operations on singleton types. For example,
486486
singleton types, the compiler can evaluate the result of the operation.
487487

488488
```scala
489-
import scala.compiletime.ops.int._
490-
import scala.compiletime.ops.boolean._
489+
import scala.compiletime.ops.int.*
490+
import scala.compiletime.ops.boolean.*
491491

492492
val conjunction: true && true = true
493493
val multiplication: 3 * 5 = 15
@@ -499,7 +499,7 @@ Since type aliases have the same precedence rules as their term-level
499499
equivalents, the operations compose with the expected precedence rules:
500500

501501
```scala
502-
import scala.compiletime.ops.int._
502+
import scala.compiletime.ops.int.*
503503
val x: 1 + 2 * 3 = 7
504504
```
505505

@@ -510,7 +510,7 @@ concatenation. To use both and distinguish the two types from each other, a
510510
match type can dispatch to the correct implementation:
511511

512512
```scala
513-
import scala.compiletime.ops._
513+
import scala.compiletime.ops.*
514514

515515
import scala.annotation.infix
516516

docs/docs/reference/metaprogramming/macros-spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ For instance, here is a version of `power` that generates the multiplications
172172
directly if the exponent is statically known and falls back to the dynamic
173173
implementation of `power` otherwise.
174174
```scala
175-
import scala.quoted._
175+
import scala.quoted.*
176176

177177
inline def power(x: Double, n: Int): Double =
178178
${ powerExpr('x, 'n) }

docs/docs/reference/metaprogramming/macros.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ a boolean expression tree as argument. `assertImpl` evaluates the expression and
2828
prints it again in an error message if it evaluates to `false`.
2929

3030
```scala
31-
import scala.quoted._
31+
import scala.quoted.*
3232

3333
inline def assert(inline expr: Boolean): Unit =
3434
${ assertImpl('expr) }
@@ -229,15 +229,15 @@ Consider the following implementation of a staged interpreter that implements
229229
a compiler through staging.
230230

231231
```scala
232-
import scala.quoted._
232+
import scala.quoted.*
233233

234234
enum Exp:
235235
case Num(n: Int)
236236
case Plus(e1: Exp, e2: Exp)
237237
case Var(x: String)
238238
case Let(x: String, e: Exp, in: Exp)
239239

240-
import Exp._
240+
import Exp.*
241241
```
242242

243243
The interpreted language consists of numbers `Num`, addition `Plus`, and variables
@@ -253,7 +253,7 @@ language to quoted Scala code of type `Expr[Int]`.
253253
The compiler takes an environment that maps variable names to Scala `Expr`s.
254254

255255
```scala
256-
import scala.quoted._
256+
import scala.quoted.*
257257

258258
def compile(e: Exp, env: Map[String, Expr[Int]])(using Quotes): Expr[Int] =
259259
e match

docs/docs/reference/metaprogramming/reflection.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@ guarantees and may fail at macro expansion time, hence additional explicit
1919
checks must be done.
2020

2121
To provide reflection capabilities in macros we need to add an implicit parameter
22-
of type `scala.quoted.Quotes` and import `quotes.reflect._` from it in the scope
22+
of type `scala.quoted.Quotes` and import `quotes.reflect.*` from it in the scope
2323
where it is used.
2424

2525
```scala
26-
import scala.quoted._
26+
import scala.quoted.*
2727

2828
inline def natConst(inline x: Int): Int = ${natConstImpl('{x})}
2929

3030
def natConstImpl(x: Expr[Int])(using Quotes): Expr[Int] =
31-
import quotes.reflect._
31+
import quotes.reflect.*
3232
...
3333
```
3434

3535
### Extractors
3636

37-
`import quotes.reflect._` will provide all extractors and methods on `quotes.reflect.Tree`s.
37+
`import quotes.reflect.*` will provide all extractors and methods on `quotes.reflect.Tree`s.
3838
For example the `Literal(_)` extractor used below.
3939

4040
```scala
4141
def natConstImpl(x: Expr[Int])(using Quotes): Expr[Int] =
42-
import quotes.reflect._
42+
import quotes.reflect.*
4343
val tree: Term = x.asTerm
4444
tree match
4545
case Inlined(_, _, Literal(IntConstant(n))) =>
@@ -78,7 +78,7 @@ expansion point.
7878

7979
```scala
8080
def macroImpl()(quotes: Quotes): Expr[Unit] =
81-
import quotes.reflect._
81+
import quotes.reflect.*
8282
val pos = Position.ofMacroExpansion
8383

8484
val path = pos.sourceFile.jpath.toString

docs/docs/reference/metaprogramming/staging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ expression at runtime. Within the scope of `staging.run` we can also invoke `sho
104104
to get a source-like representation of the expression.
105105

106106
```scala
107-
import scala.quoted._
107+
import scala.quoted.*
108108

109109
// make available the necessary compiler for runtime code generation
110110
given staging.Compiler = staging.Compiler.make(getClass.getClassLoader)

docs/docs/reference/metaprogramming/tasty-inspect.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ through the TASTy reflect API.
1818
To inspect the trees of a TASTy file a consumer can be defined in the following way.
1919

2020
```scala
21-
import scala.quoted._
22-
import scala.tasty.inspector._
21+
import scala.quoted.*
22+
import scala.tasty.inspector.*
2323

2424
class MyInspector extends Inspector:
2525
def inspect(using Quotes)(tastys: List[Tasty[quotes.type]]): Unit =
26-
import quotes.reflect._
26+
import quotes.reflect.*
2727
for tasty <- tastys do
2828
val tree = tasty.ast
2929
// Do something with the tree

docs/docs/reference/other-new-features/opaques.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ two types. Hence, the following usage scenario type-checks.
111111

112112
```scala
113113
object User:
114-
import Access._
114+
import Access.*
115115

116116
case class Item(rights: Permissions)
117117

docs/docs/reference/other-new-features/type-test.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Using `ClassTag` instances was unsound since classtags can check only the class
113113
Given the following abstract definition of Peano numbers that provides two given instances of types `TypeTest[Nat, Zero]` and `TypeTest[Nat, Succ]`
114114

115115
```scala
116-
import scala.reflect._
116+
import scala.reflect.*
117117

118118
trait Peano:
119119
type Nat
@@ -129,7 +129,7 @@ trait Peano:
129129
def apply(nat: Nat): Succ
130130
def unapply(nat: Succ): Option[Nat]
131131

132-
given typeTestOfZero: TypeTest[Nat, Zero]
132+
given typeTestOfZero: TypeTest[Nat, Zero]
133133
given typeTestOfSucc: TypeTest[Nat, Succ]
134134
```
135135

@@ -162,7 +162,7 @@ it is possible to write the following program
162162

163163
```scala
164164
@main def test =
165-
import PeanoInt._
165+
import PeanoInt.*
166166

167167
def divOpt(m: Nat, n: Nat): Option[(Nat, Nat)] =
168168
n match

docs/docs/usage/cbt-projects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cbt comes with built-in Dotty support. Follow the
1111

1212
```scala
1313
// build/build.scala
14-
import cbt._
14+
import cbt.*
1515
class Build(val context: Context) extends Dotty {
1616
...
1717
}

docs/sidebar.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ sidebar:
115115
url: docs/reference/other-new-features/control-syntax.html
116116
- title: Optional Braces
117117
url: docs/reference/other-new-features/indentation.html
118+
- title: Imports
119+
url: docs/reference/other-new-features/imports.html
118120
- title: Explicit Nulls
119121
url: docs/reference/other-new-features/explicit-nulls.html
120122
- title: Safe Initialization

0 commit comments

Comments
 (0)