title: Kotlin Companion Object is null when referenced
body: <p>Not sure if I am using this companion object properly.</p>
  
  <p>Data class:</p>
  
  <pre><code>data class AppModel(
      val name: String,
      val items: List&lt;ItemModel&gt;,
  )
  </code></pre>
  
  <p>Set the data:</p>
  
  <pre><code>open class PathManager() {
  
      companion object {
          var shared = PathManager()    // SHARED OBJECT IN QUESTION
      }
  
      var app: AppModel? = null
  
      fun setUp() {
          // Show loading...
  
          // Parse the JSON
          val gson = GsonBuilder().create()
          val text = mainActivity.resources.openRawResource(R.raw.jsonFile)  
              .bufferedReader().use { it.readText() }
          val appModel = gson.fromJson(text, AppModel::class.java)
  
          app = appModel
  
          performInitialPath()
      } 
  
      private fun performInitialPath() {
  
          val app = app?.let { it } ?: error("Attempted to start without an App Config.")
  
          this.app = app    // DEBUGGER SHOWS CORRECT VALUES HERE
  
          // Removed irrelevant code for readability, builds 'initialFoo' here
  
          this.mainActivity.addFragment(initialFoo)
      }
  }
  </code></pre>
  
  <p>Fragment Builder Class (looks for Path Manager companion object here):</p>
  
  <pre><code>class Frag : Fragment() {
  
      override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
  
          var itemModels: List&lt;ItemModel&gt;? = null
  
          if(PathManager.shared.app?.items != null) {  // NULL - WHY?
              itemModels = PathManager.shared.app?.items  
          }
     }
  }
  </code></pre>
  
  <p>To sum up what happens:</p>
  
  <ol>
  <li><p>AppModel is built properly in PathManager(). The data IS there (can
  see in debugger)   </p></li>
  <li><p>Path Manager launches 'Frag()' class</p></li>
  <li><p>Frag() class references back to the companion object created in
  PathManager(), attempting to find data in
  'PathManager.shared.app?.items', but the data in there is null, when
  it should not be.  Isn't a companion object the same as a Static
  variable?</p></li>
  </ol>
  
  <p>I am certain I'm missing something, just looking for advice.  Am I calling the companion object correctly?  Can I not reference it from a new class like this?  What gives?</p>