File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -329,6 +329,11 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped]
329329 def isFunctionWithUnknownParamType (tree : Tree ): Boolean =
330330 functionWithUnknownParamType(tree).isDefined
331331
332+ def isFunction (tree : Tree ): Boolean = tree match
333+ case Function (_, _) | Match (EmptyTree , _) => true
334+ case Block (Nil , expr) => isFunction(expr)
335+ case _ => false
336+
332337 /** Is `tree` an context function or closure, possibly nested in a block? */
333338 def isContextualClosure (tree : Tree )(using Context ): Boolean = unsplice(tree) match {
334339 case tree : FunctionWithMods => tree.mods.is(Given )
Original file line number Diff line number Diff line change @@ -3831,8 +3831,7 @@ class Typer extends Namer
38313831 && ! isSelfOrSuperConstrCall(tree)
38323832 then tree match
38333833 case closureDef(meth)
3834- if meth.span == meth.rhs.span.toSynthetic
3835- && ! original.isInstanceOf [untpd.Function ] =>
3834+ if meth.span == meth.rhs.span.toSynthetic && ! untpd.isFunction(original) =>
38363835 // It's a synthesized lambda, for instance via an eta expansion: report a hard error
38373836 // There are two tests for synthetic lambdas which both have to be true.
38383837 // The first test compares spans of closure definition with the closure's right hand
You can’t perform that action at this time.
0 commit comments