@@ -182,20 +182,6 @@ object ProtoTypes {
182182 if ((args eq this .args) && (resultType eq this .resultType) && (typer eq this .typer)) this
183183 else new FunProto (args, resultType, typer)
184184
185- def argsAreTyped : Boolean = myTypedArgs.size == args.length
186-
187- private def typedArg (arg : untpd.Tree , typerFn : untpd.Tree => Tree )(implicit ctx : Context ): Tree = {
188- var targ = myTypedArg(arg)
189- if (targ == null ) {
190- targ = typerFn(arg)
191- if (! ctx.reporter.hasPending) {
192- myTypedArg = myTypedArg.updated(arg, targ)
193- evalState = evalState.updated(arg, ctx.typerState)
194- }
195- }
196- targ
197- }
198-
199185 /** Forget the types of any arguments that have been typed producing a constraint in a
200186 * typer state that is not yet committed into the one of the current context `ctx`.
201187 * This is necessary to avoid "orphan" PolyParams that are referred to from
@@ -206,27 +192,40 @@ object ProtoTypes {
206192 def allArgTypesAreCurrent ()(implicit ctx : Context ): Boolean = {
207193 evalState foreachBinding { (arg, tstate) =>
208194 if (tstate.uncommittedAncestor.constraint ne ctx.typerState.constraint) {
209- println(i " need to invalidate $arg / ${myTypedArg(arg)}, ${tstate.constraint}, current = ${ctx.typerState.constraint}" )
195+ typr. println(i " need to invalidate $arg / ${myTypedArg(arg)}, ${tstate.constraint}, current = ${ctx.typerState.constraint}" )
210196 myTypedArg = myTypedArg.remove(arg)
211197 evalState = evalState.remove(arg)
212198 }
213199 }
214200 myTypedArg.size == args.length
215201 }
216202
203+ private def cacheTypedArg (arg : untpd.Tree , typerFn : untpd.Tree => Tree )(implicit ctx : Context ): Tree = {
204+ var targ = myTypedArg(arg)
205+ if (targ == null ) {
206+ targ = typerFn(arg)
207+ if (! ctx.reporter.hasPending) {
208+ myTypedArg = myTypedArg.updated(arg, targ)
209+ evalState = evalState.updated(arg, ctx.typerState)
210+ }
211+ }
212+ targ
213+ }
214+
217215 /** The typed arguments. This takes any arguments already typed using
218216 * `typedArg` into account.
219217 */
220218 def typedArgs : List [Tree ] = {
221- if (! argsAreTyped) myTypedArgs = args.mapconserve(typedArg(_, typer.typed(_)))
219+ if (myTypedArgs.size != args.length)
220+ myTypedArgs = args.mapconserve(cacheTypedArg(_, typer.typed(_)))
222221 myTypedArgs
223222 }
224223
225224 /** Type single argument and remember the unadapted result in `myTypedArg`.
226225 * used to avoid repeated typings of trees when backtracking.
227226 */
228227 def typedArg (arg : untpd.Tree , formal : Type )(implicit ctx : Context ): Tree = {
229- val targ = typedArg (arg, typer.typedUnadapted(_, formal))
228+ val targ = cacheTypedArg (arg, typer.typedUnadapted(_, formal))
230229 typer.adapt(targ, formal, arg)
231230 }
232231
@@ -262,7 +261,6 @@ object ProtoTypes {
262261 */
263262 class FunProtoTyped (args : List [tpd.Tree ], resultType : Type , typer : Typer )(implicit ctx : Context ) extends FunProto (args, resultType, typer)(ctx) {
264263 override def typedArgs = args
265- override def argsAreTyped = true
266264 }
267265
268266 /** A prototype for implicitly inferred views:
0 commit comments