@@ -20,7 +20,7 @@ import Denotations._
20
20
import Periods ._
21
21
import CheckRealizable ._
22
22
import Variances .{Variance , varianceFromInt , varianceToInt , setStructuralVariances , Invariant }
23
- import typer .Nullables
23
+ import typer .Nullables . useUnsafeNullsSubTypeIf
24
24
import util .Stats ._
25
25
import util .SimpleIdentitySet
26
26
import ast .tpd ._
@@ -1002,17 +1002,19 @@ object Types {
1002
1002
* @param matchLoosely if true the types `=> T` and `()T` are seen as overriding each other.
1003
1003
* @param checkClassInfo if true we check that ClassInfos are within bounds of abstract types
1004
1004
*/
1005
- final def overrides (that : Type , matchLoosely : => Boolean , checkClassInfo : Boolean = true )(using Context ): Boolean = {
1005
+ final def overrides (that : Type , matchLoosely : => Boolean ,
1006
+ checkClassInfo : Boolean = true , relaxedNulls : Boolean = false )(using Context ): Boolean = {
1006
1007
def widenNullary (tp : Type ) = tp match {
1007
1008
case tp @ MethodType (Nil ) => tp.resultType
1008
1009
case _ => tp
1009
1010
}
1010
1011
! checkClassInfo && this .isInstanceOf [ClassInfo ]
1011
- || (this .widenExpr frozen_<:< that.widenExpr)
1012
+ || useUnsafeNullsSubTypeIf(relaxedNulls) (this .widenExpr frozen_<:< that.widenExpr)
1012
1013
|| matchLoosely && {
1013
1014
val this1 = widenNullary(this )
1014
1015
val that1 = widenNullary(that)
1015
- ((this1 `ne` this ) || (that1 `ne` that)) && this1.overrides(that1, false , checkClassInfo)
1016
+ ((this1 `ne` this ) || (that1 `ne` that))
1017
+ && this1.overrides(that1, false , checkClassInfo, relaxedNulls)
1016
1018
}
1017
1019
}
1018
1020
@@ -1034,7 +1036,7 @@ object Types {
1034
1036
*/
1035
1037
def matches (that : Type )(using Context ): Boolean = {
1036
1038
record(" matches" )
1037
- Nullables . useUnsafeNullsSubTypeIf(ctx.explicitNulls)(
1039
+ useUnsafeNullsSubTypeIf(ctx.explicitNulls)(
1038
1040
TypeComparer .matchesType(this , that, relaxed = ! ctx.phase.erasedTypes))
1039
1041
}
1040
1042
0 commit comments