title: The argument types of an anonymous function must be fully known. (SLS 8.5)
body: <p>I have a function literal</p>
  
  <pre><code>{case QualifiedType(preds, ty) =&gt;
                 t.ty = ty ;
                 Some((emptyEqualityConstraintSet,preds)) }
  </code></pre>
  
  <p>Which results in an error message</p>
  
  <pre><code>missing parameter type for expanded function The argument types of an anonymous function
  must be fully known. (SLS 8.5) Expected type was:
  ? =&gt; Option[(Typer.this.EqualityConstraintSet, Typer.this.TypeRelationSet)]
  </code></pre>
  
  <p>I looked in <a href="https://www.scala-lang.org/files/archive/spec/2.11/08-pattern-matching.html#pattern-matching-anonymous-functions" rel="noreferrer">SLS 8.5</a>, but didn't find an explanation.</p>
  
  <p>If I expand the function myself to </p>
  
  <pre><code>{(qt : QualifiedType) =&gt;
    qt match {case QualifiedType(preds, ty) =&gt;
                 t.ty = ty ;
                 Some((emptyEqualityConstraintSet,preds)) }}
  </code></pre>
  
  <p>the error goes away.</p>
  
  <p>(a) Why is this an error?</p>
  
  <p>(b) What can I do to fix it?</p>
  
  <p>I tried the obvious fix, which was to add <code>: QualifiedType</code> between the pattern and the =>, but this is a syntax error.</p>
  
  <hr>
  
  <p>One thing I noticed is that the context makes a difference. If I use the function literal as an argument to a function declared as expecting a <code>QualifiedType =&gt; B</code>, there is no error.  But if I use it as an argument to a function expecting an <code>A =&gt; B</code>, there is an error.  I expect that what is going on here is that, as the pattern could conceivably be applied to an object whose type is a supertype of QualifiedType, the compiler is not willing to assign the obvious type without assurance that the function won't be applied to anything that isn't a QualifiedType. Really what I'd like is to be able to write <code>{QualifiedType( preds, ty) =&gt; ...}</code>
  and have it mean the same thing as Haskell's <code>\QualifiedType(preds,ty) -&gt; ...</code>.</p>