title: Type mismatch in ArrayOfNulls with Kotlin
body: <p>I got a problem when converting my java code to kotlin.</p>
  
  <p>This line of code is what making me the problem</p>
  
  <pre><code> dots = arrayOfNulls&lt;TextView&gt;(layouts.size)
  </code></pre>
  
  <p>it said:</p>
  
  <blockquote>
    <p>Type mismatch. Required: Array(TextView)? - Found: Array(TextView?)</p>
  </blockquote>
  
  <p>Let you here the whole code and hope you can give me hand to figure out what's wrong.</p>
  
  <pre><code>class WelcomeActivity : AppCompatActivity() {
  
  private var viewPager: ViewPager? = null
  private var myViewPagerAdapter: MyViewPagerAdapter? = null
  private var dotsLayout: LinearLayout? = null
  private var dots: Array&lt;TextView&gt;? = null
  private var layouts: IntArray? = null
  private var btnSkip: Button? = null
  private var btnNext: Button? = null
  private var prefManager: PrefManager? = null
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
  
      // Checking for first time launch - before calling setContentView()
      prefManager = PrefManager(this)
      if (!prefManager!!.isFirstTimeLaunch) {
          launchHomeScreen()
          finish()
      }
  
      // Making notification bar transparent
      if (Build.VERSION.SDK_INT &gt;= 21) {
          window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
      }
  
      setContentView(R.layout.welcomescreen)
  
      viewPager = findViewById(R.id.view_pager) as ViewPager
      dotsLayout = findViewById(R.id.layoutDots) as LinearLayout
      btnSkip = findViewById(R.id.btn_skip) as Button
      btnNext = findViewById(R.id.btn_next) as Button
  
  
      // layouts of all welcome sliders
      // add few more layouts if you want
      layouts = intArrayOf(R.layout.welcomescreen_slide1, R.layout.welcomescreen_slide2, R.layout.welcomescreen_slide3, R.layout.welcomescreen_slide4)
  
      // adding bottom dots
      addBottomDots(0)
  
      // making notification bar transparent
      changeStatusBarColor()
  
      myViewPagerAdapter = MyViewPagerAdapter()
      viewPager!!.adapter = myViewPagerAdapter
      viewPager!!.addOnPageChangeListener(viewPagerPageChangeListener)
  
      btnSkip!!.setOnClickListener { launchHomeScreen() }
  
      btnNext!!.setOnClickListener {
          // checking for last page
          // if last page home screen will be launched
          val current = getItem(+1)
          if (current &lt; layouts!!.size) {
              // move to next screen
              viewPager!!.currentItem = current
          } else {
              launchHomeScreen()
          }
      }
  }
  
  private fun addBottomDots(currentPage: Int) {
      dots = arrayOfNulls&lt;TextView&gt;(layouts.size)
  
      val colorsActive = resources.getIntArray(R.array.array_dot_active)
      val colorsInactive = resources.getIntArray(R.array.array_dot_inactive)
  
      dotsLayout!!.removeAllViews()
      for (i in dots!!.indices) {
          dots[i] = TextView(this)
          dots!![i].text = Html.fromHtml("&amp;#8226;")
          dots!![i].textSize = 35f
          dots!![i].setTextColor(colorsInactive[currentPage])
          dotsLayout!!.addView(dots!![i])
      }
  
      if (dots!!.size &gt; 0)
          dots!![currentPage].setTextColor(colorsActive[currentPage])
  }
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <p>[EDIT]: Also, I noticed an error in a for statement, here:</p>
  
  <pre><code>for (i in dots!!.indices) {
          dots[i] = TextView(this)
          dots!![i].text = Html.fromHtml("&amp;#8226;")
          dots!![i].textSize = 35f
          dots!![i].setTextColor(colorsInactive[currentPage])
          dotsLayout!!.addView(dots!![i])
      }
  </code></pre>
  
  <p>First, in the first line said <strong>Unresolve reference indices</strong>; then in second line say that dots[i] cannot smart cast to 'Array?' because it's a mutable property and finally in the lines behind every dot before dots!![i] says "Only safe (?) or not-null asserted (!!.) calls are allowed on a nullable receiver of type TextView?</p>