From e9d7789f98afa4d60deaeced1107ee67101e6e73 Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Mon, 8 Jun 2020 10:39:58 +0200 Subject: [PATCH] fix #8925: check for NamedArg when inserting implicit arguments --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 ++ tests/neg/i8925.scala | 17 +++++++++++++++++ tests/pos/i8925.scala | 17 +++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 tests/neg/i8925.scala create mode 100644 tests/pos/i8925.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index b89d878e03c1..d7b0753bf288 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -3058,6 +3058,8 @@ class Typer extends Namer else tree match { case tree: Block => readaptSimplified(tpd.Block(tree.stats, tpd.Apply(tree.expr, args))) + case tree: NamedArg => + readaptSimplified(tpd.NamedArg(tree.name, tpd.Apply(tree.arg, args))) case _ => readaptSimplified(tpd.Apply(tree, args)) } diff --git a/tests/neg/i8925.scala b/tests/neg/i8925.scala new file mode 100644 index 000000000000..3467a0ca3ca8 --- /dev/null +++ b/tests/neg/i8925.scala @@ -0,0 +1,17 @@ +trait Parent { + type Child +} + +object Demo { + def params(arr: Int): Int = ??? + + def parametersOf[Parent, T]()(using m: String): Int = 0 + + def combineInternal(using p: Parent): Int = { + //this implicit needs to be available + implicit val s: String = "" + + //parameter needs to be named + params(arr = parametersOf[Parent, p.Child]) // error: method parametersOf must be called with () argument + } +} diff --git a/tests/pos/i8925.scala b/tests/pos/i8925.scala new file mode 100644 index 000000000000..2a97c88937c1 --- /dev/null +++ b/tests/pos/i8925.scala @@ -0,0 +1,17 @@ +trait Parent { + type Child +} + +object Demo { + def params(arr: Int): Int = ??? + + def parametersOf[Parent, T]()(using m: String): Int = 0 + + def combineInternal(using p: Parent): Int = { + //this implicit needs to be available + implicit val s: String = "" + + //parameter needs to be named + params(arr = parametersOf[Parent, p.Child]()) + } +}