Skip to content

Commit 076091f

Browse files
committed
Polishings
1 parent 7b5e964 commit 076091f

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package ast
44

55
import core._
66
import Flags._, Trees._, Types._, Contexts._
7-
import Names._, StdNames._, NameOps._, Symbols._, Constants._
7+
import Names._, StdNames._, NameOps._, Symbols._
88
import typer.ConstFold
99
import reporting.trace
1010
import dotty.tools.dotc.transform.SymUtils._

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ trait Applications extends Compatibility {
867867
else
868868
new ApplyToUntyped(tree, fun1, funRef, proto, pt)(
869869
fun1.nullableInArgContext(given argCtx(tree)))
870-
convertNewGenericArray(app.result).computeNullable
870+
convertNewGenericArray(app.result).computeNullable()
871871
case _ =>
872872
handleUnexpectedFunType(tree, fun1)
873873
}

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,15 +1066,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
10661066
| its condition ${tree.cond}
10671067
| is not a constant value""")
10681068
else
1069-
// Recompute nullablity info. This is needed because inlined code could have come
1070-
// from Tasty where no nullability info is kept.
1071-
val addNullable = new TreeTraverser {
1072-
def traverse(tree: Tree)(implicit ctx: Context) =
1073-
traverseChildren(tree)
1074-
tree.computeNullable
1075-
}
1076-
addNullable.traverse(cond1)
1077-
1069+
cond1.computeNullableDeeply()
10781070
val if1 = untpd.cpy.If(tree)(cond = untpd.TypedSplice(cond1))
10791071
super.typedIf(if1, pt)
10801072
}

compiler/src/dotty/tools/dotc/typer/Nullables.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ object Nullables with
140140
* a path (i.e. a stable TermRef)
141141
* 2. Boolean &&, ||, !
142142
*/
143-
def computeNullable(given Context): tree.type =
143+
def computeNullable()(given Context): tree.type =
144144
def setExcluded(ifTrue: Excluded, ifFalse: Excluded) =
145145
tree.putAttachment(CondExcluded, EitherExcluded(ifTrue, ifFalse))
146146
if !curCtx.erasedTypes then tree match
@@ -161,4 +161,13 @@ object Nullables with
161161
setExcluded(xc.ifFalse, xc.ifTrue)
162162
case _ =>
163163
tree
164+
165+
/** Compute nullability information for this tree and all its subtrees */
166+
def computeNullableDeeply()(given Context): Unit =
167+
new TreeTraverser {
168+
def traverse(tree: Tree)(implicit ctx: Context) =
169+
traverseChildren(tree)
170+
tree.computeNullable()
171+
}.traverse(tree)
172+
164173
end Nullables

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ class Typer extends Namer
452452

453453
def typeSelectOnTerm(implicit ctx: Context): Tree =
454454
typedSelect(tree, pt, typedExpr(tree.qualifier, selectionProto(tree.name, pt, this)))
455-
.computeNullable
455+
.computeNullable()
456456

457457
def typeSelectOnType(qual: untpd.Tree)(implicit ctx: Context) =
458458
typedSelect(untpd.cpy.Select(tree)(qual, tree.name.toTypeName), pt)

0 commit comments

Comments
 (0)