@@ -74,11 +74,8 @@ object desugar {
74
74
def derivedTree (sym : Symbol )(implicit ctx : Context ): tpd.Tree = tpd.ref(sym)
75
75
}
76
76
77
- /** A type tree that computes its type from an existing parameter.
78
- * @param suffix String difference between existing parameter (call it `P`) and parameter owning the
79
- * DerivedTypeTree (call it `O`). We have: `O.name == P.name + suffix`.
80
- */
81
- class DerivedFromParamTree (suffix : String )(implicit @ constructorOnly src : SourceFile ) extends DerivedTypeTree {
77
+ /** A type tree that computes its type from an existing parameter. */
78
+ class DerivedFromParamTree (implicit @ constructorOnly src : SourceFile ) extends DerivedTypeTree {
82
79
83
80
/** Make sure that for all enclosing module classes their companion classes
84
81
* are completed. Reason: We need the constructor of such companion classes to
@@ -96,24 +93,20 @@ object desugar {
96
93
97
94
/** Return info of original symbol, where all references to siblings of the
98
95
* original symbol (i.e. sibling and original symbol have the same owner)
99
- * are rewired to like -named* parameters or accessors in the scope enclosing
96
+ * are rewired to same -named parameters or accessors in the scope enclosing
100
97
* the current scope. The current scope is the scope owned by the defined symbol
101
98
* itself, that's why we have to look one scope further out. If the resulting
102
99
* type is an alias type, dealias it. This is necessary because the
103
100
* accessor of a type parameter is a private type alias that cannot be accessed
104
101
* from subclasses.
105
- *
106
- * (*) like-named means:
107
- *
108
- * parameter name == reference name ++ suffix
109
102
*/
110
103
def derivedTree (sym : Symbol )(implicit ctx : Context ): tpd.TypeTree = {
111
104
val relocate = new TypeMap {
112
105
val originalOwner = sym.owner
113
106
def apply (tp : Type ) = tp match {
114
107
case tp : NamedType if tp.symbol.exists && (tp.symbol.owner eq originalOwner) =>
115
108
val defctx = ctx.outersIterator.dropWhile(_.scope eq ctx.scope).next()
116
- var local = defctx.denotNamed(tp.name ++ suffix ).suchThat(_.isParamOrAccessor).symbol
109
+ var local = defctx.denotNamed(tp.name).suchThat(_.isParamOrAccessor).symbol
117
110
if (local.exists) (defctx.owner.thisType select local).dealiasKeepAnnots
118
111
else {
119
112
def msg =
@@ -129,20 +122,19 @@ object desugar {
129
122
}
130
123
131
124
/** A type definition copied from `tdef` with a rhs typetree derived from it */
132
- def derivedTypeParam (tdef : TypeDef , suffix : String = " " )(implicit ctx : Context ): TypeDef =
125
+ def derivedTypeParam (tdef : TypeDef )(implicit ctx : Context ): TypeDef =
133
126
cpy.TypeDef (tdef)(
134
- name = tdef.name ++ suffix,
135
- rhs = DerivedFromParamTree (suffix).withSpan(tdef.rhs.span).watching(tdef)
127
+ rhs = DerivedFromParamTree ().withSpan(tdef.rhs.span).watching(tdef)
136
128
)
137
129
138
130
/** A derived type definition watching `sym` */
139
131
def derivedTypeParam (sym : TypeSymbol )(implicit ctx : Context ): TypeDef =
140
- TypeDef (sym.name, DerivedFromParamTree (" " ).watching(sym)).withFlags(TypeParam )
132
+ TypeDef (sym.name, DerivedFromParamTree ().watching(sym)).withFlags(TypeParam )
141
133
142
134
/** A value definition copied from `vdef` with a tpt typetree derived from it */
143
135
def derivedTermParam (vdef : ValDef )(implicit ctx : Context ): ValDef =
144
136
cpy.ValDef (vdef)(
145
- tpt = DerivedFromParamTree (" " ).withSpan(vdef.tpt.span).watching(vdef))
137
+ tpt = DerivedFromParamTree ().withSpan(vdef.tpt.span).watching(vdef))
146
138
147
139
// ----- Desugar methods -------------------------------------------------
148
140
0 commit comments