@@ -2,7 +2,7 @@ package dotty.tools.dotc.core
2
2
3
3
import dotty .tools .dotc .core .Contexts .Context
4
4
import 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 ._
6
6
7
7
/** Defines operations on nullable types. */
8
8
object NullOpsDecorator {
@@ -18,8 +18,8 @@ object NullOpsDecorator {
18
18
}
19
19
20
20
/** 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`.
23
23
* If this type isn't (syntactically) nullable, then returns the type unchanged.
24
24
*
25
25
* @param onlyJavaNull whether we only remove `JavaNull`, the default value is false
@@ -40,7 +40,7 @@ object NullOpsDecorator {
40
40
else tp.derivedOrType(llhs, rrhs)
41
41
case tp @ AndType (tp1, tp2) =>
42
42
// 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
44
44
// result `(A & B) | Null`.
45
45
val tp1s = strip(tp1)
46
46
val tp2s = strip(tp2)
@@ -59,8 +59,8 @@ object NullOpsDecorator {
59
59
def stripJavaNull (implicit ctx : Context ): Type = self.stripNull(true )
60
60
61
61
/** 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]
64
64
* If no `JavaNull` unions are found within the type, then returns the input type unchanged.
65
65
*/
66
66
def stripAllJavaNull (implicit ctx : Context ): Type = {
0 commit comments