@@ -35,7 +35,7 @@ import dotty.tools.dotc.core.Decorators.i
3535 * to handle the full spectrum of Scala types. Additionally, some kinds of symbols like constructors and
3636 * enum instances get special treatment.
3737 */
38- object JavaNullInterop {
38+ object ImplicitNullInterop {
3939
4040 /** Transforms the type `tp` of Java member `sym` to be explicitly nullable.
4141 * `tp` is needed because the type inside `sym` might not be set when this method is called.
@@ -55,7 +55,6 @@ object JavaNullInterop {
5555 */
5656 def nullifyMember (sym : Symbol , tp : Type , isEnumValueDef : Boolean )(using Context ): Type = trace(i " nullifyMember ${sym}, ${tp}" ){
5757 assert(ctx.explicitNulls)
58- // assert(sym.is(JavaDefined), "can only nullify java-defined members")
5958
6059 // Some special cases when nullifying the type
6160 if isEnumValueDef || sym.name == nme.TYPE_ // Don't nullify the `TYPE` field in every class and Java enum instances
@@ -81,14 +80,14 @@ object JavaNullInterop {
8180 * but the result type is not nullable.
8281 */
8382 private def nullifyExceptReturnType (tp : Type )(using Context ): Type =
84- new JavaNullMap (outermostLevelAlreadyNullable = true )(tp)
83+ new ImplicitNullMap (outermostLevelAlreadyNullable = true )(tp)
8584
86- /** Nullifies a Java type by adding `| Null` in the relevant places. */
85+ /** Nullifies a type by adding `| Null` in the relevant places. */
8786 private def nullifyType (tp : Type )(using Context ): Type =
88- new JavaNullMap (outermostLevelAlreadyNullable = false )(tp)
87+ new ImplicitNullMap (outermostLevelAlreadyNullable = false )(tp)
8988
90- /** A type map that implements the nullification function on types. Given a Java-sourced type, this adds `| Null`
91- * in the right places to make the nulls explicit in Scala .
89+ /** A type map that implements the nullification function on types. Given a Java-sourced type or an
90+ * implicitly null type, this adds `| Null` in the right places to make the nulls explicit.
9291 *
9392 * @param outermostLevelAlreadyNullable whether this type is already nullable at the outermost level.
9493 * For example, `Array[String] | Null` is already nullable at the
@@ -98,7 +97,7 @@ object JavaNullInterop {
9897 * This is useful for e.g. constructors, and also so that `A & B` is nullified
9998 * to `(A & B) | Null`, instead of `(A | Null & B | Null) | Null`.
10099 */
101- private class JavaNullMap (var outermostLevelAlreadyNullable : Boolean )(using Context ) extends TypeMap {
100+ private class ImplicitNullMap (var outermostLevelAlreadyNullable : Boolean )(using Context ) extends TypeMap {
102101 def nullify (tp : Type ): Type = if ctx.flexibleTypes then FlexibleType (tp) else OrNull (tp)
103102
104103 /** Should we nullify `tp` at the outermost level? */
0 commit comments