Skip to content

Commit 1c15bef

Browse files
authored
Merge pull request #50 from noti0na1/dotty-explicit-nulls-notNull
Update comments
2 parents a8f3dc1 + 2f42d1b commit 1c15bef

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Diff for: compiler/src/dotty/tools/dotc/core/Definitions.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class Definitions {
269269
@tu lazy val Any_asInstanceOf: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.asInstanceOf_, _.paramRefs(0), Final)
270270
@tu lazy val Any_typeTest: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.isInstanceOfPM, _ => BooleanType, Final | Synthetic | Artifact)
271271
@tu lazy val Any_typeCast: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.asInstanceOfPM, _.paramRefs(0), Final | Synthetic | Artifact | StableRealizable)
272-
// generated by pattern matcher and exlicit nulls, eliminated by erasure
272+
// generated by pattern matcher and explicit nulls, eliminated by erasure
273273

274274
/** def getClass[A >: this.type](): Class[? <: A] */
275275
@tu lazy val Any_getClass: TermSymbol =
@@ -1144,7 +1144,7 @@ class Definitions {
11441144

11451145
def isTupleType(tp: Type)(implicit ctx: Context): Boolean = {
11461146
val arity = tp.dealias.argInfos.length
1147-
arity <= MaxTupleArity && TupleType(arity) != null && (tp isRef TupleType(arity).symbol)
1147+
arity <= MaxTupleArity && TupleType(arity) != null && tp.isRef(TupleType(arity).symbol)
11481148
}
11491149

11501150
def tupleType(elems: List[Type]): Type = {

Diff for: compiler/src/dotty/tools/dotc/core/NullOpsDecorator.scala

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dotty.tools.dotc.core
22

33
import dotty.tools.dotc.core.Contexts.Context
44
import dotty.tools.dotc.core.Symbols.defn
5-
import dotty.tools.dotc.core.Types.{AndType, ClassInfo, ConstantType, OrType, Type, TypeBounds, TypeMap, TypeProxy}
5+
import dotty.tools.dotc.core.Types._
66

77
/** Defines operations on nullable types. */
88
object NullOpsDecorator {
@@ -18,8 +18,8 @@ object NullOpsDecorator {
1818
}
1919

2020
/** Syntactically strips the nullability from this type.
21-
* If the normalized form (as per `normNullableUnion`) of this type is `T1 | ... | Tn-1 | Tn`,
22-
* and `Tn` references to `Null` (or `JavaNull`), then return `T1 | ... | Tn-1`.
21+
* If the type is `T1 | ... | Tn`, and `Ti` references to `Null` (or `JavaNull`),
22+
* then return `T1 | ... | Ti-1 | Ti+1 | ... | Tn`.
2323
* If this type isn't (syntactically) nullable, then returns the type unchanged.
2424
*
2525
* @param onlyJavaNull whether we only remove `JavaNull`, the default value is false
@@ -40,7 +40,7 @@ object NullOpsDecorator {
4040
else tp.derivedOrType(llhs, rrhs)
4141
case tp @ AndType(tp1, tp2) =>
4242
// We cannot `tp.derivedAndType(strip(tp1), strip(tp2))` directly,
43-
// since `normNullableUnion((A | Null) & B)` would produce the wrong
43+
// since `stripNull((A | Null) & B)` would produce the wrong
4444
// result `(A & B) | Null`.
4545
val tp1s = strip(tp1)
4646
val tp2s = strip(tp2)
@@ -59,8 +59,8 @@ object NullOpsDecorator {
5959
def stripJavaNull(implicit ctx: Context): Type = self.stripNull(true)
6060

6161
/** Collapses all `JavaNull` unions within this type, and not just the outermost ones (as `stripJavaNull` does).
62-
* e.g. (Array[String|Null]|Null).stripNull => Array[String|Null]
63-
* (Array[String|Null]|Null).stripInnerNulls => Array[String]
62+
* e.g. (Array[String|JavaNull]|JavaNull).stripJavaNull => Array[String|JavaNull]
63+
* (Array[String|JavaNull]|JavaNull).stripAllJavaNull => Array[String]
6464
* If no `JavaNull` unions are found within the type, then returns the input type unchanged.
6565
*/
6666
def stripAllJavaNull(implicit ctx: Context): Type = {

0 commit comments

Comments
 (0)