@@ -20,6 +20,7 @@ import ast.tpd.*
20
20
import Synthesizer .*
21
21
import sbt .ExtractDependencies .*
22
22
import xsbti .api .DependencyContext .*
23
+ import TypeComparer .{fullLowerBound , fullUpperBound }
23
24
24
25
/** Synthesize terms for special classes */
25
26
class Synthesizer (typer : Typer )(using @ constructorOnly c : Context ):
@@ -50,18 +51,20 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
50
51
// add that special case.
51
52
def isGroundConstr (tp : Type ): Boolean = tp.dealias match
52
53
case tvar : TypeVar if ctx.typerState.constraint.contains(tvar) => false
54
+ case pref : TypeParamRef if ctx.typerState.constraint.contains(pref) => false
53
55
case tp : AndOrType => isGroundConstr(tp.tp1) && isGroundConstr(tp.tp2)
54
56
case _ => true
55
57
instArg(
56
58
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 )
58
60
else if isFullyDefined(tp, ForceDegree .all) then tp
59
61
else NoType
60
62
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 )
62
64
else if isFullyDefined(tp, ForceDegree .all) then tp
63
65
else NoType
64
- else NoType )
66
+ else
67
+ NoType )
65
68
case _ =>
66
69
tp
67
70
@@ -593,9 +596,8 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
593
596
resType <:< target
594
597
val tparams = poly.paramRefs
595
598
val variances = childClass.typeParams.map(_.paramVarianceSign)
596
- val instanceTypes = tparams.lazyZip(variances).map( (tparam, variance) =>
599
+ val instanceTypes = tparams.lazyZip(variances).map: (tparam, variance) =>
597
600
TypeComparer .instanceType(tparam, fromBelow = variance < 0 , Widen .Unions )
598
- )
599
601
val instanceType = resType.substParams(poly, instanceTypes)
600
602
// this is broken in tests/run/i13332intersection.scala,
601
603
// because type parameters are not correctly inferred.
0 commit comments