@@ -154,38 +154,9 @@ trait AsyncTransform {
154154 sym.asModule.moduleClass.setOwner(stateMachineClass)
155155 }
156156 }
157- // Replace the ValDefs in the splicee with Assigns to the corresponding lifted
158- // fields. Similarly, replace references to them with references to the field.
159- //
160- // This transform will only be run on the RHS of `def foo`.
161- val useFields : (Tree , TypingTransformApi ) => Tree = (tree, api) => {
162- val result : Tree = tree match {
163- case _ if api.currentOwner == stateMachineClass =>
164- api.default(tree)
165- case ValDef (_, _, _, rhs) if liftedSyms(tree.symbol) =>
166- api.atOwner(api.currentOwner) {
167- val fieldSym = tree.symbol
168- if (fieldSym.asTerm.isLazy) Literal (Constant (()))
169- else {
170- val lhs = atPos(tree.pos) {
171- gen.mkAttributedStableRef(thisType(fieldSym.owner.asClass), fieldSym)
172- }
173- treeCopy.Assign (tree, lhs, api.recur(rhs)).setType(definitions.UnitTpe ).changeOwner(fieldSym, api.currentOwner)
174- }
175- }
176- case _ : DefTree if liftedSyms(tree.symbol) =>
177- EmptyTree
178- case Ident (name) if liftedSyms(tree.symbol) =>
179- val fieldSym = tree.symbol
180- atPos(tree.pos) {
181- gen.mkAttributedStableRef(thisType(fieldSym.owner.asClass), fieldSym).setType(tree.tpe)
182- }
183- case ta : TypeApply =>
184- api.default(tree)
185- case _ =>
186- api.default(tree)
187- }
188- val resultType = if (result.tpe eq null ) null else result.tpe.map {
157+
158+ def adjustType (tree : Tree ): Tree = {
159+ val resultType = if (tree.tpe eq null ) null else tree.tpe.map {
189160 case TypeRef (pre, sym, args) if liftedSyms.contains(sym) =>
190161 val tp1 = internal.typeRef(thisType(sym.owner.asClass), sym, args)
191162 tp1
@@ -194,7 +165,41 @@ trait AsyncTransform {
194165 tp1
195166 case tp => tp
196167 }
197- setType(result, resultType)
168+ setType(tree, resultType)
169+ }
170+
171+ // Replace the ValDefs in the splicee with Assigns to the corresponding lifted
172+ // fields. Similarly, replace references to them with references to the field.
173+ //
174+ // This transform will only be run on the RHS of `def foo`.
175+ val useFields : (Tree , TypingTransformApi ) => Tree = (tree, api) => tree match {
176+ case _ if api.currentOwner == stateMachineClass =>
177+ api.default(tree)
178+ case ValDef (_, _, _, rhs) if liftedSyms(tree.symbol) =>
179+ api.atOwner(api.currentOwner) {
180+ val fieldSym = tree.symbol
181+ if (fieldSym.asTerm.isLazy) Literal (Constant (()))
182+ else {
183+ val lhs = atPos(tree.pos) {
184+ gen.mkAttributedStableRef(thisType(fieldSym.owner.asClass), fieldSym)
185+ }
186+ treeCopy.Assign (tree, lhs, api.recur(rhs)).setType(definitions.UnitTpe ).changeOwner(fieldSym, api.currentOwner)
187+ }
188+ }
189+ case _ : DefTree if liftedSyms(tree.symbol) =>
190+ EmptyTree
191+ case Ident (name) if liftedSyms(tree.symbol) =>
192+ val fieldSym = tree.symbol
193+ atPos(tree.pos) {
194+ gen.mkAttributedStableRef(thisType(fieldSym.owner.asClass), fieldSym).setType(tree.tpe)
195+ }
196+ case sel @ Select (n@ New (tt : TypeTree ), nme.CONSTRUCTOR ) =>
197+ adjustType(sel)
198+ adjustType(n)
199+ adjustType(tt)
200+ sel
201+ case _ =>
202+ api.default(tree)
198203 }
199204
200205 val liftablesUseFields = liftables.map {
0 commit comments