Skip to content

Commit 009f18b

Browse files
committed
More concise implementation, remove unneeded dealiasing per comments on #13750
1 parent e76f078 commit 009f18b

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

compiler/src/dotty/tools/dotc/transform/ElimContextClosures.scala

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,19 @@ class ElimContextClosures extends MiniPhase with IdentityDenotTransformer { this
4848
trace(s"transforming ${tree.show} at phase ${ctx.phase}", show = true) {
4949

5050
def transformArg(arg: Tree, formal: Type): Tree = {
51-
val formal1 = formal.widenDealias
51+
val formal1 = formal.widen
5252
if defn.isContextFunctionType(formal1) && untpd.isContextualClosure(arg) then
53-
val body = unsplice(closureBody(arg)) match {
54-
case Apply(Select(fn, nme.apply), _) => fn
53+
unsplice(closureBody(arg)) match {
54+
case Apply(Select(body, nme.apply), _) =>
55+
val underlyingBodyType = body.tpe.widen
56+
val bodyIsContextual = defn.isContextFunctionType(underlyingBodyType)
57+
val bodyTypeMatches = TypeComparer.isSubType(underlyingBodyType, formal1)
58+
if bodyIsContextual && bodyTypeMatches then
59+
body
60+
else
61+
arg
5562
case other => other
5663
} // no-op if not a nested closure of some kind
57-
val underlyingBodyType = body.tpe.widenDealias
58-
val bodyIsContextual = defn.isContextFunctionType(underlyingBodyType)
59-
val bodyTypeMatches = TypeComparer.isSubType(underlyingBodyType, formal1)
60-
if bodyIsContextual && bodyTypeMatches then
61-
body
62-
else
63-
arg
64-
6564
else
6665
arg
6766
}

0 commit comments

Comments
 (0)