Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-8426

Private field in class cannot be accessed from companion object

    Details

    • Type: Bug
    • Status: CLOSED
    • Priority: Blocker
    • Resolution: Not a Bug
    • Affects Version/s: Scala 2.11.0-RC1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Environment:

      Scala version 2.11.0-RC1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_51), Gentoo Linux

      Description

      According to the announcement of 2.11.0-RC1, I report an issue I have with code that compiles file under 2.10.3 but does not compile under 2.11.0-RC1.

      The issue can be reduced to the following minimal case:

      Welcome to Scala version 2.10.3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_51).
      Type in expressions to have them evaluated.
      Type :help for more information.
       
      scala> :paste
      // Entering paste mode (ctrl-D to finish)
       
      object A extends A
      class A {
        private var a: Boolean = false 
        def run { A.a = true }
      }
       
      // Exiting paste mode, now interpreting.
       
      defined module A
      defined class A
       
      scala>
      

      The same code fails to compile with Scala 2.11.0-RC1

      Welcome to Scala version 2.11.0-RC1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_51).
      Type in expressions to have them evaluated.
      Type :help for more information.
       
      scala> :paste
      // Entering paste mode (ctrl-D to finish)
       
      object A extends A
      class A {
        private var a: Boolean = false 
        def run { A.a = true }
      }
       
      // Exiting paste mode, now interpreting.
       
      <console>:10: error: value a is not a member of object A
               def run { A.a = true }
                           ^
       
      scala>
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                retronym Jason Zaugg
                Reporter:
                lefou Tobias Roeser
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: