@@ -187,23 +187,19 @@ class TreeTypeMap(
187
187
*/
188
188
def withMappedSyms (syms : List [Symbol ], mapped : List [Symbol ]): TreeTypeMap = {
189
189
val symsChanged = syms ne mapped
190
- val origTypeParams = syms.filter(_.isClass).flatMap(_.typeParams)
191
- val mappedTypeParams = mapped.filter(_.isClass).flatMap(_.typeParams)
192
- assert(origTypeParams.hasSameLengthAs(mappedTypeParams))
193
- val substMap = withSubstitution(syms ++ origTypeParams, mapped ++ mappedTypeParams)
190
+ val substMap = withSubstitution(syms, mapped)
191
+ lazy val origCls = mapped.zip(syms).filter(_._1.isClass).toMap
194
192
val fullMap = mapped.filter(_.isClass).foldLeft(substMap) { (tmap, cls) =>
195
193
val origDcls = cls.info.decls.toList.filterNot(_.is(TypeParam ))
196
194
val mappedDcls = mapSymbols(origDcls, tmap)
197
- // type parameters were already copied in the `mapSymbols` call which produced `mapped`.
198
- val tmap1 = tmap
199
- // .withSubstitution(origTypeParams, cls.typeParams)
200
- // type parameters were already mapped in the `mapSymbols` call which produced `mapped`.
201
- .withMappedSyms(origDcls, mappedDcls)
202
- if (symsChanged)
195
+ val tmap1 = tmap.withMappedSyms(
196
+ origCls(cls).typeParams ::: origDcls,
197
+ cls.typeParams ::: mappedDcls)
198
+ if symsChanged then
203
199
origDcls.lazyZip(mappedDcls).foreach(cls.asClass.replace)
204
200
tmap1
205
201
}
206
- if ( symsChanged || (fullMap eq substMap)) fullMap
202
+ if symsChanged || (fullMap eq substMap) then fullMap
207
203
else withMappedSyms(syms, mapAlways = true )
208
204
}
209
205
}
0 commit comments