File tree 2 files changed +30
-8
lines changed
compiler/src/dotty/tools/dotc/typer 2 files changed +30
-8
lines changed Original file line number Diff line number Diff line change @@ -462,20 +462,26 @@ object Implicits:
462
462
val ctx1 = ctx.fresh.setExploreTyperState()
463
463
ctx1.typerState.constraint = constraint
464
464
inContext(ctx1) {
465
- val map = new TypeMap {
466
- def apply (t : Type ): Type = t match {
465
+ val map = new TypeMap :
466
+ def apply (t : Type ): Type = t match
467
467
case t : TypeParamRef =>
468
- constraint.entry(t) match {
469
- case NoType => t
470
- case bounds : TypeBounds => TypeComparer .fullBounds(t)
468
+ constraint.entry(t) match
469
+ case NoType | _ : TypeBounds => t
471
470
case t1 => t1
472
- }
473
471
case t : TypeVar =>
474
472
t.instanceOpt.orElse(apply(t.origin))
475
473
case _ =>
476
474
mapOver(t)
477
- }
478
- }
475
+
476
+ override def mapArgs (args : List [Type ], tparams : List [ParamInfo ]) =
477
+ args.mapConserve {
478
+ case t : TypeParamRef =>
479
+ constraint.entry(t) match
480
+ case bounds : TypeBounds => TypeComparer .fullBounds(t)
481
+ case _ => this (t)
482
+ case t => this (t)
483
+ }
484
+ end map
479
485
map(tp)
480
486
}
481
487
Original file line number Diff line number Diff line change
1
+ sealed trait Xa [T ]
2
+ sealed trait Mu [T ] extends Xa [T ]
3
+ object Xa {
4
+ // bad
5
+ implicit def convertMu [X [x] <: Xa [x], A , B ](implicit t : X [A ] with Xa [A ]): X [B ] = t.asInstanceOf [X [B ]]
6
+ // good
7
+ // implicit def convertMu[X[x] <: Xa[x], A, B](implicit t: X[A] with Mu[A]): X[B] = t.asInstanceOf[X[B]]
8
+ }
9
+ object Mu {
10
+ implicit def mu : Mu [Int ] = new Mu [Int ] {}
11
+ }
12
+
13
+ object App extends App {
14
+ def constrain (a : Mu [Long ]): Unit = println(a)
15
+ constrain(Xa .convertMu) // error
16
+ }
You can’t perform that action at this time.
0 commit comments