@@ -712,6 +712,17 @@ trait Infer extends Checkable {
712
712
argtpes
713
713
}
714
714
715
+ // This is primarily a duplicte of enhanceBounds in typedAppliedTypeTree
716
+ // modified to use updateInfo rather than setInfo to avoid wiping out
717
+ // type history.
718
+ def enhanceBounds (okparams : List [Symbol ], okargs : List [Type ], undets : List [Symbol ]): Unit =
719
+ undets.foreach { undet =>
720
+ val bounds = undet.info.bounds
721
+ val substBounds = bounds.subst(okparams, okargs)
722
+ if (bounds ne substBounds)
723
+ undet.updateInfo(substBounds)
724
+ }
725
+
715
726
private def isApplicableToMethod (undetparams : List [Symbol ], mt : MethodType , argtpes0 : List [Type ], pt : Type ): Boolean = {
716
727
val formals = formalTypes(mt.paramTypes, argtpes0.length, removeByName = false )
717
728
def missingArgs = missingParams[Type ](argtpes0, mt.params, x => Some (x) collect { case NamedType (n, _) => n })
@@ -728,6 +739,7 @@ trait Infer extends Checkable {
728
739
def tryInstantiating (args : List [Type ]) = falseIfNoInstance {
729
740
val restpe = mt resultType args
730
741
val AdjustedTypeArgs .Undets (okparams, okargs, leftUndet) = methTypeArgs(EmptyTree , undetparams, formals, restpe, args, pt)
742
+ enhanceBounds(okparams, okargs, leftUndet)
731
743
val restpeInst = restpe.instantiateTypeParams(okparams, okargs)
732
744
// #2665: must use weak conformance, not regular one (follow the monomorphic case above)
733
745
exprTypeArgs(leftUndet, restpeInst, pt, useWeaklyCompatible = true ) match {
@@ -936,11 +948,14 @@ trait Infer extends Checkable {
936
948
List ()
937
949
} else {
938
950
val AdjustedTypeArgs .Undets (okParams, okArgs, leftUndet) = adjustTypeArgs(tparams, tvars, targsStrict)
951
+ enhanceBounds(okParams, okArgs, leftUndet)
952
+
939
953
def solved_s = map2(okParams, okArgs)((p, a) => s " $p= $a" ) mkString " ,"
940
954
def undet_s = leftUndet match {
941
955
case Nil => " "
942
956
case ps => ps.mkString(" , undet=" , " ," , " " )
943
957
}
958
+
944
959
printTyping(tree, s " infer solved $solved_s$undet_s" )
945
960
substExpr(tree, okParams, okArgs, pt)
946
961
leftUndet
@@ -982,6 +997,7 @@ trait Infer extends Checkable {
982
997
983
998
val AdjustedTypeArgs .AllArgsAndUndets (okparams, okargs, allargs, leftUndet) =
984
999
methTypeArgs(fn, undetparams, formals, restpe, argtpes, pt)
1000
+ enhanceBounds(okparams, okargs, leftUndet)
985
1001
986
1002
if (checkBounds(fn, NoPrefix , NoSymbol , undetparams, allargs, " inferred " )) {
987
1003
val treeSubst = new TreeTypeSubstituter (okparams, okargs)
0 commit comments