Dart2js release build may make generic parameters dynamic

From rrousselGit/provider#406

@mono0926 found a compilation issue with Dart2js when running:

flutter run -t chrome --release

where the build output behaves differently from debug builds and VM builds.

The issue happens with the following code:

typedef Locator = void Function<T>();

class Bar {
  Bar({this.read}) {

  final Locator read;

void main() {
  Bar(read: <T>() {
    return null;

The expected behavior of this code is to print int in the console, which it does in debug builds and VM release builds.
But when running this code with flutter -t chrome --release, this will print dynamic

This causes InheritedWIdgets from Flutter to fail to be resolved

Author: Fantashit

6 thoughts on “Dart2js release build may make generic parameters dynamic

  1. I checked on it, by looking in the results.json for the build after the one they were reported on.
    They were detected to be flaky in that next build, so they stopped being reported on the results feed, and the previous failure was not marked as “superceded” (inactive, replaced by a more recent change).

    This failure has happened a number of times before, and confuses everyone and wastes their time.
    The fix is to report a change in flaky status to the results feed, and mark earlier failures on now flaky tests as inactive.
    I see now that fixing this is urgent, because it wastes so many users’ time when it happens.

  2. My apologies – I closed the issue when my fix landed and our tests started passing, but it looks like there’s still another bug lurking around when --omit-implicit-checks is passed. I’ll add another test and investigate.

  3. The initial fix for this was pretty quick, but revealed a deeper issue causing other tests (mainly async ones) to fail. I have a more complete fix that I’m working on landing now.

  4. HI @ochmist – the fix landed in 5671730, which is part of Dart’s 2.10.0-1.0.dev release and newer releases.

    I am not sure on which flutter release this version was rolled into. When I try flutter doctor -v, I see already a newer version of the Dart sdk in the master channel:

    [✓] Flutter (Channel master, 1.21.0-10.0.pre.41, on Linux, locale en_US.UTF-8)
        • Flutter version 1.21.0-10.0.pre.41 at /usr/local/google/home/sigmund/dart/flutter/flutter
        • Framework revision 49fac9a885 (2 days ago), 2020-08-11 11:44:03 -0700
        • Engine revision 9b4ce4e3a0
        • Dart version 2.10.0 (build 2.10.0-11.0.dev)

    So the fix should be there. Is the Dart version in your case further behind? Is this resolved after upgrading to the latest flutter?

Comments are closed.