Skip to content

Commit cf75785

Browse files
committed
rename paramVariance -> paramVarianceSign
1 parent ec4e3f9 commit cf75785

13 files changed

+26
-26
lines changed

compiler/src/dotty/tools/dotc/core/ParamInfo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ trait ParamInfo {
3535
def paramInfoOrCompleter(implicit ctx: Context): Type
3636

3737
/** The variance of the type parameter */
38-
def paramVariance(implicit ctx: Context): Int
38+
def paramVarianceSign(implicit ctx: Context): Int
3939

4040
/** A type that refers to the parameter */
4141
def paramRef(implicit ctx: Context): Type

compiler/src/dotty/tools/dotc/core/PatternTypeConstrainer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ trait PatternTypeConstrainer { self: TypeComparer =>
191191
def apply(tp: Type) = mapOver(tp) match {
192192
case tp @ AppliedType(tycon, args) =>
193193
val args1 = args.zipWithConserve(tycon.typeParams)((arg, tparam) =>
194-
if (tparam.paramVariance != 0) TypeBounds.empty else arg
194+
if (tparam.paramVarianceSign != 0) TypeBounds.empty else arg
195195
)
196196
tp.derivedAppliedType(tycon, args1)
197197
case tp =>

compiler/src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ object Symbols {
699699
def paramInfo(implicit ctx: Context): Type = denot.info
700700
def paramInfoAsSeenFrom(pre: Type)(implicit ctx: Context): Type = pre.memberInfo(this)
701701
def paramInfoOrCompleter(implicit ctx: Context): Type = denot.infoOrCompleter
702-
def paramVariance(implicit ctx: Context): Int = denot.variance
702+
def paramVarianceSign(implicit ctx: Context): Int = denot.variance
703703
def paramRef(implicit ctx: Context): TypeRef = denot.typeRef
704704

705705
// -------- Printing --------------------------------------------------------

compiler/src/dotty/tools/dotc/core/TypeApplications.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,11 @@ class TypeApplications(val self: Type) extends AnyVal {
310310
else {
311311
def adaptArg(arg: Type): Type = arg match {
312312
case arg @ HKTypeLambda(tparams, body) if
313-
!tparams.corresponds(hkParams)(_.paramVariance == _.paramVariance) &&
313+
!tparams.corresponds(hkParams)(_.paramVarianceSign == _.paramVarianceSign) &&
314314
tparams.corresponds(hkParams)(varianceConforms) =>
315315
HKTypeLambda(
316316
tparams.lazyZip(hkParams).map((tparam, hkparam) =>
317-
tparam.paramName.withVariance(hkparam.paramVariance)))(
317+
tparam.paramName.withVariance(hkparam.paramVarianceSign)))(
318318
tl => arg.paramInfos.map(_.subst(arg, tl).bounds),
319319
tl => arg.resultType.subst(arg, tl)
320320
)

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
12141214
if (args1.isEmpty) args2.isEmpty
12151215
else args2.nonEmpty && {
12161216
val tparam = tparams2.head
1217-
val v = tparam.paramVariance
1217+
val v = tparam.paramVarianceSign
12181218

12191219
/** Try a capture conversion:
12201220
* If the original left-hand type `leftRoot` is a path `p.type`,
@@ -1840,7 +1840,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
18401840
val arg1 :: args1Rest = args1
18411841
val arg2 :: args2Rest = args2
18421842
val common = singletonInterval(arg1, arg2)
1843-
val v = tparam.paramVariance
1843+
val v = tparam.paramVarianceSign
18441844
val lubArg =
18451845
if (common.exists) common
18461846
else if (v > 0) lub(arg1.hiBound, arg2.hiBound, canConstrain)
@@ -1872,7 +1872,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
18721872
val arg1 :: args1Rest = args1
18731873
val arg2 :: args2Rest = args2
18741874
val common = singletonInterval(arg1, arg2)
1875-
val v = tparam.paramVariance
1875+
val v = tparam.paramVarianceSign
18761876
val glbArg =
18771877
if (common.exists) common
18781878
else if (v > 0) glb(arg1.hiBound, arg2.hiBound)
@@ -2022,7 +2022,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
20222022
HKTypeLambda(
20232023
paramNames = HKTypeLambda.syntheticParamNames(tparams1.length).lazyZip(tparams1).lazyZip(tparams2)
20242024
.map((pname, tparam1, tparam2) =>
2025-
pname.withVariance((tparam1.paramVariance + tparam2.paramVariance) / 2)))(
2025+
pname.withVariance((tparam1.paramVarianceSign + tparam2.paramVarianceSign) / 2)))(
20262026
paramInfosExp = tl => tparams1.lazyZip(tparams2).map((tparam1, tparam2) =>
20272027
tl.integrate(tparams1, tparam1.paramInfoAsSeenFrom(tp1)).bounds &
20282028
tl.integrate(tparams2, tparam2.paramInfoAsSeenFrom(tp2)).bounds),
@@ -2211,7 +2211,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
22112211
case OrType(tp1, tp2) => provablyEmpty(tp1) && provablyEmpty(tp2)
22122212
case at @ AppliedType(tycon, args) =>
22132213
args.lazyZip(tycon.typeParams).exists { (arg, tparam) =>
2214-
tparam.paramVariance >= 0
2214+
tparam.paramVarianceSign >= 0
22152215
&& provablyEmpty(arg)
22162216
&& typeparamCorrespondsToField(tycon, tparam)
22172217
}
@@ -2286,7 +2286,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
22862286

22872287
args1.lazyZip(args2).lazyZip(tycon1.typeParams).exists {
22882288
(arg1, arg2, tparam) =>
2289-
val v = tparam.paramVariance
2289+
val v = tparam.paramVarianceSign
22902290
if (v > 0)
22912291
covariantDisjoint(arg1, arg2, tparam)
22922292
else if (v < 0)

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,7 @@ object Types {
20352035
if (0 <= idx && idx < args.length) {
20362036
val argInfo = args(idx) match {
20372037
case arg: TypeBounds =>
2038-
val v = param.paramVariance
2038+
val v = param.paramVarianceSign
20392039
val pbounds = param.paramInfo
20402040
if (v > 0 && pbounds.loBound.dealiasKeepAnnots.isBottomType) TypeAlias(arg.hiBound & rebase(pbounds.hiBound))
20412041
else if (v < 0 && pbounds.hiBound.dealiasKeepAnnots.isTopType) TypeAlias(arg.loBound | rebase(pbounds.loBound))
@@ -2191,7 +2191,7 @@ object Types {
21912191
case base: AndOrType =>
21922192
var tp1 = argForParam(base.tp1)
21932193
var tp2 = argForParam(base.tp2)
2194-
val variance = tparam.paramVariance
2194+
val variance = tparam.paramVarianceSign
21952195
if (isBounds(tp1) || isBounds(tp2) || variance == 0) {
21962196
// compute argument as a type bounds instead of a point type
21972197
tp1 = tp1.bounds
@@ -3529,7 +3529,7 @@ object Types {
35293529
pt => List.fill(n)(TypeBounds.empty), pt => defn.AnyType)
35303530

35313531
override def paramName(param: ParamInfo.Of[TypeName])(implicit ctx: Context): TypeName =
3532-
param.paramName.withVariance(param.paramVariance)
3532+
param.paramName.withVariance(param.paramVarianceSign)
35333533

35343534
/** Distributes Lambda inside type bounds. Examples:
35353535
*
@@ -3585,7 +3585,7 @@ object Types {
35853585
def paramInfo(implicit ctx: Context): tl.PInfo = tl.paramInfos(n)
35863586
def paramInfoAsSeenFrom(pre: Type)(implicit ctx: Context): tl.PInfo = paramInfo
35873587
def paramInfoOrCompleter(implicit ctx: Context): Type = paramInfo
3588-
def paramVariance(implicit ctx: Context): Int = tl.paramNames(n).variance
3588+
def paramVarianceSign(implicit ctx: Context): Int = tl.paramNames(n).variance
35893589
def paramRef(implicit ctx: Context): Type = tl.paramRefs(n)
35903590
}
35913591

@@ -4685,7 +4685,7 @@ object Types {
46854685
case arg :: otherArgs if tparams.nonEmpty =>
46864686
val arg1 = arg match {
46874687
case arg: TypeBounds => this(arg)
4688-
case arg => atVariance(variance * tparams.head.paramVariance)(this(arg))
4688+
case arg => atVariance(variance * tparams.head.paramVarianceSign)(this(arg))
46894689
}
46904690
val otherArgs1 = mapArgs(otherArgs, tparams.tail)
46914691
if ((arg1 eq arg) && (otherArgs1 eq otherArgs)) args
@@ -4987,7 +4987,7 @@ object Types {
49874987
// @return operation succeeded for all arguments.
49884988
def distributeArgs(args: List[Type], tparams: List[ParamInfo]): Boolean = args match {
49894989
case Range(lo, hi) :: args1 =>
4990-
val v = tparams.head.paramVariance
4990+
val v = tparams.head.paramVarianceSign
49914991
if (v == 0) false
49924992
else {
49934993
if (v > 0) { loBuf += lo; hiBuf += hi }
@@ -5105,7 +5105,7 @@ object Types {
51055105
val tparam = tparams.head
51065106
val acc = args.head match {
51075107
case arg: TypeBounds => this(x, arg)
5108-
case arg => atVariance(variance * tparam.paramVariance)(this(x, arg))
5108+
case arg => atVariance(variance * tparam.paramVarianceSign)(this(x, arg))
51095109
}
51105110
foldArgs(acc, tparams.tail, args.tail)
51115111
}

compiler/src/dotty/tools/dotc/core/Variances.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ object Variances {
8787
args match {
8888
case arg :: args1 =>
8989
varianceInArgs(
90-
v & compose(varianceInType(arg)(tparam), tparams.head.paramVariance),
90+
v & compose(varianceInType(arg)(tparam), tparams.head.paramVarianceSign),
9191
args1, tparams.tail)
9292
case nil =>
9393
v
@@ -131,7 +131,7 @@ object Variances {
131131
/** Does the variance of type parameter `tparam1` conform to the variance of type parameter `tparam2`?
132132
*/
133133
def varianceConforms(tparam1: TypeParamInfo, tparam2: TypeParamInfo)(implicit ctx: Context): Boolean =
134-
varianceConforms(tparam1.paramVariance, tparam2.paramVariance)
134+
varianceConforms(tparam1.paramVarianceSign, tparam2.paramVarianceSign)
135135

136136
/** Do the variances of type parameters `tparams1` conform to the variances
137137
* of corresponding type parameters `tparams2`?

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
545545
}
546546

547547
def apiTypeParameter(tparam: ParamInfo): api.TypeParameter =
548-
apiTypeParameter(tparam.paramName.toString, tparam.paramVariance,
548+
apiTypeParameter(tparam.paramName.toString, tparam.paramVarianceSign,
549549
tparam.paramInfo.bounds.lo, tparam.paramInfo.bounds.hi)
550550

551551
def apiTypeParameter(name: String, variance: Int, lo: Type, hi: Type): api.TypeParameter =

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ trait Applications extends Compatibility {
13941394
def apply(t: Type) = t match {
13951395
case t @ AppliedType(tycon, args) =>
13961396
def mapArg(arg: Type, tparam: TypeParamInfo) =
1397-
if (variance > 0 && tparam.paramVariance < 0) defn.FunctionOf(arg :: Nil, defn.UnitType)
1397+
if (variance > 0 && tparam.paramVarianceSign < 0) defn.FunctionOf(arg :: Nil, defn.UnitType)
13981398
else arg
13991399
mapOver(t.derivedAppliedType(tycon, args.zipWithConserve(tycon.typeParams)(mapArg)))
14001400
case _ => mapOver(t)

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ trait Implicits { self: Typer =>
10321032
}
10331033
resType <:< target
10341034
val tparams = poly.paramRefs
1035-
val variances = caseClass.typeParams.map(_.paramVariance)
1035+
val variances = caseClass.typeParams.map(_.paramVarianceSign)
10361036
val instanceTypes = tparams.lazyZip(variances).map((tparam, variance) =>
10371037
ctx.typeComparer.instanceType(tparam, fromBelow = variance < 0))
10381038
resType.substParams(poly, instanceTypes)

compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ trait QuotesAndSplices {
218218
case tdef: TypeDef if tdef.symbol.hasAnnotation(defn.InternalQuoted_patternBindHoleAnnot) =>
219219
transformTypeBindingTypeDef(tdef, typePatBuf)
220220
case tree @ AppliedTypeTree(tpt, args) =>
221-
val args1: List[Tree] = args.zipWithConserve(tpt.tpe.typeParams.map(_.paramVariance)) { (arg, v) =>
221+
val args1: List[Tree] = args.zipWithConserve(tpt.tpe.typeParams.map(_.paramVarianceSign)) { (arg, v) =>
222222
arg.tpe match {
223223
case _: TypeBounds => transform(arg)
224224
case _ => atVariance(variance * v)(transform(arg))

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ object RefChecks {
667667
def checkCaseClassInheritanceInvariant() =
668668
for (caseCls <- clazz.info.baseClasses.tail.find(_.is(Case)))
669669
for (baseCls <- caseCls.info.baseClasses.tail)
670-
if (baseCls.typeParams.exists(_.paramVariance != 0))
670+
if (baseCls.typeParams.exists(_.paramVarianceSign != 0))
671671
for (problem <- variantInheritanceProblems(baseCls, caseCls, "non-variant", "case "))
672672
ctx.errorOrMigrationWarning(problem(), clazz.sourcePos)
673673
checkNoAbstractMembers()

compiler/src/dotty/tools/dotc/typer/VarianceChecker.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ object VarianceChecker {
4545
def apply(x: Boolean, t: Type) = x && {
4646
t match {
4747
case tref: TypeParamRef if tref.binder `eq` tl =>
48-
val v = tl.typeParams(tref.paramNum).paramVariance
48+
val v = tl.typeParams(tref.paramNum).paramVarianceSign
4949
varianceConforms(variance, v) || { error(tref); false }
5050
case AnnotatedType(_, annot) if annot.symbol == defn.UncheckedVarianceAnnot =>
5151
x

0 commit comments

Comments
 (0)