File tree 1 file changed +16
-1
lines changed
compiler/src/dotty/tools/dotc/cc 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -606,8 +606,23 @@ class CheckCaptures extends Recheck, SymTransformer:
606
606
// rechecking the body.
607
607
openClosures = (mdef.symbol, pt) :: openClosures
608
608
try
609
+ def isEtaExpansion (mdef : DefDef ): Boolean = mdef.paramss match
610
+ case (param :: _) :: _ if param.asInstanceOf [Tree ].span.isZeroExtent =>
611
+ mdef.rhs match
612
+ case _ : Apply => true
613
+ case closureDef(mdef1) => isEtaExpansion(mdef1)
614
+ case _ => false
615
+ case _ => false
609
616
val res = recheckClosure(expr, pt, forceDependent = true )
610
- checkConformsExpr(res, pt, expr)
617
+ if ! isEtaExpansion(mdef) then
618
+ // If closure is an eta expanded method reference it's better to not constrain
619
+ // its internals early since that would give error messages in generated code
620
+ // which are less intelligible.
621
+ // Example is the line `a = x` in neg-custom-args/captures/vars.scala.
622
+ // For all other closures, early constraints are preferred since they
623
+ // give more localized error messages.
624
+ checkConformsExpr(res, pt, expr)
625
+ // else report.warning(i"skip test $mdef", mdef.srcPos)
611
626
recheckDef(mdef, mdef.symbol)
612
627
// println(i"RECHECK CLOSURE ${mdef.symbol.info}")
613
628
res
You can’t perform that action at this time.
0 commit comments