File tree Expand file tree Collapse file tree 5 files changed +26
-14
lines changed
src/dotty/tools/dotc/typer Expand file tree Collapse file tree 5 files changed +26
-14
lines changed Original file line number Diff line number Diff line change @@ -1227,8 +1227,11 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
12271227 case mtpe : MethodType =>
12281228 val pos = paramIndex(param.name)
12291229 if pos < mtpe.paramInfos.length then
1230- val ptype = mtpe.paramInfos(pos)
1231- if ptype.isRepeatedParam then NoType else ptype
1230+ mtpe.paramInfos(pos)
1231+ // This works only if vararg annotations match up.
1232+ // See neg/i14367.scala for an example where the inferred type is mispredicted.
1233+ // Nevertheless, the alternative would be to give up completely, so this is
1234+ // defensible.
12321235 else NoType
12331236 case _ => NoType
12341237 if target.exists then formal <:< target
@@ -1317,10 +1320,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
13171320 */
13181321 var fnBody = tree.body
13191322
1320- def refersTo (arg : untpd.Tree , param : untpd.ValDef ): Boolean = arg match {
1323+ def refersTo (arg : untpd.Tree , param : untpd.ValDef ): Boolean = arg match
13211324 case Ident (name) => name == param.name
1325+ case Typed (arg1, _) if untpd.isWildcardStarArg(arg) => refersTo(arg1, param)
13221326 case _ => false
1323- }
13241327
13251328 /** If parameter `param` appears exactly once as an argument in `args`,
13261329 * the singleton list consisting of its position in `args`, otherwise `Nil`.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ -- [E007] Type Mismatch Error: tests/neg/i14367.scala:2:16 -------------------------------------------------------------
2+ 2 |val h2 = i => p(i) // error: Found (i : Seq[Int]), Required: Int
3+ | ^
4+ | Found: (i : Seq[Int])
5+ | Required: Int
6+
7+ longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change 1+ def p (i : Int * ) = i.sum
2+ val h2 = i => p(i) // error: Found (i : Seq[Int]), Required: Int
3+ // It would be more logical to fail with a "missing parameter type", however.
4+
5+
Original file line number Diff line number Diff line change 1+ def m (i : Int * ) = i.sum
2+ val f1 = m
3+ val f2 = i => m(i* )
4+
5+ def n (i : Seq [Int ]) = i.sum
6+ val g1 = n
7+ val g2 = i => n(i)
You can’t perform that action at this time.
0 commit comments