Skip to content

Commit ec92d30

Browse files
authored
Merge pull request #2583 from dotty-staging/add-reference-2
Add section on dropping DelayedInit
2 parents d207e7e + 28f2f23 commit ec92d30

12 files changed

+225
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
layout: doc-page
3+
title: Dropped: Class Shadowing
4+
---
5+
6+
Scala so far allowed patterns like this:
7+
8+
class Base {
9+
class Ops { ... }
10+
}
11+
12+
class Sub extends Base {
13+
class Ops { ... }
14+
}
15+
16+
Dotty rejects this with the error message:
17+
18+
6 | class Ops { }
19+
| ^
20+
|class Ops cannot have the same name as class Ops in class Base -- class definitions cannot be overridden
21+
22+
The issue is that the two `Ops` classes _look_ like one overrides the
23+
other, but classes in Scala cannot be overridden. To keep things clean
24+
(and its internal operations conistent) the Dotty compiler forces you
25+
to rename the inner classes so that their names are different.
26+
27+
28+
29+
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
layout: doc-page
3+
title: Dropped: Delayedinit
4+
---
5+
6+
The special handling of the `DelayedInit` trait is no longer
7+
supported.
8+
9+
One consequence is that the `App` class, which used `DelayedInit` is
10+
now partially broken. You can still use `App` for an easy and concise
11+
way to set up a main program. Example:
12+
13+
object HelloWorld extends App {
14+
println("Hello, world!")
15+
}
16+
17+
However, the code is now run in the initializer of the object, which on
18+
some JVM's means that it will only be interpreted. So, better not use it
19+
for benchmarking! Also, if you want to access the command line arguments,
20+
you need to use an explicit `main` method for that.
21+
22+
object Hello {
23+
def main(args: Array[String]) =
24+
println(s"Hello, ${args(0)}")
25+
}
26+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
layout: doc-page
3+
title: Dropped: Early Initializers
4+
---
5+
6+
Early initializers of the form
7+
8+
class C extends { ... } with SuperClass ...
9+
10+
have been dropped. They were rarely used, and mostly to compensate for the lack of
11+
[trait parameters](../trait-parameters.md), which are now directly supported in Dotty.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
layout: doc-page
3+
title: Dropped: Existential Types
4+
---
5+
6+
Existential types using `forSome` have been dropped. The reasons for dropping them were:
7+
8+
- Existential types violate a type soundness principle on which DOT
9+
and Dotty are constructed. That principle says that every the
10+
prefix (`p`, respectvely `S`) of a type selection `p.T` or `S#T`
11+
must either come from a value constructed at runtime or refer to a
12+
type that is known to have only good bounds.
13+
14+
- Existential types create many difficult feature interactions
15+
with other Scala constructs.
16+
17+
- Existential types have large overlap with path-dependent types,
18+
so the gain of having them is relatively minor.
19+
20+
Existential types that can be expressed using only wildcards (but not
21+
`forSome`) are still supported, but are treated as refined types.
22+
For instance, the type
23+
24+
Map[_ <: AnyRef, Int]
25+
26+
is treated as the type `Map`, where the first type parameter
27+
is upper-bounded by `AnyRef` and the second type parameter is an alias
28+
of `Int`.
29+
30+
When reading classfiles compiled with _scalac_, Dotty will do a best
31+
effort to approximate existential types with its own types. It will
32+
issue a warning is a precise emulation is not possible.
33+
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
layout: doc-page
3+
title: Dropped: Limit 22
4+
---
5+
6+
The limit of 22 for the maximal number of parameters of function types
7+
has been dropped. Functions can now have an arbitrary number of
8+
parameters. Functions beyond Function22 are represented with a new trait
9+
`scala.FunctionXXL`.
10+
11+
The limit of 22 for the size of tuples is about to be dropped. Tuples
12+
will in the future be represented by an HList-like structure which can
13+
be arbitrarily large.

