We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f351ec4 commit 74f6851Copy full SHA for 74f6851
compiler/src/dotty/tools/dotc/typer/Nullables.scala
@@ -445,7 +445,7 @@ object Nullables:
445
else candidates -= name
446
case None =>
447
traverseChildren(tree)
448
- case _: (If | WhileDo | Typed | Match | CaseDef) =>
+ case _: (If | WhileDo | Typed | Match | CaseDef | untpd.ParsedTry) =>
449
traverseChildren(tree) // assignments to candidate variables are OK here ...
450
case _ =>
451
reachable = Set.empty // ... but not here
tests/explicit-nulls/pos/match-flow-typing.scala
@@ -6,3 +6,16 @@ def m(): String = {
6
if(x == null) "foo"
7
else x
8
}
9
+
10
+def m2(): String = {
11
+ var x: String|Null = "foo"
12
+ try {
13
+ x = x
14
+ } catch {
15
+ case e => x = x
16
+ } finally {
17
18
+ }
19
+ if(x == null) "foo"
20
+ else x
21
+}
0 commit comments