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 +} +}