@@ -144,26 +144,30 @@ object TypeTestsCasts {
144144 case _ => recur(defn.AnyType , tpT)
145145 }
146146 case tpe @ AppliedType (tycon, targs) if ! trustTypeApplication =>
147- X .widenDealias match {
148- case OrType (tp1, tp2) =>
149- // This case is required to retrofit type inference,
150- // which cut constraints in the following two cases:
151- // - T1 <:< T2 | T3
152- // - T1 & T2 <:< T3
153- // See TypeComparer#either
154- recur(tp1, P ) && recur(tp2, P )
155- case tpX : FlexibleType =>
156- recur(tpX.underlying, P )
157- case x =>
158- // always false test warnings are emitted elsewhere
159- // provablyDisjoint wants fully applied types as input; because we're in the middle of erasure, we sometimes get raw types here
160- val xApplied =
161- val tparams = x.typeParams
162- if tparams.isEmpty then x else x.appliedTo(tparams.map(_ => WildcardType ))
163- TypeComparer .provablyDisjoint(xApplied, tpe.derivedAppliedType(tycon, targs.map(_ => WildcardType )))
164- || typeArgsDeterminable(X , tpe)
165- ||| i " its type arguments can't be determined from $X"
166- }
147+ val abstractArgs = targs.filter(isAbstract)
148+ if abstractArgs.nonEmpty && ! tycon.classSymbol.is(Final ) then
149+ i " type arguments $abstractArgs refer to abstract types, "
150+ else
151+ X .widenDealias match {
152+ case OrType (tp1, tp2) =>
153+ // This case is required to retrofit type inference,
154+ // which cut constraints in the following two cases:
155+ // - T1 <:< T2 | T3
156+ // - T1 & T2 <:< T3
157+ // See TypeComparer#either
158+ recur(tp1, P ) && recur(tp2, P )
159+ case tpX : FlexibleType =>
160+ recur(tpX.underlying, P )
161+ case x =>
162+ // always false test warnings are emitted elsewhere
163+ // provablyDisjoint wants fully applied types as input; because we're in the middle of erasure, we sometimes get raw types here
164+ val xApplied =
165+ val tparams = x.typeParams
166+ if tparams.isEmpty then x else x.appliedTo(tparams.map(_ => WildcardType ))
167+ TypeComparer .provablyDisjoint(xApplied, tpe.derivedAppliedType(tycon, targs.map(_ => WildcardType )))
168+ || typeArgsDeterminable(X , tpe)
169+ ||| i " its type arguments can't be determined from $X"
170+ }
167171 case AndType (tp1, tp2) => recur(X , tp1) && recur(X , tp2)
168172 case OrType (tp1, tp2) => recur(X , tp1) && recur(X , tp2)
169173 case AnnotatedType (t, _) => recur(X , t)
0 commit comments