@@ -285,6 +285,12 @@ object ProtoTypes {
285
285
state.typedArg.size == args.length
286
286
}
287
287
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
+
288
294
private def cacheTypedArg (arg : untpd.Tree , typerFn : untpd.Tree => Tree , force : Boolean )(implicit ctx : Context ): Tree = {
289
295
var targ = state.typedArg(arg)
290
296
if (targ == null ) {
@@ -317,21 +323,15 @@ object ProtoTypes {
317
323
318
324
/** The typed arguments. This takes any arguments already typed using
319
325
* `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
323
326
*/
324
- protected [ this ] def typedArgs ( force : Boolean ) : List [Tree ] =
327
+ def unforcedTypedArgs : List [Tree ] =
325
328
if (state.typedArgs.size == args.length) state.typedArgs
326
329
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
329
332
args1
330
333
}
331
334
332
- def typedArgs : List [Tree ] = typedArgs(force = true )
333
- def unforcedTypedArgs : List [Tree ] = typedArgs(force = false )
334
-
335
335
/** Type single argument and remember the unadapted result in `myTypedArg`.
336
336
* used to avoid repeated typings of trees when backtracking.
337
337
*/
@@ -397,7 +397,7 @@ object ProtoTypes {
397
397
* [](args): resultType, where args are known to be typed
398
398
*/
399
399
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
401
401
override def withContext (ctx : Context ): FunProtoTyped = this
402
402
}
403
403
0 commit comments