From f981f3298f635ba1cdac7cffa0702b47e6285133 Mon Sep 17 00:00:00 2001 From: Kacper Korban Date: Mon, 5 Sep 2022 00:35:37 +0200 Subject: [PATCH 1/2] Only look for synthetic applies under TypeApply with inferred arguments fixes lampepfl#15969 --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 +- tests/pos/i15969.scala | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i15969.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 628dcc5a9d92..06a81a8a7bf9 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -105,7 +105,7 @@ object Typer { */ private[typer] def isSyntheticApply(tree: tpd.Tree): Boolean = tree match { case tree: tpd.Select => tree.hasAttachment(InsertedApply) - case TypeApply(fn, _) => isSyntheticApply(fn) + case TypeApply(fn, targs) if targs.forall(_.isInstanceOf[tpd.InferredTypeTree]) => isSyntheticApply(fn) case _ => false } diff --git a/tests/pos/i15969.scala b/tests/pos/i15969.scala new file mode 100644 index 000000000000..827f3ae1f233 --- /dev/null +++ b/tests/pos/i15969.scala @@ -0,0 +1,7 @@ +object Obj { + def apply[L]: Unit = ??? + + extension (make: Unit) def apply(value: Int): String = ??? + + def test: String = Obj[Int](1) +} From fc65e2d55b896bfc841a6d0eae0850d48660d317 Mon Sep 17 00:00:00 2001 From: Kacper Korban <39772805+KacperFKorban@users.noreply.github.com> Date: Mon, 5 Sep 2022 11:25:42 +0200 Subject: [PATCH 2/2] Combine conditions for TypeApply in isSyntheticApply Co-authored-by: odersky --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 06a81a8a7bf9..b05ba9d1ca43 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -105,7 +105,7 @@ object Typer { */ private[typer] def isSyntheticApply(tree: tpd.Tree): Boolean = tree match { case tree: tpd.Select => tree.hasAttachment(InsertedApply) - case TypeApply(fn, targs) if targs.forall(_.isInstanceOf[tpd.InferredTypeTree]) => isSyntheticApply(fn) + case TypeApply(fn, targs) => isSyntheticApply(fn) && targs.forall(_.isInstanceOf[tpd.InferredTypeTree]) case _ => false }