@@ -182,20 +182,6 @@ object ProtoTypes {
182
182
if ((args eq this .args) && (resultType eq this .resultType) && (typer eq this .typer)) this
183
183
else new FunProto (args, resultType, typer)
184
184
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
-
199
185
/** Forget the types of any arguments that have been typed producing a constraint in a
200
186
* typer state that is not yet committed into the one of the current context `ctx`.
201
187
* This is necessary to avoid "orphan" PolyParams that are referred to from
@@ -206,27 +192,40 @@ object ProtoTypes {
206
192
def allArgTypesAreCurrent ()(implicit ctx : Context ): Boolean = {
207
193
evalState foreachBinding { (arg, tstate) =>
208
194
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}" )
210
196
myTypedArg = myTypedArg.remove(arg)
211
197
evalState = evalState.remove(arg)
212
198
}
213
199
}
214
200
myTypedArg.size == args.length
215
201
}
216
202
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
+
217
215
/** The typed arguments. This takes any arguments already typed using
218
216
* `typedArg` into account.
219
217
*/
220
218
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(_)))
222
221
myTypedArgs
223
222
}
224
223
225
224
/** Type single argument and remember the unadapted result in `myTypedArg`.
226
225
* used to avoid repeated typings of trees when backtracking.
227
226
*/
228
227
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))
230
229
typer.adapt(targ, formal, arg)
231
230
}
232
231
@@ -262,7 +261,6 @@ object ProtoTypes {
262
261
*/
263
262
class FunProtoTyped (args : List [tpd.Tree ], resultType : Type , typer : Typer )(implicit ctx : Context ) extends FunProto (args, resultType, typer)(ctx) {
264
263
override def typedArgs = args
265
- override def argsAreTyped = true
266
264
}
267
265
268
266
/** A prototype for implicitly inferred views:
0 commit comments