Skip to content

Commit e5a96e7

Browse files
committed
Also consider private symbols in implicit scope of type
Fixes #14013
1 parent 097356d commit e5a96e7

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ object Implicits:
287287
}
288288

289289
override def isAccessible(ref: TermRef)(using Context): Boolean =
290-
ref.symbol.exists && !ref.symbol.is(Private)
290+
ref.symbol.exists
291291

292292
override def toString: String =
293293
i"OfTypeImplicits($tp), companions = ${companionRefs.showAsList}%, %; refs = $refs%, %."

tests/neg/i14013.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
object Foo1 {
2+
case class Bar(i: Int)
3+
4+
private implicit class BarOps(bar: Bar) {
5+
def twice = Bar(bar.i * 2)
6+
}
7+
}
8+
9+
class Foo {
10+
def bar = Foo.Bar(1).twice // error
11+
}
12+
13+
object App extends App {
14+
println((new Foo).bar)
15+
}

tests/pos/i14013.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
object Foo {
2+
case class Bar(i: Int)
3+
4+
private implicit class BarOps(bar: Bar) {
5+
def twice = Bar(bar.i * 2)
6+
}
7+
}
8+
9+
class Foo {
10+
def bar = Foo.Bar(1).twice
11+
}
12+
13+
object App extends App {
14+
println((new Foo).bar)
15+
}

0 commit comments

Comments
 (0)