Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Generic calls don't work with async #538

Closed
@harryterkelsen

Description

@harryterkelsen
import 'dart:async';

class A {
  Future<int> bar() async {
    var result = await foo/*<int>*/(1);
    return result + 1;
  }

  Future/*<T>*/ foo/*<T>*/(/*=T*/ x) async {
    var result = await new Future/*<T>*/.value(x);
    return result;
  }
}

Future<Null> main() async {
  var a = new A();
  var x = await a.bar();
  print(x);
}

generates this:

  hello.A = class A extends core.Object {
    bar() {
      return dart.async((function*() {
        let result = (yield this.foo(core.int)(1));
        return dart.notNull(result) + 1;
      }).bind(this), core.int);
    }
    foo(x) {
      return dart.async(function*(x) {
        let result = (yield async.Future$(T).value(x));
        return result;
      }, T, x);
    }
  };
  dart.setSignature(hello.A, {
    methods: () => ({
      bar: [async.Future$(core.int), []],
      foo: [T => [async.Future$(T), [T]]]
    })
  });
  hello.main = function() {
    return dart.async(function*() {
      let a = new hello.A();
      let x = (yield a.bar());
      core.print(x);
    }, core.Null);
  };

The foo method isn't taking the T type parameter.

Activity

changed the title [-]Generic calls don't work inside async[/-] [+]Generic calls don't work with async[/+] on Apr 29, 2016
harryterkelsen

harryterkelsen commented on Apr 29, 2016

@harryterkelsen
ContributorAuthor

That example is too big, here's a smaller one with the same problem:

import 'dart:async';

Future/*<T>*/ foo/*<T>*/(/*=T*/ x) async => x;

main() async {
  print(await foo/*<int>*/(1));
}
jmesserly

jmesserly commented on Apr 29, 2016

@jmesserly
Contributor

thanks, I can take a look. we have a lot of paths for generating function bodies so it's not terribly surprising. I'll also add to the tracking bug #435

self-assigned this
on Apr 29, 2016
jmesserly

jmesserly commented on Apr 29, 2016

@jmesserly
Contributor

likely async*/sync* have the same issue.

harryterkelsen

harryterkelsen commented on Apr 29, 2016

@harryterkelsen
ContributorAuthor

I think I found a 1-line fix, will send for review

jmesserly

jmesserly commented on Apr 29, 2016

@jmesserly
Contributor

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @jmesserly@harryterkelsen

      Issue actions

        Generic calls don't work with async · Issue #538 · dart-archive/dev_compiler