diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index a2547c94029a..def259312f73 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -3902,12 +3902,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer // Reasons NOT to eta expand: // - we reference a constructor - // - we reference a typelevel method // - we are in a pattern // - the current tree is a synthetic apply which is not expandable (eta-expasion would simply undo that) if arity >= 0 && !tree.symbol.isConstructor - && !tree.symbol.isAllOf(InlineMethod) && !ctx.mode.is(Mode.Pattern) && !(isSyntheticApply(tree) && !functionExpected) then diff --git a/tests/neg/i12207.scala b/tests/neg/i12207.scala index 08c1e76f5ecd..8ed8c479d7e6 100644 --- a/tests/neg/i12207.scala +++ b/tests/neg/i12207.scala @@ -5,4 +5,4 @@ extension [T](t: T) inline def pi[P <: Tuple](using P): T = ??? inline def env[P <: Tuple, T](op: P ?=> T): P ?=> T = op @main def Test = - env { pi[String] } // error // error + env { pi[String] } // error diff --git a/tests/neg/i7459.scala b/tests/neg/i7459.scala index b5b20d7bc22a..a17f32b15afa 100644 --- a/tests/neg/i7459.scala +++ b/tests/neg/i7459.scala @@ -2,7 +2,7 @@ object Foo { inline def summon[T](x: T): T = x match { case t: T => t } - println(summon) // error + println(summon) } import scala.deriving.* diff --git a/tests/pos/inline-eta.scala b/tests/pos/inline-eta.scala new file mode 100644 index 000000000000..1fc0246fba11 --- /dev/null +++ b/tests/pos/inline-eta.scala @@ -0,0 +1,9 @@ +class Foo(x: Int) + +object A: + inline def bar(x: Int): Int = x + val g1 = bar + val g2: Int => Int = bar + + def foo(xs: List[Int]) = + xs.map(Foo.apply) // use the `inline def apply` constructor proxy