File tree 3 files changed +26
-5
lines changed 3 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ import dotty.tools.dotc.transform.SymUtils._
33
33
* gets two different denotations in the same period. Hence, if -Yno-double-bindings is
34
34
* set, we would get a data race assertion error.
35
35
*/
36
- final class TreeTypeMap (
36
+ class TreeTypeMap (
37
37
val typeMap : Type => Type = IdentityTypeMap ,
38
38
val treeMap : tpd.Tree => tpd.Tree = identity _,
39
39
val oldOwners : List [Symbol ] = Nil ,
Original file line number Diff line number Diff line change @@ -176,7 +176,8 @@ class TypeSpecializer extends MiniPhaseTransform with InfoTransformer {
176
176
val tmap : (Tree => Tree ) = _ match {
177
177
case Return (t, from) if from.symbol == tree.symbol => Return (t, ref(newSym))
178
178
case t : TypeApply => transformTypeApply(t)
179
- case t : Apply => transformApply(t)
179
+ case t : Apply =>
180
+ transformApply(t)
180
181
case t => t
181
182
}
182
183
@@ -188,7 +189,21 @@ class TypeSpecializer extends MiniPhaseTransform with InfoTransformer {
188
189
,
189
190
oldOwners = tree.symbol :: Nil ,
190
191
newOwners = newSym :: Nil
191
- ).transform(tree.rhs)
192
+ ) {
193
+ // needed to workaround https://github.com/lampepfl/dotty/issues/592
194
+ override def transform (t : Tree )(implicit ctx : Context ) = super .transform(t) match {
195
+ case t @ Apply (fun, args) =>
196
+ val newArgs = (args zip fun.tpe.firstParamTypes).map{case (t, tpe) => t.ensureConforms(tpe)}
197
+ if (sameTypes(args, newArgs)) {
198
+ t
199
+ } else tpd.Apply (fun, newArgs)
200
+ case t : ValDef =>
201
+ cpy.ValDef (t)(rhs = t.rhs.ensureConforms(t.tpe.widen))
202
+ case t : DefDef =>
203
+ cpy.DefDef (t)(rhs = t.rhs.ensureConforms(t.tpe.finalResultType))
204
+ case t => t
205
+ }
206
+ }.transform(tree.rhs)
192
207
}})
193
208
}
194
209
} else Nil
Original file line number Diff line number Diff line change 1
- sealed abstract class Foo [@ specialized + A ] {
1
+ trait Foo [@ specialized + A ] {
2
+ // all those examples trigger bugs due to https://github.com/lampepfl/dotty/issues/592
2
3
def bop [@ specialized B >: A ]: Foo [B ] = new Bar [B ](this )
4
+ def gwa [@ specialized B >: A ]: Foo [B ] = this
5
+ def gwd [@ specialized B >: A ]: Foo [B ] = {
6
+ val d : Foo [B ] = this
7
+ d
8
+ }
3
9
// def bip[@specialized C >: A, @specialized D >: A]: Foo[D] = new Cho[D, C](new Bar[C](this))
4
10
}
5
11
6
12
case class Bar [@ specialized a](tl : Foo [a]) extends Foo [a]
7
13
8
- // case class Cho[@specialized c, @specialized d](tl: Bar[d]) extends Foo[c]
14
+ // case class Cho[@specialized c, @specialized d](tl: Bar[d]) extends Foo[c]
You can’t perform that action at this time.
0 commit comments