diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2016-10-14 19:44:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-14 19:44:43 +0200 |
commit | bac4eecd27d113294a6531bbc272c96dfae86f57 (patch) | |
tree | 8c952bc89c8ce156c488a54c1f8d6ec1020f2299 | |
parent | 148551ae5598542c023514b104160a528767e290 (diff) | |
parent | bcd3c1f6e26f814a2f69d7e44f165b59b1db0fe3 (diff) | |
download | dotty-bac4eecd27d113294a6531bbc272c96dfae86f57.tar.gz dotty-bac4eecd27d113294a6531bbc272c96dfae86f57.tar.bz2 dotty-bac4eecd27d113294a6531bbc272c96dfae86f57.zip |
Merge pull request #1596 from dotty-staging/fix-#1531
Fix #1531: Ignore private members when looking for abstract ones
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 8 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/RefChecks.scala | 2 | ||||
-rw-r--r-- | tests/neg/i1531.scala | 6 |
3 files changed, 11 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 1212cdd81..38913a7d0 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -620,13 +620,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. */ @@ -3763,7 +3763,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] } } @@ -3780,7 +3780,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 { diff --git a/src/dotty/tools/dotc/typer/RefChecks.scala b/src/dotty/tools/dotc/typer/RefChecks.scala index 4d82a2d12..834bb37a8 100644 --- a/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/src/dotty/tools/dotc/typer/RefChecks.scala @@ -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 diff --git a/tests/neg/i1531.scala b/tests/neg/i1531.scala new file mode 100644 index 000000000..3c05e9509 --- /dev/null +++ b/tests/neg/i1531.scala @@ -0,0 +1,6 @@ +trait T { + def f: Int +} + +class A(f: Int) extends T // error: class A needs to be abstract + |