@@ -2,7 +2,7 @@ package dotty.tools.dotc.core
22
33import dotty .tools .dotc .core .Contexts .Context
44import dotty .tools .dotc .core .Symbols .defn
5- import dotty .tools .dotc .core .Types .{ AndType , ClassInfo , ConstantType , OrType , Type , TypeBounds , TypeMap , TypeProxy }
5+ import dotty .tools .dotc .core .Types ._
66
77/** Defines operations on nullable types. */
88object NullOpsDecorator {
@@ -18,8 +18,8 @@ object NullOpsDecorator {
1818 }
1919
2020 /** Syntactically strips the nullability from this type.
21- * If the normalized form (as per `normNullableUnion`) of this type is `T1 | ... | Tn-1 | Tn` ,
22- * and `Tn` references to `Null` (or `JavaNull`), then return `T1 | ... | Tn-1 `.
21+ * If the type is `T1 | ... | Tn`, and `Ti` references to `Null` (or `JavaNull`) ,
22+ * then return `T1 | ... | Ti-1 | Ti+1 | ... | Tn`.
2323 * If this type isn't (syntactically) nullable, then returns the type unchanged.
2424 *
2525 * @param onlyJavaNull whether we only remove `JavaNull`, the default value is false
@@ -40,7 +40,7 @@ object NullOpsDecorator {
4040 else tp.derivedOrType(llhs, rrhs)
4141 case tp @ AndType (tp1, tp2) =>
4242 // We cannot `tp.derivedAndType(strip(tp1), strip(tp2))` directly,
43- // since `normNullableUnion ((A | Null) & B)` would produce the wrong
43+ // since `stripNull ((A | Null) & B)` would produce the wrong
4444 // result `(A & B) | Null`.
4545 val tp1s = strip(tp1)
4646 val tp2s = strip(tp2)
@@ -59,8 +59,8 @@ object NullOpsDecorator {
5959 def stripJavaNull (implicit ctx : Context ): Type = self.stripNull(true )
6060
6161 /** Collapses all `JavaNull` unions within this type, and not just the outermost ones (as `stripJavaNull` does).
62- * e.g. (Array[String|Null]|Null).stripNull => Array[String|Null ]
63- * (Array[String|Null]|Null).stripInnerNulls => Array[String]
62+ * e.g. (Array[String|JavaNull]|JavaNull).stripJavaNull => Array[String|JavaNull ]
63+ * (Array[String|JavaNull]|JavaNull).stripAllJavaNull => Array[String]
6464 * If no `JavaNull` unions are found within the type, then returns the input type unchanged.
6565 */
6666 def stripAllJavaNull (implicit ctx : Context ): Type = {
0 commit comments