diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 8ead9b64f9a7..26c2faff0a72 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -118,7 +118,7 @@ object Typer { * apply of a function class? */ private[typer] def isSyntheticApply(tree: tpd.Tree): Boolean = tree match { - case tree: tpd.Select => tree.hasAttachment(InsertedApply) + case _: (tpd.Select | tpd.Apply) => tree.hasAttachment(InsertedApply) case TypeApply(fn, targs) => isSyntheticApply(fn) && targs.forall(_.isInstanceOf[tpd.InferredTypeTree]) case _ => false } diff --git a/tests/neg/24782.check b/tests/neg/24782.check new file mode 100644 index 000000000000..5c6e55f5599d --- /dev/null +++ b/tests/neg/24782.check @@ -0,0 +1,6 @@ +-- [E050] Type Error: tests/neg/24782.scala:4:28 ----------------------------------------------------------------------- +4 | def f(using pure: Pure) = S(s => pure(s)) // error (but no compiler crash / stack overflow) + | ^ + | expression does not take more parameters + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg/24782.scala b/tests/neg/24782.scala new file mode 100644 index 000000000000..28f2df112f7b --- /dev/null +++ b/tests/neg/24782.scala @@ -0,0 +1,5 @@ +object S { + trait F[A] + type Pure = [a] => a => F[a] + def f(using pure: Pure) = S(s => pure(s)) // error (but no compiler crash / stack overflow) +} diff --git a/tests/pos/i14907.scala b/tests/pos/i14907.scala index 4a60362d0f73..ae19e5231a66 100644 --- a/tests/pos/i14907.scala +++ b/tests/pos/i14907.scala @@ -5,7 +5,7 @@ object Module { case 1 => Any *: Fill[0] } extension[N <: Int] (f: Fun[N]) - def apply: Fill[N] => Any = ??? + def apply(): Fill[N] => Any = ??? - Fun[1]()(???) + Fun[1]()()(???) }