title: 'when' expression must be exhaustive error when using adapters
body: <p>I would like to do something like this:</p>
  
  <pre><code>class MyPagerAdapter : PagerAdapter() {
      override fun getItem(position: Int) = when(position) {
          0 -&gt; Fragment0()
          1 -&gt; Fragment1()
      }
  
      override fun getCount() = 2
  }
  </code></pre>
  
  <p>I am sure that the adapter contains only 2 items, so <code>getCount()</code> simply returns 2. But it shows an error message said that <code>'when' expression must be exhaustive, add necessary 'else' branch</code>. I understand that I can add an <code>else</code> to solve it, but it's really ugly to write code like:</p>
  
  <pre><code>    when(position) {
          0 -&gt; Fragment0()
          1 -&gt; Fragment1()
          else -&gt; Fragment()    // Impossible to get here
      }
  </code></pre>
  
  <p>Is there any better way to solve it? Thanks.</p>