File tree 4 files changed +22
-12
lines changed
compiler/src/dotty/tools/dotc 4 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -61,15 +61,19 @@ object NullOpsDecorator {
61
61
/** Can the type has null value after erasure?
62
62
* TODO
63
63
*/
64
- def isNullableAfterErasure (using Context ): Boolean = self match {
65
- case tp : ClassInfo => tp.cls.isNullableClassAfterErasure
66
- case tp : TypeProxy => tp.underlying.isNullableAfterErasure
67
- case OrType (lhs, rhs) =>
68
- lhs.isNullableAfterErasure || rhs.isNullableAfterErasure
69
- case AndType (lhs, rhs) =>
70
- lhs.isNullableAfterErasure && rhs.isNullableAfterErasure
71
- case _ =>
72
- self.isNullType || self <:< defn.ObjectType
73
- }
64
+ // def isNullableAfterErasure(using Context): Boolean = self match {
65
+ // case tp: ClassInfo => tp.cls.isNullableClassAfterErasure
66
+ // case tp: TypeProxy => tp.underlying.isNullableAfterErasure
67
+ // case OrType(lhs, rhs) =>
68
+ // lhs.isNullableAfterErasure || rhs.isNullableAfterErasure
69
+ // case AndType(lhs, rhs) =>
70
+ // lhs.isNullableAfterErasure && rhs.isNullableAfterErasure
71
+ // case _ =>
72
+ // self.isNullType || self <:< defn.ObjectType
73
+ // }
74
+ def isNullableAfterErasure (using Context ): Boolean =
75
+ self.isNullType
76
+ || ! self.isNothingType
77
+ && self.derivesFrom(defn.ObjectClass , afterErasure = true )
74
78
}
75
79
}
Original file line number Diff line number Diff line change @@ -1791,7 +1791,9 @@ object SymDenotations {
1791
1791
derivesFrom(base) ||
1792
1792
base.isClass && (
1793
1793
(symbol eq defn.NothingClass ) ||
1794
- (symbol eq defn.NullClass ) && (base ne defn.NothingClass ))
1794
+ (! ctx.explicitNulls || ctx.phase.erasedTypes)
1795
+ && (symbol eq defn.NullClass )
1796
+ && (base ne defn.NothingClass ))
1795
1797
1796
1798
/** Is it possible that a class inherits both `this` and `that`?
1797
1799
*
Original file line number Diff line number Diff line change @@ -1591,6 +1591,9 @@ object Types {
1591
1591
/** Is this (an alias of) the `scala.Null` type? */
1592
1592
final def isNullType (using Context ) = isRef(defn.NullClass )
1593
1593
1594
+ /** Is this (an alias of) the `scala.Nothing` type? */
1595
+ final def isNothingType (using Context ) = isRef(defn.NothingClass )
1596
+
1594
1597
/** The resultType of a LambdaType, or ExprType, the type itself for others */
1595
1598
def resultType (using Context ): Type = this
1596
1599
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import dotty.tools.dotc.core.CheckRealizable
10
10
import dotty .tools .dotc .core .Decorators ._
11
11
import dotty .tools .dotc .core .Denotations .SingleDenotation
12
12
import dotty .tools .dotc .core .Flags ._
13
+ import dotty .tools .dotc .core .{Mode => CMode }
13
14
import dotty .tools .dotc .core .Names .{Name , TermName }
14
15
import dotty .tools .dotc .core .NameKinds .SimpleNameKind
15
16
import dotty .tools .dotc .core .NameOps ._
@@ -252,7 +253,7 @@ object Completion {
252
253
}
253
254
254
255
// 2. The extension method is a member of some given instance that is visible at the point of the reference.
255
- val givensInScope = ctx.implicits.eligible(defn.AnyType ).map(_.implicitRef.underlyingRef)
256
+ val givensInScope = ctx.implicits.eligible(defn.AnyType , ctx.mode.is( CMode . UnsafeNullConversion ) ).map(_.implicitRef.underlyingRef)
256
257
val extMethodsFromGivensInScope = extractDefinedExtensionMethods(givensInScope)
257
258
258
259
// 3. The reference is of the form r.m and the extension method is defined in the implicit scope of the type of r.
You can’t perform that action at this time.
0 commit comments