Read only property fail the null check


#1

public data class Feed(public val rss : Rss?, public val atom : Rss?){   public var title : String = ""   public var language : String = ""   public var feedType : FeedType = FeedType.NONE   public var items : ArrayList<Item> = ArrayList<Item>()

  fun transformRss()
  {
  if (rss != null){
           title = if (rss.channel!!.title == null) “” else rss.channel!!.title!!
           language = if (rss.channel!!.language == null) “” else rss.channel!!.language!!
           feedType = FeedType.RSS

           for(val i in rss.channel!!.item!!.iterator()){
           }
  }
  }

generates compilation error although I did check rss != null inside transformRss. The compiler insists that I do ensure on rss!! property.

Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type com.silverkeytech.android_rivers.syndications.rss.Rss?

Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type com.silverkeytech.android_rivers.syndications.rss.Rss?

Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type com.silverkeytech.android_rivers.syndications.rss.Rss?

Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type com.silverkeytech.android_rivers.syndications.rss.Rss?


#2

This is not exactly a bug, but this can be improved. The problem is that the properties are public. The special case here is that we are in the same class (and thus the same module), so them being public doesn't make them potentially changable.


#3

Feel free to file an issue