Closed
Description
See #33119 (comment) for background.
DDC throws with:
TypeError: Closure 'Manager_getResponse_closure': type '(SubContext) => Response<SubContext>' is not a subtype of type '(Context) => Response<Context>'
Unfortunately this doesn't really explain anything, and because most of Dart is based on covariance, I (incorrectly) thought "WTF, its a Response<SubContext>
, that's even BETTER than Response<Context>
". Of course, that is not the case...
- Does our language tour or Dart 2 FAQ have anything to help here?
- Can the error message call out "contravariance" or something to help the user?
In #33119 (comment) specifically, we are statically asking for a Callback<Response<Context>>
, but at runtime getting Callback<Response<SubContext>>
, which of course is contravariantly invalid.