Skip to content

Commit

Permalink
fix #412 and fix #425
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Jul 15, 2018
1 parent 99e8f6e commit d9a206f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/scala/wartremover/WartTraverser.scala
Expand Up @@ -91,7 +91,7 @@ trait WartTraverser {
}

def isPublic(u: WartUniverse)(t: u.universe.ValOrDefDef): Boolean = {
hasAccess(u)(t, _.isPublic)
hasAccess(u)(t, s => s.isPublic && (s != u.universe.NoSymbol))
}

def isPrivate(u: WartUniverse)(t: u.universe.ValOrDefDef): Boolean = {
Expand Down
20 changes: 20 additions & 0 deletions core/src/test/scala/wartremover/warts/PublicInferenceTest.scala
Expand Up @@ -5,6 +5,26 @@ import org.scalatest.FunSuite
import org.wartremover.warts.PublicInference

class PublicInferenceTest extends FunSuite with ResultAssertions {
test("Non-public fields and methods are allowed") {
case class X(i: Int)
val result = WartTestTraverser(PublicInference) {
class Y {
private[this] val a1 = X(2)
private val a2 = X(2)
protected[this] val a3 = X(2)
protected val a4 = X(2)
private[test] val a5 = X(2)

private[this] def b1 = X(2)
private def b2 = X(2)
protected[this] def b3 = X(2)
protected def b4 = X(2)
private[test] def b5 = X(2)
}
}
assertEmpty(result)
}

test("Public members without type ascription are disabled") {
val result = WartTestTraverser(PublicInference) {
class c {
Expand Down

0 comments on commit d9a206f

Please sign in to comment.