@@ -2501,7 +2501,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2501
2501
case rhs => typedExpr(rhs, tpt1.tpe.widenExpr)
2502
2502
}
2503
2503
val vdef1 = assignType(cpy.ValDef (vdef)(name, tpt1, rhs1), sym)
2504
- postProcessInfo(sym)
2504
+ postProcessInfo(vdef1, sym)
2505
2505
vdef1.setDefTree
2506
2506
}
2507
2507
@@ -4391,7 +4391,29 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4391
4391
var typeArgs = tree match
4392
4392
case Select (qual, nme.CONSTRUCTOR ) => qual.tpe.widenDealias.argTypesLo.map(TypeTree (_))
4393
4393
case _ => Nil
4394
- if typeArgs.isEmpty then typeArgs = constrained(poly, tree)._2.map(_.wrapInTypeTree(tree))
4394
+ if typeArgs.isEmpty then
4395
+ val poly1 = tree match
4396
+ case Select (qual, nme.apply) => qual.tpe.widen match
4397
+ case defn.PolyFunctionOf (_) =>
4398
+ // Given a poly function, like the one in i6682a:
4399
+ // val v = [T] => (y:T) => (x:y.type) => 3
4400
+ // It's possible to apply `v(v)` which extends to:
4401
+ // v.apply[?T](v)
4402
+ // Requiring the circular constraint `v <: ?T`,
4403
+ // (because type parameter T occurs in v's type).
4404
+ // So we create a fresh copy of the outer
4405
+ // poly method type, so we now extend to:
4406
+ // v.apply[?T'](v)
4407
+ // Where `?T'` is a type var for a T' type parameter,
4408
+ // leading to the non-circular `v <: ?T'` constraint.
4409
+ //
4410
+ // This also happens in `assignType(tree: untpd.TypeApply, ..)`
4411
+ // to avoid any type arguments, containing the type lambda,
4412
+ // being applied to the very same type lambda.
4413
+ poly.newLikeThis(poly.paramNames, poly.paramInfos, poly.resType)
4414
+ case _ => poly
4415
+ case _ => poly
4416
+ typeArgs = constrained(poly1, tree)._2.map(_.wrapInTypeTree(tree))
4395
4417
convertNewGenericArray(readapt(tree.appliedToTypeTrees(typeArgs)))
4396
4418
case wtp =>
4397
4419
val isStructuralCall = wtp.isValueType && isStructuralTermSelectOrApply(tree)
0 commit comments