title: found Unit: required Int. Why is the error not obvious?
body: <p>I have a method that is supposed to return an Int. I am trying to understand why Eclipse won't let me compile this, even though it looks apparent to me inside the if statement that I am indeed returning an Int. Is there something I am missing very obvious? I am trying to understand this aspect of Scala before proceeding to write more code.</p>
  
  <p>Here is the method:</p>
  
  <pre><code>def contains1(sfType: TokenType): Int = {
       if (Tokens.KEYWORDS.contains(sfType)) {
        val retVal = TokenTypes.RESERVED_WORD
      }
    }
  </code></pre>
  
  <p>Eclipse complains on line 2 --- 'type mismatch; found : Unit required: Int"</p>
  
  <pre><code>TokenTypes is - public abstract interface org.fife.ui.rsyntaxtextarea.TokenTypes and RESERVED_WORD is - public static final int RESERVED_WORD = 6;
  </code></pre>
  
  <p>I have read this post here: <a href="https://stackoverflow.com/questions/10753542/found-unit-required-int-how-to-correct-this?rq=1">found: Unit required: Int - How to correct this?</a> and tried to solve the problem before posting it, but I am still at a loss.</p>
  
  <p>Edit: The method is supposed to return an Int and I had typed in the return type wrongly. My problem remains the same. Eclipse still complains.</p>