diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 71a8872343b4..bb7ca762d9f2 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -103,6 +103,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 _ => false } diff --git a/tests/neg/i15567.scala b/tests/neg/i15567.scala new file mode 100644 index 000000000000..35f8db5ef9d2 --- /dev/null +++ b/tests/neg/i15567.scala @@ -0,0 +1,9 @@ +object Test: + object Foo { def apply[A]: Foo.type = this } + Foo() // error + + case class Bar() { def apply[A]: Bar = this } + Bar()() // error + + case class Qux() { def apply[F[_]]: Qux = this } + Qux()() // error