@@ -285,6 +285,12 @@ object ProtoTypes {
285285 state.typedArg.size == args.length
286286 }
287287
288+ private def isUndefined (tp : Type ): Boolean = tp match {
289+ case _ : WildcardType => true
290+ case defn.FunctionOf (args, result, _, _) => args.exists(isUndefined) || isUndefined(result)
291+ case _ => false
292+ }
293+
288294 private def cacheTypedArg (arg : untpd.Tree , typerFn : untpd.Tree => Tree , force : Boolean )(implicit ctx : Context ): Tree = {
289295 var targ = state.typedArg(arg)
290296 if (targ == null ) {
@@ -317,21 +323,15 @@ object ProtoTypes {
317323
318324 /** The typed arguments. This takes any arguments already typed using
319325 * `typedArg` into account.
320- * @param force if true try to typecheck arguments even if they are functions
321- * with unknown parameter types - this will then cause a
322- * "missing parameter type" error
323326 */
324- protected [ this ] def typedArgs ( force : Boolean ) : List [Tree ] =
327+ def unforcedTypedArgs : List [Tree ] =
325328 if (state.typedArgs.size == args.length) state.typedArgs
326329 else {
327- val args1 = args.mapconserve(cacheTypedArg(_, typer.typed(_), force))
328- if (force || ! args1.contains( WildcardType )) state.typedArgs = args1
330+ val args1 = args.mapconserve(cacheTypedArg(_, typer.typed(_), force = false ))
331+ if (! args1.exists(arg => isUndefined(arg.tpe) )) state.typedArgs = args1
329332 args1
330333 }
331334
332- def typedArgs : List [Tree ] = typedArgs(force = true )
333- def unforcedTypedArgs : List [Tree ] = typedArgs(force = false )
334-
335335 /** Type single argument and remember the unadapted result in `myTypedArg`.
336336 * used to avoid repeated typings of trees when backtracking.
337337 */
@@ -397,7 +397,7 @@ object ProtoTypes {
397397 * [](args): resultType, where args are known to be typed
398398 */
399399 class FunProtoTyped (args : List [tpd.Tree ], resultType : Type )(typer : Typer , isContextual : Boolean )(implicit ctx : Context ) extends FunProto (args, resultType)(typer, isContextual)(ctx) {
400- override def typedArgs ( force : Boolean ) : List [tpd.Tree ] = args
400+ override def unforcedTypedArgs : List [tpd.Tree ] = args
401401 override def withContext (ctx : Context ): FunProtoTyped = this
402402 }
403403
0 commit comments