Skip to content

Fix #6858: Wrap array when passed to inlined varargs #6859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,13 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
* @param arg the argument corresponding to the parameter
* @param bindingsBuf the buffer to which the definition should be appended
*/
private def paramBindingDef(name: Name, paramtp: Type, arg: Tree,
private def paramBindingDef(name: Name, paramtp: Type, arg0: Tree,
bindingsBuf: mutable.ListBuffer[ValOrDefDef])(implicit ctx: Context): ValOrDefDef = {
val arg = arg0 match {
case Typed(arg1, tpt) if tpt.tpe.isRepeatedParam && arg1.tpe.derivesFrom(defn.ArrayClass) =>
wrapArray(arg1, arg0.tpe.elemType)
case _ => arg0
}
val argtpe = arg.tpe.dealiasKeepAnnots
val isByName = paramtp.dealias.isInstanceOf[ExprType]
var inlineFlags: FlagSet = InlineProxy
Expand Down
10 changes: 10 additions & 0 deletions tests/run/i6858.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
object Test extends App {
inline def foo(ys: Int*): Unit = bar(ys: _*)
def bar(ys: Int*) = ()

val xs: Array[Int] = new Array[Int](3)
foo(xs: _*)

val ys: Seq[Int] = new Array[Int](3)
foo(ys: _*)
}