From 3159809c0bd6b745577d7c05f32954e2202e8467 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Tue, 4 Jul 2023 17:52:30 +0100 Subject: [PATCH] Fix finding an accessible non-private reference --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 ++ tests/pos/i18135.scala | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 tests/pos/i18135.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 51787cb5004a..deb4698431e2 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -289,6 +289,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer val pre = expr.tpe val denot0 = pre.memberBasedOnFlags(name, required, excluded) .accessibleFrom(pre)(using refctx) + .orElse(pre.memberBasedOnFlags(name, required, excluded | Private) + .accessibleFrom(pre)(using refctx)) // Pass refctx so that any errors are reported in the context of the // reference instead of the context of the import scope if denot0.exists then diff --git a/tests/pos/i18135.scala b/tests/pos/i18135.scala new file mode 100644 index 000000000000..c770585ba272 --- /dev/null +++ b/tests/pos/i18135.scala @@ -0,0 +1,9 @@ +class Ace +class Bar(last: Ace) { implicit val now: Ace = last } +class Foo(now: Ace) extends Bar(now) +class Test { +def test(fst: Foo) = { + import fst._ + now != null +} +}