Skip to content

Commit e1679f9

Browse files
Merge pull request #7461 from dotty-staging/fix-#7438
Fix #7438: Turn failing assertion into error in inliner
2 parents d56060d + 86c2687 commit e1679f9

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

compiler/src/dotty/tools/dotc/typer/Inliner.scala

+11-8
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,18 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
326326
}
327327
computeParamBindings(tp.resultType, Nil, argss)
328328
case tp: MethodType =>
329-
assert(argss.nonEmpty, i"missing bindings: $tp in $call")
330-
tp.paramNames.lazyZip(tp.paramInfos).lazyZip(argss.head).foreach { (name, paramtp, arg) =>
331-
paramSpan(name) = arg.span
332-
paramBinding(name) = arg.tpe.dealias match {
333-
case _: SingletonType if isIdempotentPath(arg) => arg.tpe
334-
case _ => paramBindingDef(name, paramtp, arg, bindingsBuf).symbol.termRef
329+
if argss.isEmpty then
330+
// can happen if arguments have errors, see i7438.scala
331+
ctx.error(i"mising arguments for inline method $inlinedMethod", call.sourcePos)
332+
else
333+
tp.paramNames.lazyZip(tp.paramInfos).lazyZip(argss.head).foreach { (name, paramtp, arg) =>
334+
paramSpan(name) = arg.span
335+
paramBinding(name) = arg.tpe.dealias match {
336+
case _: SingletonType if isIdempotentPath(arg) => arg.tpe
337+
case _ => paramBindingDef(name, paramtp, arg, bindingsBuf).symbol.termRef
338+
}
335339
}
336-
}
337-
computeParamBindings(tp.resultType, targs, argss.tail)
340+
computeParamBindings(tp.resultType, targs, argss.tail)
338341
case _ =>
339342
assert(targs.isEmpty)
340343
assert(argss.isEmpty)

tests/neg/i7438.scala

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
type Tr[+A]
2+
inline def (tr: Tr[A]) map[A, B](f: A => B): Tr[B] = ???
3+
4+
def (d: Double) func: None.type => Some[Double] = ???
5+
6+
def run[A](query: None.type => Some[A]): Some[A] = ???
7+
8+
val noBug = run(3.14 func) map (x => x)
9+
val buggy = run(3.14 func map (x => x)) // error: missing parameter type

0 commit comments

Comments
 (0)