@@ -203,11 +203,11 @@ class CheckCaptures extends Recheck:
203
203
tp
204
204
end transformType
205
205
206
- private def interpolateVars (using Context ) = new TypeTraverser :
206
+ private def interpolator (using Context ) = new TypeTraverser :
207
207
override def traverse (t : Type ) =
208
208
t match
209
209
case CapturingType (parent, refs : CaptureSet .Var , _) =>
210
- // if variance < 0 then println(i"solving $t")
210
+ if variance < 0 then capt. println(i " solving $t" )
211
211
refs.solve(variance)
212
212
traverse(parent)
213
213
case t @ RefinedType (_, nme.apply, rinfo) if defn.isFunctionOrPolyType(t) =>
@@ -220,8 +220,8 @@ class CheckCaptures extends Recheck:
220
220
221
221
private def interpolateVarsIn (tpt : Tree )(using Context ): Unit =
222
222
if tpt.isInstanceOf [InferredTypeTree ] then
223
- // println(i"solving vars in ${ knownType(tpt)}, ${knownType(tpt).toString}" )
224
- interpolateVars.traverse( knownType(tpt))
223
+ interpolator.traverse( knownType(tpt))
224
+ .showing( i " solved vars in ${ knownType(tpt)} " , capt )
225
225
226
226
private var curEnv : Env = Env (NoSymbol , CaptureSet .empty, false , null )
227
227
@@ -289,7 +289,13 @@ class CheckCaptures extends Recheck:
289
289
290
290
override def recheckValDef (tree : ValDef , sym : Symbol )(using Context ): Unit =
291
291
try super .recheckValDef(tree, sym)
292
- finally interpolateVarsIn(tree.tpt)
292
+ finally
293
+ if ! sym.is(Param ) then
294
+ // parameters with inferred types belong to anonymous methods. We need to wait
295
+ // for more info from the context, so we cannot interpolate. Note that we cannot
296
+ // expect to have all necessary info available at the point where the anonymous
297
+ // function is compiled since we do not propagate expected types into blocks.
298
+ interpolateVarsIn(tree.tpt)
293
299
294
300
override def recheckDefDef (tree : DefDef , sym : Symbol )(using Context ): Unit =
295
301
val saved = curEnv
0 commit comments