Skip to content

Fix #1531: Ignore private members when looking for abstract ones #1596

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

Merged
merged 1 commit into from
Oct 14, 2016
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
8 changes: 4 additions & 4 deletions src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,13 @@ object Types {
/** The set of abstract term members of this type. */
final def abstractTermMembers(implicit ctx: Context): Seq[SingleDenotation] = track("abstractTermMembers") {
memberDenots(abstractTermNameFilter,
(name, buf) => buf ++= member(name).altsWith(_ is Deferred))
(name, buf) => buf ++= nonPrivateMember(name).altsWith(_ is Deferred))
}

/** The set of abstract type members of this type. */
final def abstractTypeMembers(implicit ctx: Context): Seq[SingleDenotation] = track("abstractTypeMembers") {
memberDenots(abstractTypeNameFilter,
(name, buf) => buf += member(name).asSingleDenotation)
(name, buf) => buf += nonPrivateMember(name).asSingleDenotation)
}

/** The set of abstract type members of this type. */
Expand Down Expand Up @@ -3756,7 +3756,7 @@ object Types {
object abstractTypeNameFilter extends NameFilter {
def apply(pre: Type, name: Name)(implicit ctx: Context): Boolean =
name.isTypeName && {
val mbr = pre.member(name)
val mbr = pre.nonPrivateMember(name)
(mbr.symbol is Deferred) && mbr.info.isInstanceOf[RealTypeBounds]
}
}
Expand All @@ -3773,7 +3773,7 @@ object Types {
/** A filter for names of deferred term definitions of a given type */
object abstractTermNameFilter extends NameFilter {
def apply(pre: Type, name: Name)(implicit ctx: Context): Boolean =
name.isTermName && (pre member name).hasAltWith(_.symbol is Deferred)
name.isTermName && pre.nonPrivateMember(name).hasAltWith(_.symbol is Deferred)
}

object typeNameFilter extends NameFilter {
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ object RefChecks {
// abstract method, and a cursory examination of the difference reveals
// something obvious to us, let's make it more obvious to them.
val abstractParams = underlying.info.firstParamTypes
val matchingName = clazz.info.member(underlying.name).alternatives
val matchingName = clazz.info.nonPrivateMember(underlying.name).alternatives
val matchingArity = matchingName filter { m =>
!m.symbol.is(Deferred) &&
m.info.firstParamTypes.length == abstractParams.length
Expand Down
6 changes: 6 additions & 0 deletions tests/neg/i1531.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
trait T {
def f: Int
}

class A(f: Int) extends T // error: class A needs to be abstract