File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -48,20 +48,19 @@ class ElimContextClosures extends MiniPhase with IdentityDenotTransformer { this
48
48
trace(s " transforming ${tree.show} at phase ${ctx.phase}" , show = true ) {
49
49
50
50
def transformArg (arg : Tree , formal : Type ): Tree = {
51
- val formal1 = formal.widenDealias
51
+ val formal1 = formal.widen
52
52
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
55
62
case other => other
56
63
} // 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
-
65
64
else
66
65
arg
67
66
}
You can’t perform that action at this time.
0 commit comments