Skip to content

Commit 9659eb9

Browse files
authored
Backport " Tweak selection from self types" (#18475)
Backports #18467
2 parents 5f8485e + 88e6725 commit 9659eb9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,9 +808,14 @@ object Types {
808808
// is made to save execution time in the common case. See i9844.scala for test cases.
809809
def qualifies(sd: SingleDenotation) =
810810
!sd.symbol.is(Private) || sd.symbol.owner == tp.cls
811-
d match
811+
d.match
812812
case d: SingleDenotation => if qualifies(d) then d else NoDenotation
813813
case d => d.filterWithPredicate(qualifies)
814+
.orElse:
815+
// Only inaccessible private symbols were found. But there could still be
816+
// shadowed non-private symbols, so as a fallback search for those.
817+
// Test case is i18361.scala.
818+
findMember(name, pre, required, excluded | Private)
814819
else d
815820
else
816821
// There is a special case to handle:

tests/pos/i18361.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package test1:
2+
class Service(val name: String)
3+
class CrudService(name: String) extends Service(name)
4+
5+
trait Foo { self: CrudService =>
6+
val x = self.name
7+
}
8+
9+
package test2:
10+
abstract class Service[F[_]](val name: String)
11+
abstract class CrudService[F[_]](name: String) extends Service[F](name)
12+
13+
trait Foo[F[_]] { self: CrudService[?] =>
14+
val x = self.name
15+
}

0 commit comments

Comments
 (0)