File tree Expand file tree Collapse file tree 2 files changed +6
-14
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -58,8 +58,8 @@ object NullOpsDecorator {
5858 stripped ne self
5959 }
6060
61- /** Can the type has null value after erasure?
62- */
61+ /** Can the type has null value after erasure? */
62+ // TODO
6363 def isNullableAfterErasure (using Context ): Boolean = self match {
6464 case tp : ClassInfo => tp.cls.isNullableClassAfterErasure
6565 case tp : TypeProxy => tp.underlying.isNullableAfterErasure
@@ -74,17 +74,9 @@ object NullOpsDecorator {
7474 def isUnsafelyNulltoAnyRef (pt : Type )(using Context ): Boolean =
7575 self.isNullType && pt.isNullableAfterErasure
7676
77- def isUnsafeSubtype (pt : Type , relaxedSubtype : Boolean = false )(using Context ): Boolean =
78- val selfs = self.stripAllNulls
79- val pts = pt.stripAllNulls
80- if relaxedSubtype then
81- selfs relaxed_<:< pts
82- else
83- selfs <:< pts
84-
85- /** Can we convert a tree with type `self` to type `pt` unsafely.
86- */
77+ /** Can we convert a tree with type `self` to type `pt` unsafely. */
8778 def isUnsafelyConvertible (pt : Type , relaxedSubtype : Boolean = false )(using Context ): Boolean =
88- self.isUnsafelyNulltoAnyRef(pt) || self.isUnsafeSubtype(pt, relaxedSubtype)
79+ self.isUnsafelyNulltoAnyRef(pt)
80+ || TypeComparer .topLevelSubTypeIgnoringNulls(self, pt)
8981 }
9082}
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ object Implicits:
135135 if (approx) formal = wildApprox(formal)
136136 explore((argType relaxed_<:< formal.widenExpr) ||
137137 Nullables .convertUnsafeNulls &&
138- argType.isUnsafeSubtype (formal.widenExpr, true ))
138+ argType.isUnsafelyConvertible (formal.widenExpr))
139139 })
140140 Candidate .Conversion
141141 else
You can’t perform that action at this time.
0 commit comments