File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ AnnotType1 ::= SimpleType1 {Annotation}
196196
197197SimpleType ::= SimpleLiteral SingletonTypeTree(l)
198198 | ‘?’ TypeBounds
199- | SimpleType1
199+ | SimpleType1 {ParArgumentExprs}
200200SimpleType1 ::= id Ident(name)
201201 | Singleton ‘.’ id Select(t, name)
202202 | Singleton ‘.’ ‘type’ SingletonTypeTree(p)
Original file line number Diff line number Diff line change @@ -196,6 +196,33 @@ LocalModifier ::= ‘tracked’
196196
197197The (soft) ` tracked ` modifier is allowed as a local modifier.
198198
199+ ## Applied constructor types
200+
201+ A new syntax is also introduced, to make classes with ` tracked ` parameters
202+ easier to use. The new syntax is essentially the ability to use an application
203+ of a class constructor as a type, we call such types applied constructor types.
204+
205+ With this new feature the following example compiles correctly and the type in
206+ the comment is the resulting type of the applied constructor types.
207+
208+ ``` scala
209+ import scala .language .experimental .modularity
210+
211+ class Box (tracked val v : Any )
212+
213+ val c : C (42 ) /* C { val v: 42 } */ = C (42 )
214+ ```
215+
216+ ### Syntax change
217+
218+ ```
219+ SimpleType ::= SimpleLiteral
220+ | ‘?’ TypeBounds
221+ --- | SimpleType1
222+ +++ | SimpleType1 {ParArgumentExprs}
223+ ```
224+
225+ A ` SimpleType ` can now optionally be followed by ` ParArgumentExprs ` .
199226
200227## Allow Class Parents to be Refined Types
201228
You can’t perform that action at this time.
0 commit comments