Skip to content

Commit

Permalink
Merge pull request #15186 from dotty-staging/remove-special-eq-in-uns…
Browse files Browse the repository at this point in the history
…afe-nulls

Remove special eq/ne in unsafeNulls
  • Loading branch information
olhotak authored May 14, 2022
2 parents be65db4 + 0cf96cc commit bb29e20
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -643,19 +643,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer

def typeSelectOnTerm(using Context): Tree =
val qual = typedExpr(tree.qualifier, shallowSelectionProto(tree.name, pt, this))
val qual1 = if Nullables.unsafeNullsEnabled then
qual.tpe match {
case OrNull(tpe1) if tpe1 <:< defn.ObjectType =>
qual.cast(AndType(qual.tpe, tpe1))
case tp =>
if tp.isNullType
&& (tree.name == nme.eq || tree.name == nme.ne) then
// Allow selecting `eq` and `ne` on `Null` specially
qual.cast(defn.ObjectType)
else qual
}
else qual
typedSelect(tree, pt, qual1).withSpan(tree.span).computeNullable()
typedSelect(tree, pt, qual).withSpan(tree.span).computeNullable()

def javaSelectOnType(qual: Tree)(using Context) =
// semantic name conversion for `O$` in java code
Expand Down

0 comments on commit bb29e20

Please sign in to comment.