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
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 }
You can’t perform that action at this time.
0 commit comments