Skip to content

Commit 98fc019

Browse files
authored
Merge pull request #9122 from dotty-staging/fix-#8925
fix #8925: check for NamedArg when inserting implicit arguments
2 parents 8d5c465 + e9d7789 commit 98fc019

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3058,6 +3058,8 @@ class Typer extends Namer
30583058
else tree match {
30593059
case tree: Block =>
30603060
readaptSimplified(tpd.Block(tree.stats, tpd.Apply(tree.expr, args)))
3061+
case tree: NamedArg =>
3062+
readaptSimplified(tpd.NamedArg(tree.name, tpd.Apply(tree.arg, args)))
30613063
case _ =>
30623064
readaptSimplified(tpd.Apply(tree, args))
30633065
}

tests/neg/i8925.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
trait Parent {
2+
type Child
3+
}
4+
5+
object Demo {
6+
def params(arr: Int): Int = ???
7+
8+
def parametersOf[Parent, T]()(using m: String): Int = 0
9+
10+
def combineInternal(using p: Parent): Int = {
11+
//this implicit needs to be available
12+
implicit val s: String = ""
13+
14+
//parameter needs to be named
15+
params(arr = parametersOf[Parent, p.Child]) // error: method parametersOf must be called with () argument
16+
}
17+
}

tests/pos/i8925.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
trait Parent {
2+
type Child
3+
}
4+
5+
object Demo {
6+
def params(arr: Int): Int = ???
7+
8+
def parametersOf[Parent, T]()(using m: String): Int = 0
9+
10+
def combineInternal(using p: Parent): Int = {
11+
//this implicit needs to be available
12+
implicit val s: String = ""
13+
14+
//parameter needs to be named
15+
params(arr = parametersOf[Parent, p.Child]())
16+
}
17+
}

0 commit comments

Comments
 (0)