File tree Expand file tree Collapse file tree 2 files changed +30
-8
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +30
-8
lines changed Original file line number Diff line number Diff line change @@ -470,20 +470,26 @@ object Implicits:
470470 val ctx1 = ctx.fresh.setExploreTyperState()
471471 ctx1.typerState.constraint = constraint
472472 inContext(ctx1) {
473- val map = new TypeMap {
474- def apply (t : Type ): Type = t match {
473+ val map = new TypeMap :
474+ def apply (t : Type ): Type = t match
475475 case t : TypeParamRef =>
476- constraint.entry(t) match {
477- case NoType => t
478- case bounds : TypeBounds => TypeComparer .fullBounds(t)
476+ constraint.entry(t) match
477+ case NoType | _ : TypeBounds => t
479478 case t1 => t1
480- }
481479 case t : TypeVar =>
482480 t.instanceOpt.orElse(apply(t.origin))
483481 case _ =>
484482 mapOver(t)
485- }
486- }
483+
484+ override def mapArgs (args : List [Type ], tparams : List [ParamInfo ]) =
485+ args.mapConserve {
486+ case t : TypeParamRef =>
487+ constraint.entry(t) match
488+ case bounds : TypeBounds => TypeComparer .fullBounds(t)
489+ case _ => this (t)
490+ case t => this (t)
491+ }
492+ end map
487493 map(tp)
488494 }
489495
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