@@ -1379,21 +1379,19 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
13791379 }
13801380
13811381 /** Try to typecheck any arguments in `pt` that are function values missing a
1382- * parameter type. The expected type for these arguments is the lub of the
1383- * corresponding formal parameter types of all alternatives. Type variables
1384- * in formal parameter types are replaced by wildcards. The result of the
1385- * typecheck is stored in `pt`, to be retrieved when its `typedArgs` are selected.
1382+ * parameter type. If the formal parameter types corresponding to a closure argument
1383+ * all agree on their argument types, typecheck the argument with an expected
1384+ * function or partial function type that contains these argument types,
1385+ * The result of the typecheck is stored in `pt`, to be retrieved when its `typedArgs` are selected.
13861386 * The benefit of doing this is to allow idioms like this:
13871387 *
13881388 * def map(f: Char => Char): String = ???
13891389 * def map[U](f: Char => U): Seq[U] = ???
13901390 * map(x => x.toUpper)
13911391 *
13921392 * Without `pretypeArgs` we'd get a "missing parameter type" error for `x`.
1393- * With `pretypeArgs`, we use the union of the two formal parameter types
1394- * `Char => Char` and `Char => ?` as the expected type of the closure `x => x.toUpper`.
1395- * That union is `Char => Char`, so we have an expected parameter type `Char`
1396- * for `x`, and the code typechecks.
1393+ * With `pretypeArgs`, we use the `Char => ?` as the expected type of the
1394+ * closure `x => x.toUpper`, which makes the code typecheck.
13971395 */
13981396 private def pretypeArgs (alts : List [TermRef ], pt : FunProto )(implicit ctx : Context ): Unit = {
13991397 def recur (altFormals : List [List [Type ]], args : List [untpd.Tree ]): Unit = args match {
0 commit comments