title: Why does this Scala function compile when the argument does not conform to the type constraint?
body: <p>Let's say I have an empty marker trait named <code>Marker</code> and some functions with type parameters bound by <code>Marker</code>:</p>
  
  <pre><code>trait Marker
  
  object Marker {
    def works[M &lt;: Marker](m:M):M = m
    def doesntWork[M &lt;: Marker](f:M =&gt; String):String = "doesn't matter"
  }
  </code></pre>
  
  <p>The first function works as I expect.  That is, if you pass a parameter which is not a <code>Marker</code>, then the code does not compile:</p>
  
  <pre><code>scala&gt; works("a string")
  &lt;console&gt;:14: error: inferred type arguments [String] do not conform to method works's type parameter bounds [M &lt;: com.joescii.Marker]
         works("a string")
         ^
  &lt;console&gt;:14: error: type mismatch;
   found   : String("a string")
   required: M
         works("a string")
               ^
  </code></pre>
  
  <p>However, I am able to pass a parameter to the second function which does not conform to <code>Marker</code>.  Specifically, I can pass a function of type <code>String =&gt; String</code> and the code happily compiles and runs:</p>
  
  <pre><code>scala&gt; doesntWork( (str:String) =&gt; "a string" )
  res1: String = doesn't matter
  </code></pre>
  
  <p>I would expect this call to <code>doesntWork</code> to fail to compile.  Can anyone explain to me why it compiles and how I can change the function signature to prevent the types from checking in such cases?</p>
  
  <p><em>Full disclosure: the above contrived example is a simplified version of <a href="https://github.com/joescii/lift-ng/issues/12">this outstanding issue for lift-ng</a>.</em></p>