File tree Expand file tree Collapse file tree 4 files changed +60
-3
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 4 files changed +60
-3
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import parsing.JavaParsers.JavaParser
2222import parsing .Parsers .Parser
2323import Annotations .*
2424import Inferencing .*
25+ import Nullables .*
2526import transform .ValueClasses .*
2627import TypeErasure .erasure
2728import reporting .*
@@ -784,8 +785,11 @@ class Namer { typer: Typer =>
784785
785786 protected def localContext (owner : Symbol ): FreshContext = ctx.fresh.setOwner(owner).setTree(original)
786787
788+ var myNotNullInfos : List [NotNullInfo ] | Null = null
789+
787790 /** The context with which this completer was created */
788- given creationContext : Context = ictx
791+ given creationContext [T ]: Context =
792+ if myNotNullInfos == null then ictx else ictx.withNotNullInfos(myNotNullInfos.nn)
789793
790794 // make sure testing contexts are not captured by completers
791795 assert(! ictx.reporter.isInstanceOf [ExploringReporter ])
Original file line number Diff line number Diff line change @@ -3365,8 +3365,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
33653365 // The RHS of a val def should know about not null facts established
33663366 // in preceding statements (unless the DefTree is completed ahead of time,
33673367 // then it is impossible).
3368- sym.info = Completer (completer.original)(
3369- completer.creationContext.withNotNullInfos(ctx.notNullInfos))
3368+ completer.myNotNullInfos = ctx.notNullInfos
33703369 true
33713370 case _ =>
33723371 // If it has been completed, then it must be because there is a forward reference
Original file line number Diff line number Diff line change 1+ class Test {
2+ def test1 (s : String | Null ): Unit = {
3+ if s == null then return
4+
5+ case class XXX ()
6+ }
7+
8+ def test2 (s : String | Null ): Unit = {
9+ if s == " " then return
10+
11+ case class XXX ()
12+ }
13+
14+ def test3 (s : String | Null ): Unit = {
15+ if s == null then return
16+
17+ case class XXX ()
18+ ()
19+ }
20+
21+ def test4 (s : String | Null ): String | Null = {
22+ if s == null then return " "
23+
24+ case class XXX ()
25+ " xxx"
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ class Test {
2+ def test1 (s : String ): Unit = {
3+ if s == null then return
4+
5+ case class XXX ()
6+ }
7+
8+ def test2 (s : String ): Unit = {
9+ if s == " " then return
10+
11+ case class XXX ()
12+ }
13+
14+ def test3 (s : String ): Unit = {
15+ if s == null then return
16+
17+ case class XXX ()
18+ ()
19+ }
20+
21+ def test4 (s : String ): String = {
22+ if s == null then return " "
23+
24+ case class XXX ()
25+ " xxx"
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments