@@ -832,7 +832,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
832832 case funRef : TermRef =>
833833 val app =
834834 if (proto.allArgTypesAreCurrent())
835- new ApplyToTyped (tree, fun1, funRef, proto.typedArgs , pt)
835+ new ApplyToTyped (tree, fun1, funRef, proto.unforcedTypedArgs , pt)
836836 else
837837 new ApplyToUntyped (tree, fun1, funRef, proto, pt)(argCtx(tree))
838838 convertNewGenericArray(app.result)
@@ -857,7 +857,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
857857 }
858858
859859 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)
861861 case TryDynamicCallType => typedDynamicApply(tree, pt)
862862 case _ =>
863863 if (originalProto.isDropped) fun1
@@ -1604,7 +1604,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
16041604 if (isDetermined(alts2)) alts2
16051605 else {
16061606 pretypeArgs(alts2, pt)
1607- narrowByTrees(alts2, pt.typedArgs , resultType)
1607+ narrowByTrees(alts2, pt.unforcedTypedArgs , resultType)
16081608 }
16091609 }
16101610
@@ -1665,7 +1665,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
16651665 else pt match {
16661666 case pt @ FunProto (_, resType : FunProto ) =>
16671667 // try to narrow further with snd argument list
1668- val advanced = advanceCandidates(pt.typedArgs .tpes)
1668+ val advanced = advanceCandidates(pt.unforcedTypedArgs .tpes)
16691669 resolveOverloaded(advanced.map(_._1), resType, Nil ) // resolve with candidates where first params are stripped
16701670 .map(advanced.toMap) // map surviving result(s) back to original candidates
16711671 case _ =>
@@ -1697,40 +1697,38 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
16971697 private def pretypeArgs (alts : List [TermRef ], pt : FunProto )(implicit ctx : Context ): Unit = {
16981698 def recur (altFormals : List [List [Type ]], args : List [untpd.Tree ]): Unit = args match {
16991699 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 ))
17131730 }
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 =>
17341732 }
17351733 recur(altFormals.map(_.tail), args1)
17361734 case _ =>
0 commit comments