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
Description
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.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
[-]Generic calls don't work inside async[/-][+]Generic calls don't work with async[/+]harryterkelsen commentedon Apr 29, 2016
That example is too big, here's a smaller one with the same problem:
jmesserly commentedon Apr 29, 2016
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
jmesserly commentedon Apr 29, 2016
likely
async*/sync*
have the same issue.harryterkelsen commentedon Apr 29, 2016
I think I found a 1-line fix, will send for review
jmesserly commentedon Apr 29, 2016
🎉