Skip to content

Commit 8e65a2c

Browse files
committed
Spec: Rewrite the type system fundamentals.
There are two fundamental differences between the type sytems of Scala 2 and 3, which made a fundamental rewrite desirable: - Scala 2 defines path-dependent types in terms of type projections, whereas Scala 3 is path-dependent first, and has not general type projects. - Scala 2 has ad hod higher-kinded type parameters and polymorphic type aliases, whereas Scala 3 has first-class type lambdas and is fundamentally higher order. We therefore rewrite the entire type system section of the spec to be higher-kinded and path-dependent first. In the process, we also revise refined types to better fit the path-dependent nature. I (sjrd) took the liberty to add myself as a contributor in the index page of the spec, as I believe this constitutes a fundamental contribution to the language specification.
1 parent 4e4552e commit 8e65a2c

File tree

5 files changed

+781
-459
lines changed

5 files changed

+781
-459
lines changed

docs/_docs/internals/syntax.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ SimpleType1 ::= id
201201
Singleton ::= SimpleRef
202202
| SimpleLiteral
203203
| Singleton ‘.’ id
204-
Singletons ::= Singleton { ‘,’ Singleton }
205204
FunArgType ::= [`erased`] Type
206205
| [`erased`] ‘=>’ Type PrefixOp(=>, t)
207206
FunArgTypes ::= FunArgType { ‘,’ FunArgType }
@@ -357,8 +356,8 @@ ClsParam ::= {Annotation}
357356
[{Modifier} (‘val’ | ‘var’) | ‘inline’] Param
358357
359358
DefParamClauses ::= DefParamClause { DefParamClause } -- and two DefTypeParamClause cannot be adjacent
360-
DefParamClause ::= DefTypeParamClause
361-
| DefTermParamClause
359+
DefParamClause ::= DefTypeParamClause
360+
| DefTermParamClause
362361
| UsingParamClause
363362
TypelessClauses ::= TypelessClause {TypelessClause}
364363
TypelessClause ::= DefTermParamClause

docs/_spec/02-identifiers-names-and-scopes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ In that case, the type of ´x´ is the type of the referenced entity.
5353

5454
A reference to a qualified (type- or term-) identifier ´e.x´ refers to the member of the type ´T´ of ´e´ which has the name ´x´ in the same namespace as the identifier.
5555
It is an error if ´T´ is not a [value type](03-types.html#value-types).
56-
The type of ´e.x´ is the member type of the referenced entity in ´T´.
56+
The type of ´e.x´ is specified as a [type designator](03-types.html#type-designators).
5757

5858
Binding precedence implies that the way source is bundled in files affects name resolution.
5959
In particular, imported names have higher precedence than names, defined in other files, that might otherwise be visible because they are defined in either the current package or an enclosing package.

0 commit comments

Comments
 (0)