title: Why the Dart compiler cannot infer the type but the C# compiler can do this, despite the fact that this is a fairly simple case
body: <p>Sample source code:</p>
  
  <pre><code>void main() {
    final func = () =&gt; petOwners.selectMany(
        (petOwner) =&gt; petOwner.pets, (petOwner, petName) =&gt; {petOwner: petName});
    print(func.runtimeType);
  }
  
  final petOwners = [
    PetOwner('Higa', ['Scruffy', 'Sam']),
    PetOwner('Ashkenazi', ['Walker', 'Sugar']),
    PetOwner('Price', ['Scratches', 'Diesel']),
    PetOwner('Hines', ['Dusty']),
  ];
  
  class PetOwner {
    String name;
    List&lt;String&gt; pets;
    PetOwner(this.name, this.pets);
  }
  
  extension IEnumerable&lt;TSource&gt; on Iterable&lt;TSource&gt; {
    Iterable&lt;TResult&gt; selectMany&lt;TCollection, TResult&gt;(
        Iterable&lt;TCollection&gt; Function(TSource) collectionSelector,
        TResult Function(TSource, TCollection) resultSelector) {
      return null;
    }
  }
  </code></pre>
  
  <p>Output:</p>
  
  <p><code>() =&gt; Iterable&lt;Map&lt;PetOwner, dynamic&gt;&gt;</code></p>
  
  <p>That is, instead of getting the result <code>() =&gt; Iterable&lt;Map&lt;PetOwner, String&gt;&gt;</code> I get a rather strange result of the form <code>() =&gt; Iterable&lt;Map&lt;PetOwner, dynamic&gt;&gt;</code>.</p>
  
  <p>In this rather simple case, the Dart compiler is not able to infer the type "TCollection".<br>
  I can’t understand what is the reason. The code is quite simple. Easier nowhere.<br>
  Nevertheless, the result is very poor. Is this a bug in the compiler or is it done according to the language specification?<br>
  If this meets the specifications, then why was this decision made? Are there really any advantages from this (in such minimization and simplification)?</p>
  
  <p>P.S.<br>
  The same simplest code written in C# works without problems.</p>
  
  <p>EDIT:</p>
  
  <p>The problem in that the compiler cannot infer the type "TCollection" from this code (<code>Iterable&lt;TCollection&gt; Function(TSource) collectionSelector</code>):</p>
  
  <pre><code>(petOwner) =&gt; petOwner.pets
  </code></pre>
  
  <p>The compiler should consider this code as the following:</p>
  
  <pre><code>() =&gt; (PetOwner) =&gt; List&lt;String&gt;
  </code></pre>
  
  <p>But the compiler recognizes this code like this:</p>
  
  <pre><code>() =&gt; (PetOwner) =&gt; dynamic
  </code></pre>