@@ -832,7 +832,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
832
832
case funRef : TermRef =>
833
833
val app =
834
834
if (proto.allArgTypesAreCurrent())
835
- new ApplyToTyped (tree, fun1, funRef, proto.typedArgs , pt)
835
+ new ApplyToTyped (tree, fun1, funRef, proto.unforcedTypedArgs , pt)
836
836
else
837
837
new ApplyToUntyped (tree, fun1, funRef, proto, pt)(argCtx(tree))
838
838
convertNewGenericArray(app.result)
@@ -857,7 +857,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
857
857
}
858
858
859
859
fun1.tpe match {
860
- case err : ErrorType => cpy.Apply (tree)(fun1, proto.typedArgs ).withType(err)
860
+ case err : ErrorType => cpy.Apply (tree)(fun1, proto.unforcedTypedArgs ).withType(err)
861
861
case TryDynamicCallType => typedDynamicApply(tree, pt)
862
862
case _ =>
863
863
if (originalProto.isDropped) fun1
@@ -1604,7 +1604,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1604
1604
if (isDetermined(alts2)) alts2
1605
1605
else {
1606
1606
pretypeArgs(alts2, pt)
1607
- narrowByTrees(alts2, pt.typedArgs , resultType)
1607
+ narrowByTrees(alts2, pt.unforcedTypedArgs , resultType)
1608
1608
}
1609
1609
}
1610
1610
@@ -1665,7 +1665,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1665
1665
else pt match {
1666
1666
case pt @ FunProto (_, resType : FunProto ) =>
1667
1667
// try to narrow further with snd argument list
1668
- val advanced = advanceCandidates(pt.typedArgs .tpes)
1668
+ val advanced = advanceCandidates(pt.unforcedTypedArgs .tpes)
1669
1669
resolveOverloaded(advanced.map(_._1), resType, Nil ) // resolve with candidates where first params are stripped
1670
1670
.map(advanced.toMap) // map surviving result(s) back to original candidates
1671
1671
case _ =>
@@ -1697,40 +1697,38 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1697
1697
private def pretypeArgs (alts : List [TermRef ], pt : FunProto )(implicit ctx : Context ): Unit = {
1698
1698
def recur (altFormals : List [List [Type ]], args : List [untpd.Tree ]): Unit = args match {
1699
1699
case arg :: args1 if ! altFormals.exists(_.isEmpty) =>
1700
- def isUnknownParamType (t : untpd.Tree ) = t match {
1701
- case ValDef (_, tpt, _) => tpt.isEmpty
1702
- case _ => false
1703
- }
1704
- val fn = untpd.functionWithUnknownParamType(arg)
1705
- if (fn.isDefined) {
1706
- def isUniform [T ](xs : List [T ])(p : (T , T ) => Boolean ) = xs.forall(p(_, xs.head))
1707
- val formalsForArg : List [Type ] = altFormals.map(_.head)
1708
- def argTypesOfFormal (formal : Type ): List [Type ] =
1709
- formal match {
1710
- case defn.FunctionOf (args, result, isImplicit, isErased) => args
1711
- case defn.PartialFunctionOf (arg, result) => arg :: Nil
1712
- case _ => Nil
1700
+ untpd.functionWithUnknownParamType(arg) match {
1701
+ case Some (fn) =>
1702
+ def isUniform [T ](xs : List [T ])(p : (T , T ) => Boolean ) = xs.forall(p(_, xs.head))
1703
+ val formalsForArg : List [Type ] = altFormals.map(_.head)
1704
+ def argTypesOfFormal (formal : Type ): List [Type ] =
1705
+ formal match {
1706
+ case defn.FunctionOf (args, result, isImplicit, isErased) => args
1707
+ case defn.PartialFunctionOf (arg, result) => arg :: Nil
1708
+ case _ => Nil
1709
+ }
1710
+ val formalParamTypessForArg : List [List [Type ]] =
1711
+ formalsForArg.map(argTypesOfFormal)
1712
+ if (formalParamTypessForArg.forall(_.nonEmpty) &&
1713
+ isUniform(formalParamTypessForArg)((x, y) => x.length == y.length)) {
1714
+ val commonParamTypes = formalParamTypessForArg.transpose.map(ps =>
1715
+ // Given definitions above, for i = 1,...,m,
1716
+ // ps(i) = List(p_i_1, ..., p_i_n) -- i.e. a column
1717
+ // If all p_i_k's are the same, assume the type as formal parameter
1718
+ // type of the i'th parameter of the closure.
1719
+ if (isUniform(ps)(_ frozen_=:= _)) ps.head
1720
+ else WildcardType )
1721
+ def isPartial = // we should generate a partial function for the arg
1722
+ fn.isInstanceOf [untpd.Match ] &&
1723
+ formalsForArg.exists(_.isRef(defn.PartialFunctionClass ))
1724
+ val commonFormal =
1725
+ if (isPartial) defn.PartialFunctionOf (commonParamTypes.head, WildcardType )
1726
+ else defn.FunctionOf (commonParamTypes, WildcardType )
1727
+ overload.println(i " pretype arg $arg with expected type $commonFormal" )
1728
+ if (commonParamTypes.forall(isFullyDefined(_, ForceDegree .noBottom)))
1729
+ pt.typedArg(arg, commonFormal)(ctx.addMode(Mode .ImplicitsEnabled ))
1713
1730
}
1714
- val formalParamTypessForArg : List [List [Type ]] =
1715
- formalsForArg.map(argTypesOfFormal)
1716
- if (formalParamTypessForArg.forall(_.nonEmpty) &&
1717
- isUniform(formalParamTypessForArg)((x, y) => x.length == y.length)) {
1718
- val commonParamTypes = formalParamTypessForArg.transpose.map(ps =>
1719
- // Given definitions above, for i = 1,...,m,
1720
- // ps(i) = List(p_i_1, ..., p_i_n) -- i.e. a column
1721
- // If all p_i_k's are the same, assume the type as formal parameter
1722
- // type of the i'th parameter of the closure.
1723
- if (isUniform(ps)(_ frozen_=:= _)) ps.head
1724
- else WildcardType )
1725
- def isPartial = // we should generate a partial function for the arg
1726
- fn.get.isInstanceOf [untpd.Match ] &&
1727
- formalsForArg.exists(_.isRef(defn.PartialFunctionClass ))
1728
- val commonFormal =
1729
- if (isPartial) defn.PartialFunctionOf (commonParamTypes.head, WildcardType )
1730
- else defn.FunctionOf (commonParamTypes, WildcardType )
1731
- overload.println(i " pretype arg $arg with expected type $commonFormal" )
1732
- pt.typedArg(arg, commonFormal)(ctx.addMode(Mode .ImplicitsEnabled ))
1733
- }
1731
+ case None =>
1734
1732
}
1735
1733
recur(altFormals.map(_.tail), args1)
1736
1734
case _ =>
0 commit comments