diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index d0a8733d05f7..0bbe5ee7c7ac 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1611,6 +1611,8 @@ object desugar { def makePolyFunction(targs: List[Tree], body: Tree): Tree = body match { case Parens(body1) => makePolyFunction(targs, body1) + case Block(Nil, body1) => + makePolyFunction(targs, body1) case Function(vargs, res) => assert(targs.nonEmpty) // TODO: Figure out if we need a `PolyFunctionWithMods` instead. diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index eac39ca72120..c8ad2d706945 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1312,6 +1312,7 @@ object Parsers { private def isFunction(tree: Tree): Boolean = tree match { case Parens(tree1) => isFunction(tree1) + case Block(Nil, tree1) => isFunction(tree1) case _: Function => true case _ => false } diff --git a/tests/run/polymorphic-functions.scala b/tests/run/polymorphic-functions.scala index e723fa34cf79..d059484d60cd 100644 --- a/tests/run/polymorphic-functions.scala +++ b/tests/run/polymorphic-functions.scala @@ -95,4 +95,6 @@ object Test extends App { // Parens handling val tt1: [T] => (T => T) = [T] => (x: T) => x val tt2: [T] => T => T = [T] => ((x: T) => x) + val tt3: [T] => T => T = [T] => { (x: T) => x } + val tt4: [T] => T => T = [T] => (x: T) => { x } }