From 03df624aefcd295a563938e61733540921cc18cd 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 d802ef0df973..4c6875ddace3 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 6a7a9fa0f0f6ce43f3c0fde10b144fdc7f941f0f 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 4c6875ddace3..dd3e6f2ee8ca 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 }