File tree 2 files changed +6
-14
lines changed
compiler/src/dotty/tools/dotc
2 files changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -58,8 +58,8 @@ object NullOpsDecorator {
58
58
stripped ne self
59
59
}
60
60
61
- /** Can the type has null value after erasure?
62
- */
61
+ /** Can the type has null value after erasure? */
62
+ // TODO
63
63
def isNullableAfterErasure (using Context ): Boolean = self match {
64
64
case tp : ClassInfo => tp.cls.isNullableClassAfterErasure
65
65
case tp : TypeProxy => tp.underlying.isNullableAfterErasure
@@ -74,17 +74,9 @@ object NullOpsDecorator {
74
74
def isUnsafelyNulltoAnyRef (pt : Type )(using Context ): Boolean =
75
75
self.isNullType && pt.isNullableAfterErasure
76
76
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. */
87
78
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)
89
81
}
90
82
}
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ object Implicits:
135
135
if (approx) formal = wildApprox(formal)
136
136
explore((argType relaxed_<:< formal.widenExpr) ||
137
137
Nullables .convertUnsafeNulls &&
138
- argType.isUnsafeSubtype (formal.widenExpr, true ))
138
+ argType.isUnsafelyConvertible (formal.widenExpr))
139
139
})
140
140
Candidate .Conversion
141
141
else
You can’t perform that action at this time.
0 commit comments