Skip to content

Commit 629006b

Browse files
committed
Remove now-unnecessary avoid when typing closures
This is no longer needed thanks to the improvements to avoidance in this PR.
1 parent ae1b00d commit 629006b

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

compiler/src/dotty/tools/dotc/typer/Namer.scala

+1-16
Original file line numberDiff line numberDiff line change
@@ -1479,22 +1479,7 @@ class Namer { typer: Typer =>
14791479
// This case applies if the closure result type contains uninstantiated
14801480
// type variables. In this case, constrain the closure result from below
14811481
// by the parameter-capture-avoiding type of the body.
1482-
val rhsType = typedAheadExpr(mdef.rhs, tpt.tpe).tpe
1483-
1484-
// The following part is important since otherwise we might instantiate
1485-
// the closure result type with a plain functon type that refers
1486-
// to local parameters. An example where this happens in `dependent-closures.scala`
1487-
// If the code after `val rhsType` is commented out, this file fails pickling tests.
1488-
// AVOIDANCE TODO: Follow up why this happens, and whether there
1489-
// are better ways to achieve this. It would be good if we could get rid of this code.
1490-
// It seems at least partially redundant with the nesting level checking on TypeVar
1491-
// instantiation.
1492-
val hygienicType = TypeOps.avoid(rhsType, termParamss.flatten)
1493-
if (!hygienicType.isValueType || !(hygienicType <:< tpt.tpe))
1494-
report.error(i"return type ${tpt.tpe} of lambda cannot be made hygienic;\n" +
1495-
i"it is not a supertype of the hygienic type $hygienicType", mdef.srcPos)
1496-
//println(i"lifting $rhsType over $termParamss -> $hygienicType = ${tpt.tpe}")
1497-
//println(TypeComparer.explained { implicit ctx => hygienicType <:< tpt.tpe })
1482+
typedAheadExpr(mdef.rhs, tpt.tpe).tpe
14981483
case _ =>
14991484
}
15001485
WildcardType

0 commit comments

Comments
 (0)