Skip to content

Commit

Permalink
Check whether type parameters are loaded before emitting.
Browse files Browse the repository at this point in the history
This fixes #190.

BUG=
R=vsm@google.com

Review URL: https://codereview.chromium.org/1143253003
  • Loading branch information
leafpetersen committed May 20, 2015
1 parent 0ce4905 commit 406e68c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/dev_compiler/lib/src/codegen/js_codegen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,9 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
type.normalParameterTypes.every(_typeIsLoaded));
}
if (type.isDynamic || type.isVoid || type.isBottom) return true;
if (type is ParameterizedType && !type.typeArguments.every(_typeIsLoaded)) {
return false;
}
return _loader.isLoaded(type.element);
}

Expand Down
19 changes: 19 additions & 0 deletions pkg/dev_compiler/test/codegen/expect/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var functions = dart.defineLibrary(functions, {});
var core = dart.import(core);
(function(exports, core) {
'use strict';
function bootstrap() {
return dart.setType([new Foo()], core.List$(Foo));
}
dart.fn(bootstrap, () => dart.functionType(core.List$(Foo), []));
class Foo extends core.Object {}
dart.setSignature(Foo, {});
function main() {
core.print(bootstrap()[core.$get](0));
}
dart.fn(main, dart.void, []);
// Exports:
exports.bootstrap = bootstrap;
exports.Foo = Foo;
exports.main = main;
})(functions, core);
1 change: 1 addition & 0 deletions pkg/dev_compiler/test/codegen/expect/functions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Messages from compiling functions.dart
14 changes: 14 additions & 0 deletions pkg/dev_compiler/test/codegen/functions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
List<Foo> bootstrap() {
return <Foo>[new Foo()];
}

typedef B A2B<A, B>(A x);

A2B<Foo, Foo> id(A2B<Foo, Foo> f) => f;

class Foo {
}

void main() {
print(bootstrap()[0]);
}

0 comments on commit 406e68c

Please sign in to comment.