Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak selection from self types #18467

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -854,9 +854,14 @@ object Types {
// is made to save execution time in the common case. See i9844.scala for test cases.
def qualifies(sd: SingleDenotation) =
!sd.symbol.is(Private) || sd.symbol.owner == tp.cls
d match
d.match
case d: SingleDenotation => if qualifies(d) then d else NoDenotation
case d => d.filterWithPredicate(qualifies)
.orElse:
// Only inaccessible private symbols were found. But there could still be
// shadowed non-private symbols, so as a fallback search for those.
// Test case is i18361.scala.
findMember(name, pre, required, excluded | Private)
else d
else
// There is a special case to handle:
Expand Down
15 changes: 15 additions & 0 deletions tests/pos/i18361.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package test1:
class Service(val name: String)
class CrudService(name: String) extends Service(name)

trait Foo { self: CrudService =>
val x = self.name
}

package test2:
abstract class Service[F[_]](val name: String)
abstract class CrudService[F[_]](name: String) extends Service[F](name)

trait Foo[F[_]] { self: CrudService[?] =>
val x = self.name
}