@@ -40,7 +40,9 @@ object NullOpsDecorator:
40
40
case _ => strip(tp)
41
41
42
42
override def apply (tp : Type ): Type =
43
- if isDeep then stripOver(tp) else strip(tp)
43
+ val tpw = tp.widenDealias
44
+ val tpws = if isDeep then stripOver(tpw) else strip(tpw)
45
+ if tpws ne tpw then tpws else tp
44
46
45
47
end StripNullsMap
46
48
@@ -52,11 +54,7 @@ object NullOpsDecorator:
52
54
* The type will not be changed if explicit-nulls is not enabled.
53
55
*/
54
56
def stripNull (using Context ): Type = {
55
- if ctx.explicitNulls then
56
- val selfw = self.widenDealias
57
- val selfws = new StripNullsMap (false )(selfw)
58
- if selfws ne selfw then selfws else self
59
- else self
57
+ if ctx.explicitNulls then new StripNullsMap (false )(self) else self
60
58
}
61
59
62
60
/** Is self (after widening and dealiasing) a type of the form `T | Null`? */
@@ -70,11 +68,7 @@ object NullOpsDecorator:
70
68
* each member of function types as well.
71
69
*/
72
70
def stripNullsDeep (using Context ): Type =
73
- if ctx.explicitNulls then
74
- val selfw = self.widenDealias
75
- val selfws = new StripNullsMap (true )(selfw)
76
- if selfws ne selfw then selfws else self
77
- else self
71
+ if ctx.explicitNulls then new StripNullsMap (true )(self) else self
78
72
79
73
end extension
80
74
0 commit comments