Skip to content

Commit 406e68c

Browse files
committed
Check whether type parameters are loaded before emitting.
This fixes #190. BUG= [email protected] Review URL: https://codereview.chromium.org/1143253003
1 parent 0ce4905 commit 406e68c

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

pkg/dev_compiler/lib/src/codegen/js_codegen.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,9 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
10001000
type.normalParameterTypes.every(_typeIsLoaded));
10011001
}
10021002
if (type.isDynamic || type.isVoid || type.isBottom) return true;
1003+
if (type is ParameterizedType && !type.typeArguments.every(_typeIsLoaded)) {
1004+
return false;
1005+
}
10031006
return _loader.isLoaded(type.element);
10041007
}
10051008

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var functions = dart.defineLibrary(functions, {});
2+
var core = dart.import(core);
3+
(function(exports, core) {
4+
'use strict';
5+
function bootstrap() {
6+
return dart.setType([new Foo()], core.List$(Foo));
7+
}
8+
dart.fn(bootstrap, () => dart.functionType(core.List$(Foo), []));
9+
class Foo extends core.Object {}
10+
dart.setSignature(Foo, {});
11+
function main() {
12+
core.print(bootstrap()[core.$get](0));
13+
}
14+
dart.fn(main, dart.void, []);
15+
// Exports:
16+
exports.bootstrap = bootstrap;
17+
exports.Foo = Foo;
18+
exports.main = main;
19+
})(functions, core);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Messages from compiling functions.dart
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
List<Foo> bootstrap() {
2+
return <Foo>[new Foo()];
3+
}
4+
5+
typedef B A2B<A, B>(A x);
6+
7+
A2B<Foo, Foo> id(A2B<Foo, Foo> f) => f;
8+
9+
class Foo {
10+
}
11+
12+
void main() {
13+
print(bootstrap()[0]);
14+
}

0 commit comments

Comments
 (0)