Skip to content

Commit 23a52e7

Browse files
committed
move widenDealias
1 parent 9445d16 commit 23a52e7

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

compiler/src/dotty/tools/dotc/core/NullOpsDecorator.scala

+5-11
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ object NullOpsDecorator:
4040
case _ => strip(tp)
4141

4242
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
4446

4547
end StripNullsMap
4648

@@ -52,11 +54,7 @@ object NullOpsDecorator:
5254
* The type will not be changed if explicit-nulls is not enabled.
5355
*/
5456
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
6058
}
6159

6260
/** Is self (after widening and dealiasing) a type of the form `T | Null`? */
@@ -70,11 +68,7 @@ object NullOpsDecorator:
7068
* each member of function types as well.
7169
*/
7270
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
7872

7973
end extension
8074

0 commit comments

Comments
 (0)