From da4d73290766193fcd6f11e65094639ff1104d48 Mon Sep 17 00:00:00 2001 From: noti0na1 <8036790+noti0na1@users.noreply.github.com> Date: Wed, 28 Feb 2024 15:42:48 +0000 Subject: [PATCH] Don't force to compute the owner of a symbol [Cherry-picked 784abfb829ae0a03462fabebf4b11a8845959efd] --- compiler/src/dotty/tools/dotc/typer/Nullables.scala | 2 +- tests/explicit-nulls/pos/i19808.scala | 6 ++++++ tests/pos/i19808.scala | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/explicit-nulls/pos/i19808.scala create mode 100644 tests/pos/i19808.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Nullables.scala b/compiler/src/dotty/tools/dotc/typer/Nullables.scala index 4c536abd0fcd..d47cfc0bf17e 100644 --- a/compiler/src/dotty/tools/dotc/typer/Nullables.scala +++ b/compiler/src/dotty/tools/dotc/typer/Nullables.scala @@ -262,7 +262,7 @@ object Nullables: */ def usedOutOfOrder(using Context): Boolean = val refSym = ref.symbol - val refOwner = refSym.owner + val refOwner = refSym.maybeOwner @tailrec def recur(s: Symbol): Boolean = s != NoSymbol diff --git a/tests/explicit-nulls/pos/i19808.scala b/tests/explicit-nulls/pos/i19808.scala new file mode 100644 index 000000000000..57937ecabb03 --- /dev/null +++ b/tests/explicit-nulls/pos/i19808.scala @@ -0,0 +1,6 @@ +import scala.reflect.Selectable.reflectiveSelectable + +def saveRedir(what: {def validate: List[String]}) = + what.validate match + case Nil => ??? + case xs => ??? diff --git a/tests/pos/i19808.scala b/tests/pos/i19808.scala new file mode 100644 index 000000000000..57937ecabb03 --- /dev/null +++ b/tests/pos/i19808.scala @@ -0,0 +1,6 @@ +import scala.reflect.Selectable.reflectiveSelectable + +def saveRedir(what: {def validate: List[String]}) = + what.validate match + case Nil => ??? + case xs => ???