File tree 2 files changed +6
-2
lines changed
compiler/src/dotty/tools/dotc
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]
329
329
def isFunctionWithUnknownParamType (tree : Tree ): Boolean =
330
330
functionWithUnknownParamType(tree).isDefined
331
331
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
+
332
337
/** Is `tree` an context function or closure, possibly nested in a block? */
333
338
def isContextualClosure (tree : Tree )(using Context ): Boolean = unsplice(tree) match {
334
339
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
3831
3831
&& ! isSelfOrSuperConstrCall(tree)
3832
3832
then tree match
3833
3833
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) =>
3836
3835
// It's a synthesized lambda, for instance via an eta expansion: report a hard error
3837
3836
// There are two tests for synthetic lambdas which both have to be true.
3838
3837
// 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