@@ -528,7 +528,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
528
528
case tp2 : HKTypeLambda =>
529
529
def compareTypeLambda : Boolean = tp1.stripTypeVar match {
530
530
case tp1 : HKTypeLambda =>
531
- /* Don't compare bounds of lambdas under language:Scala2, or t2994 will fail.
531
+ /* Don't compare bounds of lambdas under language:Scala2, or t2994 will fail.
532
532
* The issue is that, logically, bounds should compare contravariantly,
533
533
* but that would invalidate a pattern exploited in t2994:
534
534
*
@@ -761,14 +761,14 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
761
761
}
762
762
763
763
/** Subtype test for the hk application `tp2 = tycon2[args2]`.
764
- */
764
+ */
765
765
def compareAppliedType2 (tp2 : AppliedType , tycon2 : Type , args2 : List [Type ]): Boolean = {
766
766
val tparams = tycon2.typeParams
767
767
if (tparams.isEmpty) return false // can happen for ill-typed programs, e.g. neg/tcpoly_overloaded.scala
768
768
769
769
/** True if `tp1` and `tp2` have compatible type constructors and their
770
- * corresponding arguments are subtypes relative to their variance (see `isSubArgs`).
771
- */
770
+ * corresponding arguments are subtypes relative to their variance (see `isSubArgs`).
771
+ */
772
772
def isMatchingApply (tp1 : Type ): Boolean = tp1 match {
773
773
case AppliedType (tycon1, args1) =>
774
774
tycon1.dealiasKeepRefiningAnnots match {
@@ -815,25 +815,25 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
815
815
}
816
816
817
817
/** `param2` can be instantiated to a type application prefix of the LHS
818
- * or to a type application prefix of one of the LHS base class instances
819
- * and the resulting type application is a supertype of `tp1`,
820
- * or fallback to fourthTry.
821
- */
818
+ * or to a type application prefix of one of the LHS base class instances
819
+ * and the resulting type application is a supertype of `tp1`,
820
+ * or fallback to fourthTry.
821
+ */
822
822
def canInstantiate (tycon2 : TypeParamRef ): Boolean = {
823
823
824
824
/** Let
825
- *
826
- * `tparams_1, ..., tparams_k-1` be the type parameters of the rhs
827
- * `tparams1_1, ..., tparams1_n-1` be the type parameters of the constructor of the lhs
828
- * `args1_1, ..., args1_n-1` be the type arguments of the lhs
829
- * `d = n - k`
830
- *
831
- * Returns `true` iff `d >= 0` and `tycon2` can be instantiated to
832
- *
833
- * [tparams1_d, ... tparams1_n-1] -> tycon1[args_1, ..., args_d-1, tparams_d, ... tparams_n-1]
834
- *
835
- * such that the resulting type application is a supertype of `tp1`.
836
- */
825
+ *
826
+ * `tparams_1, ..., tparams_k-1` be the type parameters of the rhs
827
+ * `tparams1_1, ..., tparams1_n-1` be the type parameters of the constructor of the lhs
828
+ * `args1_1, ..., args1_n-1` be the type arguments of the lhs
829
+ * `d = n - k`
830
+ *
831
+ * Returns `true` iff `d >= 0` and `tycon2` can be instantiated to
832
+ *
833
+ * [tparams1_d, ... tparams1_n-1] -> tycon1[args_1, ..., args_d-1, tparams_d, ... tparams_n-1]
834
+ *
835
+ * such that the resulting type application is a supertype of `tp1`.
836
+ */
837
837
def appOK (tp1base : Type ) = tp1base match {
838
838
case tp1base : AppliedType =>
839
839
var tycon1 = tp1base.tycon
@@ -874,21 +874,21 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
874
874
}
875
875
876
876
/** Fall back to comparing either with `fourthTry` or against the lower
877
- * approximation of the rhs.
878
- * @param tyconLo The type constructor's lower approximation.
879
- */
877
+ * approximation of the rhs.
878
+ * @param tyconLo The type constructor's lower approximation.
879
+ */
880
880
def fallback (tyconLo : Type ) =
881
881
either(fourthTry, isSubApproxHi(tp1, tyconLo.applyIfParameterized(args2)))
882
882
883
883
/** Let `tycon2bounds` be the bounds of the RHS type constructor `tycon2`.
884
- * Let `app2 = tp2` where the type constructor of `tp2` is replaced by
885
- * `tycon2bounds.lo`.
886
- * If both bounds are the same, continue with `tp1 <:< app2`.
887
- * otherwise continue with either
888
- *
889
- * tp1 <:< tp2 using fourthTry (this might instantiate params in tp1)
890
- * tp1 <:< app2 using isSubType (this might instantiate params in tp2)
891
- */
884
+ * Let `app2 = tp2` where the type constructor of `tp2` is replaced by
885
+ * `tycon2bounds.lo`.
886
+ * If both bounds are the same, continue with `tp1 <:< app2`.
887
+ * otherwise continue with either
888
+ *
889
+ * tp1 <:< tp2 using fourthTry (this might instantiate params in tp1)
890
+ * tp1 <:< app2 using isSubType (this might instantiate params in tp2)
891
+ */
892
892
def compareLower (tycon2bounds : TypeBounds , tyconIsTypeRef : Boolean ): Boolean =
893
893
if ((tycon2bounds.lo `eq` tycon2bounds.hi) && ! tycon2bounds.isInstanceOf [MatchAlias ])
894
894
if (tyconIsTypeRef) recur(tp1, tp2.superType)
@@ -927,7 +927,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
927
927
}
928
928
929
929
/** Subtype test for the application `tp1 = tycon1[args1]`.
930
- */
930
+ */
931
931
def compareAppliedType1 (tp1 : AppliedType , tycon1 : Type , args1 : List [Type ]): Boolean =
932
932
tycon1 match {
933
933
case param1 : TypeParamRef =>
@@ -973,8 +973,8 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
973
973
}
974
974
975
975
/** Like tp1 <:< tp2, but returns false immediately if we know that
976
- * the case was covered previously during subtyping.
977
- */
976
+ * the case was covered previously during subtyping.
977
+ */
978
978
def isNewSubType (tp1 : Type ): Boolean =
979
979
if (isCovered(tp1) && isCovered(tp2)) {
980
980
// println(s"useless subtype: $tp1 <:< $tp2")
@@ -1031,12 +1031,12 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] {
1031
1031
}
1032
1032
1033
1033
/** Subtype test for corresponding arguments in `args1`, `args2` according to
1034
- * variances in type parameters `tparams2`.
1035
- * @param tp1 The applied type containing `args1`
1036
- * @param tparams2 The type parameters of the type constructor applied to `args2`
1037
- */
1034
+ * variances in type parameters `tparams2`.
1035
+ *
1036
+ * @param tp1 The applied type containing `args1`
1037
+ * @param tparams2 The type parameters of the type constructor applied to `args2`
1038
+ */
1038
1039
def isSubArgs (args1 : List [Type ], args2 : List [Type ], tp1 : Type , tparams2 : List [ParamInfo ]): Boolean = {
1039
-
1040
1040
/** The bounds of parameter `tparam`, where all references to type paramneters
1041
1041
* are replaced by corresponding arguments (or their approximations in the case of
1042
1042
* wildcard arguments).
0 commit comments