@@ -20,6 +20,7 @@ import ast.tpd.*
2020import Synthesizer .*
2121import sbt .ExtractDependencies .*
2222import xsbti .api .DependencyContext .*
23+ import TypeComparer .{fullLowerBound , fullUpperBound }
2324
2425/** Synthesize terms for special classes */
2526class Synthesizer (typer : Typer )(using @ constructorOnly c : Context ):
@@ -50,18 +51,20 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
5051 // add that special case.
5152 def isGroundConstr (tp : Type ): Boolean = tp.dealias match
5253 case tvar : TypeVar if ctx.typerState.constraint.contains(tvar) => false
54+ case pref : TypeParamRef if ctx.typerState.constraint.contains(pref) => false
5355 case tp : AndOrType => isGroundConstr(tp.tp1) && isGroundConstr(tp.tp2)
5456 case _ => true
5557 instArg(
5658 if tvar.hasLowerBound then
57- if isGroundConstr(tvar.lowerBound ) then tvar.instantiate(fromBelow = true )
59+ if isGroundConstr(fullLowerBound( tvar.origin) ) then tvar.instantiate(fromBelow = true )
5860 else if isFullyDefined(tp, ForceDegree .all) then tp
5961 else NoType
6062 else if tvar.hasUpperBound then
61- if isGroundConstr(tvar.upperBound ) then tvar.instantiate(fromBelow = false )
63+ if isGroundConstr(fullUpperBound( tvar.origin) ) then tvar.instantiate(fromBelow = false )
6264 else if isFullyDefined(tp, ForceDegree .all) then tp
6365 else NoType
64- else NoType )
66+ else
67+ NoType )
6568 case _ =>
6669 tp
6770
@@ -593,9 +596,8 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
593596 resType <:< target
594597 val tparams = poly.paramRefs
595598 val variances = childClass.typeParams.map(_.paramVarianceSign)
596- val instanceTypes = tparams.lazyZip(variances).map( (tparam, variance) =>
599+ val instanceTypes = tparams.lazyZip(variances).map: (tparam, variance) =>
597600 TypeComparer .instanceType(tparam, fromBelow = variance < 0 , Widen .Unions )
598- )
599601 val instanceType = resType.substParams(poly, instanceTypes)
600602 // this is broken in tests/run/i13332intersection.scala,
601603 // because type parameters are not correctly inferred.
0 commit comments