title: Smart cast to 'ArrayList<Object>' is impossible in Kotlin
body: <p>I have some classes and I have converted them from <em>Java</em> to <em>Kotlin</em>.</p>
  
  <p>This is the <em>Kotlin</em> method:</p>
  
  <pre><code>private var allCountriesList: List&lt;Country&gt;? = null
  
          val allCountries: List&lt;Country&gt;
              get() {
  
                  val locales = Locale.getISOCountries()
                  val countries = ArrayList&lt;Country&gt;()
  
                  for (countryCode in locales) {
  
                      val obj = Locale("", countryCode)
                      Log.i("AMIRA2020", obj.country + " / " + obj.displayName)
                      if (obj.country == "SP" == false &amp;&amp; obj.country == "ZG" == false)
                          countries.add(Country(obj.country, obj.displayName, -1))
                  }
  
                  Collections.sort(countries) { o1, o2 -&gt; o1.name!!.compareTo(o2.name!!) }
  
                  allCountriesList = countries
  
                  return allCountriesList
              }
  </code></pre>
  
  <p>I am getting an error in the <code>return</code> statement that the smart case is impossible.</p>
  
  <p>Can anyone help please ?</p>