Skip to content

Commit 97ebc45

Browse files
committed
Add sections on dropped features
1 parent 5a44430 commit 97ebc45

9 files changed

+181
-25
lines changed
Lines changed: 29 additions & 0 deletions
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+
Lines changed: 11 additions & 0 deletions
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.
Lines changed: 33 additions & 0 deletions
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+
Lines changed: 13 additions & 0 deletions
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.
Lines changed: 19 additions & 0 deletions
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+
Lines changed: 15 additions & 0 deletions
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

Lines changed: 9 additions & 0 deletions
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

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,58 @@ sidebar:
33
url: blog/index.html
44
- title: Reference
55
subsection:
6-
- title: Dropped Features
6+
- title: New Types
77
subsection:
8-
- title: DelayedInit
9-
url: docs/reference/dropped/delayed-init.md
10-
- title: Macros
11-
url: docs/reference/dropped/macros.md
12-
- title: Implicit Function Types
13-
url: docs/reference/implicit-function-types.md
14-
- title: Intersection types
15-
url: docs/reference/intersection-types.html
16-
- title: Union types
17-
url: docs/reference/union-types.html
18-
- title: Type lambdas
19-
url: docs/reference/type-lambdas.html
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
2024
- title: Trait Parameters
2125
url: docs/reference/trait-parameters.html
22-
- title: Enumerations
23-
url: docs/reference/enums.html
24-
- title: Algebraic Data Types
25-
url: docs/reference/adts.html
26-
- title: Enum Translation
27-
url: docs/reference/desugarEnums.html
2826
-title: Multiversal Equality
2927
url: docs/reference/multiversal-equality.html
30-
- title: By-Name Implicits
31-
url: docs/reference/implicit-by-name-parameters.htmldocs/reference/implicit-by-name-parameters.html
32-
- title: Auto Parameter Tupling
33-
url: docs/reference/auto-parameter-tupling.html
34-
- title: Named Type Arguments
35-
url: docs/reference/named-typeargs.html
3628
- title: Inline
3729
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
3858
- title: Usage
3959
subsection:
4060
- title: sbt-projects

tests/neg/class-shadowing.scala

Lines changed: 7 additions & 0 deletions
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+
}

0 commit comments

Comments
 (0)