From 7c06c9d7f6a12c2b13c83b195fffa30c5a4ec3ce Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 27 Jan 2014 15:19:07 +0300 Subject: SI-6733 LOCAL, isLocal, and private[this] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due to an unfortunate name collision, internal.Symbols#Symbol.isLocal means something different from Flag.LOCAL. Therefore api.Symbols#Symbol.isLocal was directly violating its documentation. Since we can’t give api#isLocal an implementation different from internal#isLocal, we have to rename, and for that occasion I have come up with names api#isPrivateThis and api#isProtectedThis, which in my opinion suits the public API better than internal#isPrivateLocal and internal#isProtectedLocal. Given the extraordinary circumstances of having no way for api#isLocal to work correctly, I’m forced to remove api#isLocal without a deprecation notice, exercising our right to break experimental APIs, something that we have never done before for reflection or macros. This is sad. --- test/files/run/t6733.check | 27 +++++++++++++++++++++++++++ test/files/run/t6733.scala | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 test/files/run/t6733.check create mode 100644 test/files/run/t6733.scala (limited to 'test') diff --git a/test/files/run/t6733.check b/test/files/run/t6733.check new file mode 100644 index 0000000000..aeb595fbfd --- /dev/null +++ b/test/files/run/t6733.check @@ -0,0 +1,27 @@ +method $init$: isPrivateThis = false, isProtectedThis = false +value pri1a: isPrivateThis = true, isProtectedThis = false +method pri2a: isPrivateThis = true, isProtectedThis = false +variable pri3a: isPrivateThis = true, isProtectedThis = false +value pri4a: isPrivateThis = true, isProtectedThis = false +lazy value pri4a: isPrivateThis = true, isProtectedThis = false +type Pri5a: isPrivateThis = true, isProtectedThis = false +class Pri6: isPrivateThis = true, isProtectedThis = false +trait Pri7: isPrivateThis = true, isProtectedThis = false +object Pri8: isPrivateThis = true, isProtectedThis = false +value pro1a: isPrivateThis = false, isProtectedThis = true +value pro1a: isPrivateThis = true, isProtectedThis = false +value pro1b: isPrivateThis = false, isProtectedThis = true +method pro2a: isPrivateThis = false, isProtectedThis = true +method pro2b: isPrivateThis = false, isProtectedThis = true +method pro3a: isPrivateThis = false, isProtectedThis = true +method pro3a_=: isPrivateThis = false, isProtectedThis = true +variable pro3a: isPrivateThis = true, isProtectedThis = false +method pro3b: isPrivateThis = false, isProtectedThis = true +method pro3b_=: isPrivateThis = false, isProtectedThis = true +value pro4a: isPrivateThis = false, isProtectedThis = true +lazy value pro4a: isPrivateThis = true, isProtectedThis = false +type Pro5a: isPrivateThis = false, isProtectedThis = true +type Pro5b: isPrivateThis = false, isProtectedThis = true +class Pro6: isPrivateThis = false, isProtectedThis = true +trait Pro7: isPrivateThis = false, isProtectedThis = true +object Pro8: isPrivateThis = false, isProtectedThis = true diff --git a/test/files/run/t6733.scala b/test/files/run/t6733.scala new file mode 100644 index 0000000000..525b276811 --- /dev/null +++ b/test/files/run/t6733.scala @@ -0,0 +1,35 @@ +import scala.reflect.runtime.universe._ + +trait Foo { + private[this] val pri1a = 0 + // private[this] val pri1b: Int + private[this] def pri2a = 1 + // private[this] def pri2b: Int + private[this] var pri3a = 0 + // private[this] var pri3b: Int + private[this] lazy val pri4a = 0 + // private[this] lazy val pri4b: Int + private[this] type Pri5a = Int + // private[this] type Pri5b <: Int + private[this] class Pri6 + private[this] trait Pri7 + private[this] object Pri8 + + protected[this] val pro1a = 0 + protected[this] val pro1b: Int + protected[this] def pro2a = 1 + protected[this] def pro2b: Int + protected[this] var pro3a = 0 + protected[this] var pro3b: Int + protected[this] lazy val pro4a = 0 + // protected[this] lazy val pro4b: Int + protected[this] type Pro5a = Int + protected[this] type Pro5b <: Int + protected[this] class Pro6 + protected[this] trait Pro7 + protected[this] object Pro8 +} + +object Test extends App { + typeOf[Foo].declarations.sorted.foreach(m => println(s"$m: isPrivateThis = ${m.isPrivateThis}, isProtectedThis = ${m.isProtectedThis}")) +} \ No newline at end of file -- cgit v1.2.3