Permalink
Browse files

Fixed SI-5708. Correctly compute accessibility for object members.

  • Loading branch information...
dragos committed May 10, 2012
1 parent 391524d commit 9d1bc68b78a76a18777a859816bcb1c7f81bf2dd
@@ -930,7 +930,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
val implicitlyAdded = viaView != NoSymbol
members.add(sym, pre, implicitlyAdded) { (s, st) =>
new TypeMember(s, st,
- context.isAccessible(s, pre, superAccess && !implicitlyAdded),
+ context.isAccessible(if (s.hasGetter) s.getter(s.owner) else s, pre, superAccess && !implicitlyAdded),
inherited,
viaView)
}
@@ -0,0 +1,47 @@
+reload: Completions.scala
+
+askTypeCompletion at Completions.scala(17,9)
+================================================================================
+[response] aksTypeCompletion at (17,9)
+retrieved 44 members
+[accessible: true] `lazy value fooInt`
+[accessible: true] `method !=(x$1: Any)Boolean`
+[accessible: true] `method !=(x$1: AnyRef)Boolean`
+[accessible: true] `method ##()Int`
+[accessible: true] `method +(other: String)String`
+[accessible: true] `method ->[B](y: B)(test.Compat.type, B)`
+[accessible: true] `method ==(x$1: Any)Boolean`
+[accessible: true] `method ==(x$1: AnyRef)Boolean`
+[accessible: true] `method asInstanceOf[T0]=> T0`
+[accessible: true] `method ensuring(cond: Boolean)test.Compat.type`
+[accessible: true] `method ensuring(cond: Boolean, msg: => Any)test.Compat.type`
+[accessible: true] `method ensuring(cond: test.Compat.type => Boolean)test.Compat.type`
+[accessible: true] `method ensuring(cond: test.Compat.type => Boolean, msg: => Any)test.Compat.type`
+[accessible: true] `method eq(x$1: AnyRef)Boolean`
+[accessible: true] `method equals(x$1: Any)Boolean`
+[accessible: true] `method formatted(fmtstr: String)String`
+[accessible: true] `method hashCode()Int`
+[accessible: true] `method isInstanceOf[T0]=> Boolean`
+[accessible: true] `method ne(x$1: AnyRef)Boolean`
+[accessible: true] `method notify()Unit`
+[accessible: true] `method notifyAll()Unit`
+[accessible: true] `method pkgPrivateM=> String`
+[accessible: true] `method synchronized[T0](x$1: T0)T0`
+[accessible: true] `method toString()String`
+[accessible: true] `method wait()Unit`
+[accessible: true] `method wait(x$1: Long)Unit`
+[accessible: true] `method wait(x$1: Long, x$2: Int)Unit`
+[accessible: true] `method x=> test.Compat.type`
+[accessible: true] `method →[B](y: B)(test.Compat.type, B)`
+[accessible: true] `value CONST_STRINGString("constant")`
+[accessible: true] `value __leftOfArrowtest.Compat.type`
+[accessible: true] `value __resultOfEnsuringtest.Compat.type`
+[accessible: true] `value pkgPrivateVString`
+[accessible: true] `value selfAny`
+[accessible: false] `method clone()Object`
+[accessible: false] `method finalize()Unit`
+[accessible: false] `method privateM=> String`
+[accessible: false] `method protectedValM=> String`
+[accessible: false] `value privateVString`
+[accessible: false] `value protectedVString`
+================================================================================
@@ -0,0 +1,18 @@
+package test
+
+object Compat {
+ final val CONST_STRING = "constant"
+ lazy val foo = 4
+
+ private val privateV = ""
+ private[test] val pkgPrivateV = ""
+ protected val protectedV = ""
+
+ private def privateM = ""
+ private[test] def pkgPrivateM = ""
+ protected def protectedValM = ""
+}
+
+class Foo {
+ Compat./*!*/CONST_STRING // its 'accessible' flag is false
+}
@@ -1,81 +0,0 @@
-reload: Completions.scala
-
-askTypeCompletion at Completions.scala(9,9)
-================================================================================
-[response] aksTypeCompletion at (9,9)
-retrieved 38 members
-[accessible: true] `method !=(x$1: Any)Boolean`
-[accessible: true] `method !=(x$1: AnyRef)Boolean`
-[accessible: true] `method ##()Int`
-[accessible: true] `method +(other: String)String`
-[accessible: true] `method ->[B](y: B)(test.Compat.type, B)`
-[accessible: true] `method ==(x$1: Any)Boolean`
-[accessible: true] `method ==(x$1: AnyRef)Boolean`
-[accessible: true] `method asInstanceOf[T0]=> T0`
-[accessible: true] `method ensuring(cond: Boolean)test.Compat.type`
-[accessible: true] `method ensuring(cond: Boolean, msg: => Any)test.Compat.type`
-[accessible: true] `method ensuring(cond: test.Compat.type => Boolean)test.Compat.type`
-[accessible: true] `method ensuring(cond: test.Compat.type => Boolean, msg: => Any)test.Compat.type`
-[accessible: true] `method eq(x$1: AnyRef)Boolean`
-[accessible: true] `method equals(x$1: Any)Boolean`
-[accessible: true] `method formatted(fmtstr: String)String`
-[accessible: true] `method hashCode()Int`
-[accessible: true] `method isInstanceOf[T0]=> Boolean`
-[accessible: true] `method ne(x$1: AnyRef)Boolean`
-[accessible: true] `method notify()Unit`
-[accessible: true] `method notifyAll()Unit`
-[accessible: true] `method synchronized[T0](x$1: T0)T0`
-[accessible: true] `method toString()String`
-[accessible: true] `method wait()Unit`
-[accessible: true] `method wait(x$1: Long)Unit`
-[accessible: true] `method wait(x$1: Long, x$2: Int)Unit`
-[accessible: true] `method x=> test.Compat.type`
-[accessible: true] `method →[B](y: B)(test.Compat.type, B)`
-[accessible: true] `lazy value fooInt`
-[accessible: false] `method clone()Object`
-[accessible: false] `method finalize()Unit`
-[accessible: true] `value CONST_STRINGString("constant")`
-[accessible: false] `value __leftOfArrowtest.Compat.type`
-[accessible: false] `value __resultOfEnsuringtest.Compat.type`
-[accessible: false] `value selfAny`
-================================================================================
-
-askTypeCompletion at Completions.scala(10,9)
-================================================================================
-[response] aksTypeCompletion at (10,9)
-retrieved 38 members
-[accessible: true] `method !=(x$1: Any)Boolean`
-[accessible: true] `method !=(x$1: AnyRef)Boolean`
-[accessible: true] `method ##()Int`
-[accessible: true] `method +(other: String)String`
-[accessible: true] `method ->[B](y: B)(test.Compat.type, B)`
-[accessible: true] `method ==(x$1: Any)Boolean`
-[accessible: true] `method ==(x$1: AnyRef)Boolean`
-[accessible: true] `method asInstanceOf[T0]=> T0`
-[accessible: true] `method ensuring(cond: Boolean)test.Compat.type`
-[accessible: true] `method ensuring(cond: Boolean, msg: => Any)test.Compat.type`
-[accessible: true] `method ensuring(cond: test.Compat.type => Boolean)test.Compat.type`
-[accessible: true] `method ensuring(cond: test.Compat.type => Boolean, msg: => Any)test.Compat.type`
-[accessible: true] `method eq(x$1: AnyRef)Boolean`
-[accessible: true] `method equals(x$1: Any)Boolean`
-[accessible: true] `method formatted(fmtstr: String)String`
-[accessible: true] `method hashCode()Int`
-[accessible: true] `method isInstanceOf[T0]=> Boolean`
-[accessible: true] `method ne(x$1: AnyRef)Boolean`
-[accessible: true] `method notify()Unit`
-[accessible: true] `method notifyAll()Unit`
-[accessible: true] `method synchronized[T0](x$1: T0)T0`
-[accessible: true] `method toString()String`
-[accessible: true] `method wait()Unit`
-[accessible: true] `method wait(x$1: Long)Unit`
-[accessible: true] `method wait(x$1: Long, x$2: Int)Unit`
-[accessible: true] `method x=> test.Compat.type`
-[accessible: true] `method →[B](y: B)(test.Compat.type, B)`
-[accessible: true] `lazy value fooInt`
-[accessible: false] `method clone()Object`
-[accessible: false] `method finalize()Unit`
-[accessible: true] `value CONST_STRINGString("constant")`
-[accessible: false] `value __leftOfArrowtest.Compat.type`
-[accessible: false] `value __resultOfEnsuringtest.Compat.type`
-[accessible: false] `value selfAny`
-================================================================================
@@ -1,11 +0,0 @@
-package test
-
-object Compat {
- final val CONST_STRING = "constant"
- lazy val foo = 4
-}
-
-class Foo {
- Compat./*!*/CONST_STRING // its 'accessible' flag is false
- Compat./*!*/foo // its 'accessible' flag is false
-}

0 comments on commit 9d1bc68

Please sign in to comment.