@@ -30,18 +30,13 @@ object Mixin {
30
30
31
31
/** This phase performs the following transformations:
32
32
*
33
- * 1. (done in `traitDefs` and `transformSym`) Map every concrete trait getter
33
+ * 1. (done in `traitDefs` and `transformSym`) For every concrete trait getter
34
34
*
35
35
* <mods> def x(): T = expr
36
36
*
37
- * to the pair of definitions :
37
+ * make it non-private, and add the definition of its trait setter :
38
38
*
39
- * <mods> def x(): T
40
- * protected def initial$x(): T = { stats; expr }
41
- *
42
- * where `stats` comprises all statements between either the start of the trait
43
- * or the previous field definition which are not definitions (i.e. are executed for
44
- * their side effects).
39
+ * <mods> def TraitName$_setter_$x(v: T): Unit
45
40
*
46
41
* 2. (done in `traitDefs`) Make every concrete trait setter
47
42
*
@@ -51,61 +46,60 @@ object Mixin {
51
46
*
52
47
* <mods> def x_=(y: T)
53
48
*
54
- * 3. For a non-trait class C:
49
+ * 3. (done in `transformSym`) For every module class constructor in traits,
50
+ * remove its Private flag (but do not expand its name), since it will have
51
+ * to be instantiated in the classes that mix in the trait.
52
+ *
53
+ * 4. For a non-trait class C:
55
54
*
56
55
* For every trait M directly implemented by the class (see SymUtils.mixin), in
57
56
* reverse linearization order, add the following definitions to C:
58
57
*
59
- * 3 .1 (done in `traitInits`) For every parameter accessor `<mods> def x(): T` in M,
58
+ * 4 .1 (done in `traitInits`) For every parameter accessor `<mods> def x(): T` in M,
60
59
* in order of textual occurrence, add
61
60
*
62
61
* <mods> def x() = e
63
62
*
64
63
* where `e` is the constructor argument in C that corresponds to `x`. Issue
65
64
* an error if no such argument exists.
66
65
*
67
- * 3 .2 (done in `traitInits`) For every concrete trait getter `<mods> def x(): T` in M
66
+ * 4 .2 (done in `traitInits`) For every concrete trait getter `<mods> def x(): T` in M
68
67
* which is not a parameter accessor, in order of textual occurrence, produce the following:
69
68
*
70
- * 3 .2.1 If `x` is also a member of `C`, and is a lazy val,
69
+ * 4 .2.1 If `x` is also a member of `C`, and is a lazy val,
71
70
*
72
71
* <mods> lazy val x: T = super[M].x
73
72
*
74
- * 3 .2.2 If `x` is also a member of `C`, and M is a Dotty trait ,
73
+ * 4 .2.2 If `x` is also a member of `C`, and is a module ,
75
74
*
76
- * <mods> def x() : T = super[M].initial$x( )
75
+ * <mods> lazy module val x : T = new T$(this )
77
76
*
78
- * 3 .2.3 If `x` is also a member of `C`, and M is a Scala 2.x trait :
77
+ * 4 .2.3 If `x` is also a member of `C`, and is something else :
79
78
*
80
79
* <mods> def x(): T = _
81
80
*
82
- * 3.2.4 If `x` is not a member of `C`, and M is a Dotty trait:
83
- *
84
- * super[M].initial$x()
85
- *
86
- * 3.2.5 If `x` is not a member of `C`, and M is a Scala2.x trait, nothing gets added.
87
- *
81
+ * 4.2.5 If `x` is not a member of `C`, nothing gets added.
88
82
*
89
- * 3 .3 (done in `superCallOpt`) The call:
83
+ * 4 .3 (done in `superCallOpt`) The call:
90
84
*
91
- * super[M].< init>
85
+ * super[M].$ init$()
92
86
*
93
- * 3 .4 (done in `setters`) For every concrete setter `<mods> def x_=(y: T)` in M:
87
+ * 4 .4 (done in `setters`) For every concrete setter `<mods> def x_=(y: T)` in M:
94
88
*
95
89
* <mods> def x_=(y: T) = ()
96
90
*
97
- * 3 .5 (done in `mixinForwarders`) For every method
91
+ * 4 .5 (done in `mixinForwarders`) For every method
98
92
* `<mods> def f[Ts](ps1)...(psN): U` imn M` that needs to be disambiguated:
99
93
*
100
94
* <mods> def f[Ts](ps1)...(psN): U = super[M].f[Ts](ps1)...(psN)
101
95
*
102
96
* A method in M needs to be disambiguated if it is concrete, not overridden in C,
103
97
* and if it overrides another concrete method.
104
98
*
105
- * 4 . (done in `transformTemplate` and `transformSym`) Drop all parameters from trait
106
- * constructors.
99
+ * 5 . (done in `transformTemplate` and `transformSym`) Drop all parameters from trait
100
+ * constructors, and rename them to `nme.TRAIT_CONSTRUCTOR` .
107
101
*
108
- * 5 . (done in `transformSym`) Drop ParamAccessor flag from all parameter accessors in traits.
102
+ * 6 . (done in `transformSym`) Drop ParamAccessor flag from all parameter accessors in traits.
109
103
*
110
104
* Conceptually, this is the second half of the previous mixin phase. It needs to run
111
105
* after erasure because it copies references to possibly private inner classes and objects
0 commit comments