docs/docs/reference/dropped/macros.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
layout: doc-page
3+
title: Dropped: Macros
4+
---
5+
6+
The previous, experimental macro system has been dropped. Instead,
7+
there is a cleaner, more restricted system based on two complementary
8+
concepts: `inline` and `meta`.
9+
10+
`inline` has been [implemented](../inline.md) in Dotty.
11+
12+
`meta` is worked on in the separate [Scalameta](http://scalameta.org) project
13+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
layout: doc-page
3+
title: Dropped: Procedure Syntax
4+
---
5+
6+
Procedure syntax
7+
8+
def f() { ... }
9+
10+
has been dropped. You need to write one of the following instead:
11+
12+
def f() = { ... }
13+
def f(): Unit = { ... }
14+
15+
Dotty will accept the old syntax under the `-language:Scala2` option.
16+
If the `-migration` option is set, it can even rewrite old syntax to new.
17+
The [ScalaFix](https://scalacenter.github.io/scalafix/) tool also
18+
can rewrite procedure syntax to make it Dotty-compatible.
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
layout: doc-page
3+
title: Dropped: General Type Projection
4+
---
5+
6+
Scala so far allowed general type projection `T#A` where `T` is an arbitrary type
7+
and `A` names a type member of `T`.
8+
9+
Dotty allows this only if `T` is a class type. The change was made because
10+
unrestricted type projection is [unsound](https://github.com/lampepfl/dotty/issues/1050).
11+
12+
The restriction rule out the [type-level encoding of compbinator
13+
calculus](https://michid.wordpress.com/2010/01/29/scala-type-level-encoding-of-the-ski-calculus/). It also rules out the previous encodings of type
14+
lambdas using structural types with projection as application. Type
15+
lambdas are now [directly supported](../type-lambdas.md) in Dotty.

docs/docs/reference/dropped/xml.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
layout: doc-page
3+
title: Dropped: XML Literals
4+
---
5+
6+
XML Literals are still supported, but will be dropped in the near future, to
7+
be replaced with XML string interpolation
8+
9+
xml""" ... """

docs/sidebar.yml

+47-21
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,58 @@ sidebar:
33
url: blog/index.html
44
- title: Reference
55
subsection:
6-
- title: Implicit Function Types
7-
url: docs/reference/implicit-function-types.md
8-
- title: Intersection types
9-
url: docs/reference/intersection-types.html
10-
- title: Union types
11-
url: docs/reference/union-types.html
12-
- title: Type lambdas
13-
url: docs/reference/type-lambdas.html
6+
- title: New Types
7+
subsection:
8+
- title: Implicit Function Types
9+
url: docs/reference/implicit-function-types.md
10+
- title: Intersection types
11+
url: docs/reference/intersection-types.html
12+
- title: Union types
13+
url: docs/reference/union-types.html
14+
- title: Type lambdas
15+
url: docs/reference/type-lambdas.html
16+
- title: Enums
17+
subsection:
18+
- title: Enumerations
19+
url: docs/reference/enums.html
20+
- title: Algebraic Data Types
21+
url: docs/reference/adts.html
22+
- title: Translation
23+
url: docs/reference/desugarEnums.html
1424
- title: Trait Parameters
1525
url: docs/reference/trait-parameters.html
16-
- title: Enumerations
17-
url: docs/reference/enums.html
18-
- title: Algebraic Data Types
19-
url: docs/reference/adts.html
20-
- title: Enum Translation
21-
url: docs/reference/desugarEnums.html
22-
- title: Multiversal Equality
26+
-title: Multiversal Equality
2327
url: docs/reference/multiversal-equality.html
24-
- title: By-Name Implicits
25-
url: docs/reference/implicit-by-name-parameters.htmldocs/reference/implicit-by-name-parameters.html
26-
- title: Auto Parameter Tupling
27-
url: docs/reference/auto-parameter-tupling.html
28-
- title: Named Type Arguments
29-
url: docs/reference/named-typeargs.html
3028
- title: Inline
3129
url: docs/reference/inline.html
30+
- title: Smaller Changes
31+
subsection:
32+
- title: By-Name Implicits
33+
url: docs/reference/implicit-by-name-parameters.html
34+
- title: Auto Parameter Tupling
35+
url: docs/reference/auto-parameter-tupling.html
36+
- title: Named Type Arguments
37+
url: docs/reference/named-typeargs.html
38+
- title: Dropped Features
39+
subsection:
40+
- title: DelayedInit
41+
url: docs/reference/dropped/delayed-init.md
42+
- title: Macros
43+
url: docs/reference/dropped/macros.md
44+
- title: Existential Types
45+
url: docs/reference/dropped/existential-types.md
46+
- title: Type Projection
47+
url: docs/reference/dropped/type-projection.md
48+
- Procedure Syntax
49+
url: docs/reference/dropped/procedure-syntax.md
50+
- title: Early Initializers
51+
url: docs/reference/dropped/early-initializers.md
52+
- title: Class Shadowing
53+
url: docs/reference/dropped/class-shadowing.md
54+
- title: Limit 22
55+
url: docs/reference/dropped/limit22.md
56+
- title: XML literals
57+
url: docs/reference/dropped/xml.md
3258
- title: Usage
3359
subsection:
3460
- title: sbt-projects

tests/neg/class-shadowing.scala

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Base {
2+
class Ops { }
3+
}
4+
5+
class Sub extends Base {
6+
class Ops { } // error: cannot override
7+
}

tests/run/delayedInit.scala

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Test extends App {
2+
println("Hello World: ")
3+
}

0 commit comments

Comments
 (0)