forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlanguage.scala
357 lines (307 loc) · 14.8 KB
/
language.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
package scala.runtime.stdLibPatches
import scala.annotation.compileTimeOnly
/** Scala 3 additions and replacements to the `scala.language` object.
*/
object language:
/** The experimental object contains features that have been recently added but have not
* been thoroughly tested in production yet.
*
* Experimental features '''may undergo API changes''' in future releases, so production
* code should not rely on them.
*
* Programmers are encouraged to try out experimental features and
* [[https://github.com/scala/scala3/issues report any bugs or API inconsistencies]]
* they encounter so they can be improved in future releases.
*
* @group experimental
*/
object experimental:
/* Experimental support for richer dependent types (disabled for now)
* One can still run the compiler with support for parsing singleton applications
* using command line option `-language:experimental.dependent`.
* But one cannot use a feature import for this as long as this entry is commented out.
*/
//object dependent
/** Experimental support for named type arguments.
*
* @see [[https://dotty.epfl.ch/docs/reference/other-new-features/named-typeargs]]
*/
@compileTimeOnly("`namedTypeArguments` can only be used at compile time in import statements")
object namedTypeArguments
/** Experimental support for generic number literals.
*
* @see [[https://dotty.epfl.ch/docs/reference/changed-features/numeric-literals]]
*/
@compileTimeOnly("`genericNumberLiterals` can only be used at compile time in import statements")
object genericNumberLiterals
/** Experimental support for `erased` modifier
*
* @see [[https://dotty.epfl.ch/docs/reference/experimental/erased-defs]]
*/
@compileTimeOnly("`erasedDefinitions` can only be used at compile time in import statements")
object erasedDefinitions
/** Experimental support for using indentation for arguments
*/
@compileTimeOnly("`fewerBraces` can only be used at compile time in import statements")
@deprecated("`fewerBraces` is now standard, no language import is needed", since = "3.3")
object fewerBraces
/** Experimental support for typechecked exception capabilities
*
* @see [[https://dotty.epfl.ch/docs/reference/experimental/canthrow]]
*/
@compileTimeOnly("`saferExceptions` can only be used at compile time in import statements")
object saferExceptions
/** Adds support for clause interleaving:
* Methods can now have as many type clauses as they like, this allows to have type bounds depend on terms: `def f(x: Int)[A <: x.type]: A`
*
* @see [[https://github.com/scala/improvement-proposals/blob/main/content/clause-interleaving.md]]
*/
@compileTimeOnly("`clauseInterleaving` can only be used at compile time in import statements")
@deprecated("`clauseInterleaving` is now standard, no language import is needed", since = "3.6")
object clauseInterleaving
/** Experimental support for pure function type syntax
*
* @see [[https://dotty.epfl.ch/docs/reference/experimental/purefuns]]
*/
@compileTimeOnly("`pureFunctions` can only be used at compile time in import statements")
object pureFunctions
/** Experimental support for capture checking; implies support for pureFunctions
*
* @see [[https://dotty.epfl.ch/docs/reference/experimental/cc]]
*/
@compileTimeOnly("`captureChecking` can only be used at compile time in import statements")
object captureChecking
/** Experimental support for automatic conversions of arguments, without requiring
* a language import `import scala.language.implicitConversions`.
*
* @see [[https://dotty.epfl.ch/docs/reference/experimental/into-modifier]]
*/
@compileTimeOnly("`into` can only be used at compile time in import statements")
object into
/** Experimental support for named tuples.
*
* @see [[https://dotty.epfl.ch/docs/reference/experimental/named-tuples]]
*/
@compileTimeOnly("`namedTuples` can only be used at compile time in import statements")
@deprecated("The experimental.namedTuples language import is no longer needed since the feature is now standard", since = "3.7")
object namedTuples
/** Experimental support for new features for better modularity, including
* - better tracking of dependencies through classes
* - better usability of context bounds
* - better syntax and conventions for type classes
* - ability to merge exported types in intersections
*
* @see [[https://dotty.epfl.ch/docs/reference/experimental/modularity]]
* @see [[https://dotty.epfl.ch/docs/reference/experimental/typeclasses]]
*/
@compileTimeOnly("`modularity` can only be used at compile time in import statements")
object modularity
/** Was needed to add support for relaxed imports of extension methods.
* The language import is no longer needed as this is now a standard feature since SIP was accepted.
* @see [[http://dotty.epfl.ch/docs/reference/contextual/extension-methods]]
*/
@compileTimeOnly("`relaxedExtensionImports` can only be used at compile time in import statements")
@deprecated("The experimental.relaxedExtensionImports language import is no longer needed since the feature is now standard", since = "3.4")
object relaxedExtensionImports
/** Enhance match type extractors to follow aliases and singletons.
*
* @see [[https://github.com/scala/improvement-proposals/pull/84]]
*/
@compileTimeOnly("`betterMatchTypeExtractors` can only be used at compile time in import statements")
@deprecated("The experimental.betterMatchTypeExtractors language import is no longer needed since the feature is now standard. It now has no effect, including when setting an older source version.", since = "3.6")
object betterMatchTypeExtractors
/** Experimental support for quote pattern matching with polymorphic functions
*
* @see [[https://dotty.epfl.ch/docs/reference/experimental/quoted-patterns-with-polymorphic-functions]]
*/
@compileTimeOnly("`quotedPatternsWithPolymorphicFunctions` can only be used at compile time in import statements")
object quotedPatternsWithPolymorphicFunctions
/** Experimental support for improvements in `for` comprehensions
*
* @see [[https://github.com/scala/improvement-proposals/pull/79]]
*/
@compileTimeOnly("`betterFors` can only be used at compile time in import statements")
object betterFors
/** Experimental support for package object values
*/
@compileTimeOnly("`packageObjectValues` can only be used at compile time in import statements")
object packageObjectValues
end experimental
/** The deprecated object contains features that are no longer officially suypported in Scala.
* Features in this object are slated for removal. New code should not use them and
* old code should migrate away from them.
*/
@compileTimeOnly("`deprecated` can only be used at compile time in import statements")
object deprecated:
/** Symbol literals have been deprecated since 2.13. Since Scala 3.0 they
* are no longer an official part of Scala. For compatibility with legacy software,
* symbol literals are still supported with a language import, but new software
* should not use them.
*/
@compileTimeOnly("`symbolLiterals` can only be used at compile time in import statements")
object symbolLiterals
end deprecated
/** Where imported, auto-tupling is disabled.
*
* '''Why control the feature?''' Auto-tupling can lead to confusing and
* brittle code in presence of overloads. In particular, surprising overloads
* can be selected, and adding new overloads can change which overload is selected
* in suprising ways.
*
* '''Why allow it?''' Not allowing auto-tupling is difficult to reconcile with
* operators accepting tuples.
*/
@compileTimeOnly("`noAutoTupling` can only be used at compile time in import statements")
object noAutoTupling
/** Where imported, loose equality using eqAny is disabled.
*
* '''Why allow and control the feature?''' For compatibility and migration reasons,
* strict equality is opt-in. See linked documentation for more information.
*
* @see [[https://dotty.epfl.ch/docs/reference/contextual/multiversal-equality]]
*/
@compileTimeOnly("`strictEquality` can only be used at compile time in import statements")
object strictEquality
/** Where imported, ad hoc extensions of non-open classes in other
* compilation units are allowed.
*
* '''Why control the feature?''' Ad-hoc extensions should usually be avoided
* since they typically cannot rely on an "internal" contract between a class
* and its extensions. Only open classes need to specify such a contract.
* Ad-hoc extensions might break for future versions of the extended class,
* since the extended class is free to change its implementation without
* being constrained by an internal contract.
*
* '''Why allow it?''' An ad-hoc extension can sometimes be necessary,
* for instance when mocking a class in a testing framework, or to work
* around a bug or missing feature in the original class. Nevertheless,
* such extensions should be limited in scope and clearly documented.
* That's why the language import is required for them.
*/
@compileTimeOnly("`adhocExtensions` can only be used at compile time in import statements")
object adhocExtensions
/** Unsafe Nulls fot Explicit Nulls
* Inside the "unsafe" scope, `Null` is considered as a subtype of all reference types.
*
* @see [[http://dotty.epfl.ch/docs/reference/other-new-features/explicit-nulls.html]]
*/
@compileTimeOnly("`unsafeNulls` can only be used at compile time in import statements")
object unsafeNulls
@compileTimeOnly("`future` can only be used at compile time in import statements")
object future
@compileTimeOnly("`future-migration` can only be used at compile time in import statements")
object `future-migration`
/** Set source version to 3.0-migration.
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.0-migration` can only be used at compile time in import statements")
object `3.0-migration`
/** Set source version to 3.0.
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.0` can only be used at compile time in import statements")
object `3.0`
/** Set source version to 3.1-migration.
*
* This is a no-op, and should not be used. A syntax error will be reported upon import.
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.1-migration` can only be used at compile time in import statements")
@deprecated("`3.1-migration` is not valid, use `3.1` instead", since = "3.2")
object `3.1-migration`
/** Set source version to 3.1
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.1` can only be used at compile time in import statements")
object `3.1`
/** Set source version to 3.2-migration.
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.2-migration` can only be used at compile time in import statements")
object `3.2-migration`
/** Set source version to 3.2
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.2` can only be used at compile time in import statements")
object `3.2`
/** Set source version to 3.3-migration.
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.3-migration` can only be used at compile time in import statements")
object `3.3-migration`
/** Set source version to 3.3
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.3` can only be used at compile time in import statements")
object `3.3`
/** Set source version to 3.4-migration.
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.4-migration` can only be used at compile time in import statements")
object `3.4-migration`
/** Set source version to 3.4
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.4` can only be used at compile time in import statements")
object `3.4`
/** Set source version to 3.5-migration.
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.5-migration` can only be used at compile time in import statements")
object `3.5-migration`
/** Set source version to 3.5
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.5` can only be used at compile time in import statements")
object `3.5`
/** Set source version to 3.6-migration.
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.6-migration` can only be used at compile time in import statements")
object `3.6-migration`
/** Set source version to 3.6
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.6` can only be used at compile time in import statements")
object `3.6`
/** Set source version to 3.7-migration.
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.7-migration` can only be used at compile time in import statements")
object `3.7-migration`
/** Set source version to 3.7
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.7` can only be used at compile time in import statements")
object `3.7`
/** Set source version to 3.8-migration.
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.8-migration` can only be used at compile time in import statements")
object `3.8-migration`
/** Set source version to 3.8
*
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
*/
@compileTimeOnly("`3.8` can only be used at compile time in import statements")
object `3.8`
// !!! Keep in sync with dotty.tools.dotc.config.SourceVersion !!!
// Also add tests in `tests/pos/source-import-3-x.scala` and `tests/pos/source-import-3-x-migration.scala`
end language