Skip to content

Commit afa320c

Browse files
committed
Add test
1 parent bc0e8af commit afa320c

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,10 @@ object NullOpsDecorator {
6666
case tp: TypeProxy => tp.underlying.isNullableAfterErasure
6767
case OrType(lhs, rhs) =>
6868
lhs.isNullableAfterErasure || rhs.isNullableAfterErasure
69+
case AndType(lhs, rhs) =>
70+
lhs.isNullableAfterErasure && rhs.isNullableAfterErasure
6971
case _ =>
7072
self.isNullType || self <:< defn.ObjectType
7173
}
72-
73-
// def isUnsafelyNulltoAnyRef(pt: Type)(using Context): Boolean =
74-
// self.isNullType && pt.isNullableAfterErasure
75-
76-
// def isUnsafeSubtype(pt: Type, relaxedSubtype: Boolean = false)(using Context): Boolean =
77-
// val selfs = self.stripAllNulls
78-
// val pts = pt.stripAllNulls
79-
// if relaxedSubtype then
80-
// selfs relaxed_<:< pts
81-
// else
82-
// selfs <:< pts
83-
84-
// /** Can we convert a tree with type `self` to type `pt` unsafely.
85-
// */
86-
// def unsafeNullsSubType(pt: Type, relaxed: Boolean = false)(using Context): Boolean =
87-
// self.isUnsafelyNulltoAnyRef(pt) || self.isUnsafeSubtype(pt, relaxed)
8874
}
8975
}

tests/explicit-nulls/pos/i10001.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Issue10001 {
2+
val a: String = "Issue10001"
3+
val b: String | Null = a
4+
val c = s"$a"
5+
val d = s"$b"
6+
}

0 commit comments

Comments
 (0)