@@ -5847,7 +5847,7 @@ object Types {
5847
5847
tp.derivedAppliedType(tycon, args.map(rangeToBounds)) match
5848
5848
case tp1 : AppliedType if tp1.isUnreducibleWild =>
5849
5849
// don't infer a type that would trigger an error later in
5850
- // Checling .checkAppliedType; fall through to default handling instead
5850
+ // Checking .checkAppliedType; fall through to default handling instead
5851
5851
case tp1 =>
5852
5852
return tp1
5853
5853
end if
@@ -5856,7 +5856,7 @@ object Types {
5856
5856
// non-range arguments L1, ..., Ln and H1, ..., Hn such that
5857
5857
// C[L1, ..., Ln] <: C[H1, ..., Hn] by taking the right limits of
5858
5858
// ranges that appear in as co- or contravariant arguments.
5859
- // Fail for non-variant argument ranges.
5859
+ // Fail for non-variant argument ranges (see use-site else branch below) .
5860
5860
// If successful, the L-arguments are in loBut, the H-arguments in hiBuf.
5861
5861
// @return operation succeeded for all arguments.
5862
5862
def distributeArgs (args : List [Type ], tparams : List [ParamInfo ]): Boolean = args match {
@@ -5877,11 +5877,18 @@ object Types {
5877
5877
if (distributeArgs(args, tp.tyconTypeParams))
5878
5878
range(tp.derivedAppliedType(tycon, loBuf.toList),
5879
5879
tp.derivedAppliedType(tycon, hiBuf.toList))
5880
- else range(defn.NothingType , defn.AnyType )
5881
- // TODO: can we give a better bound than `topType`?
5880
+ else if tycon.isLambdaSub || args.exists(isRangeOfNonTermTypes) then
5881
+ range(defn.NothingType , defn.AnyType )
5882
+ else
5883
+ // See lampepfl/dotty#14152
5884
+ range(defn.NothingType , tp.derivedAppliedType(tycon, args.map(rangeToBounds)))
5882
5885
else tp.derivedAppliedType(tycon, args)
5883
5886
}
5884
5887
5888
+ private def isRangeOfNonTermTypes (tp : Type ): Boolean = tp match
5889
+ case Range (lo, hi) => ! lo.isInstanceOf [TermType ] || ! hi.isInstanceOf [TermType ]
5890
+ case _ => false
5891
+
5885
5892
override protected def derivedAndType (tp : AndType , tp1 : Type , tp2 : Type ): Type =
5886
5893
if (isRange(tp1) || isRange(tp2)) range(lower(tp1) & lower(tp2), upper(tp1) & upper(tp2))
5887
5894
else tp.derivedAndType(tp1, tp2)
0 commit comments