Skip to content

Commit 48f7ed6

Browse files
committed
Use substApprox for F-bounds instantiation
Use substApprox for F-bounds instantiation if there are wildcards. This is the simplest checking algorithm I could find that is not obviously wrong and that accepts i6146.scala. I can't prove it's correct, though.
1 parent 01dbaeb commit 48f7ed6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,12 @@ object Checking {
7575
}.getOrElse(TypeTree(tparam.paramRef))
7676
val orderedArgs = if (hasNamedArg(args)) tparams.map(argNamed) else args
7777
val bounds = tparams.map(_.paramInfoAsSeenFrom(tree.tpe).bounds)
78-
def instantiate(bound: Type, args: List[Type]) =
79-
HKTypeLambda.fromParams(tparams, bound).appliedTo(args)
78+
def instantiate(bound: Type, args: List[Type]) = tparams match {
79+
case (_: Symbol) :: _ if args.exists(_.isInstanceOf[TypeBounds]) =>
80+
bound.substApprox(tparams.asInstanceOf[List[Symbol]], args)
81+
case _ =>
82+
HKTypeLambda.fromParams(tparams, bound).appliedTo(args)
83+
}
8084
if (boundsCheck) checkBounds(orderedArgs, bounds, instantiate)
8185

8286
def checkWildcardApply(tp: Type): Unit = tp match {

0 commit comments

Comments
 (0)