Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(629)

Unified Diff: lib/src/codegen/js_codegen.dart

Issue 1135543003: Fixes #178 (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Minor fixes + tests Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/runtime/dart/math.js ('k') | test/browser/runtime_tests.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_codegen.dart
diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart
index 264cccc42e23de10153334825d9e0422fa09896f..2c9f87f6c15b84825a6369e076ce81d843e52487 100644
--- a/lib/src/codegen/js_codegen.dart
+++ b/lib/src/codegen/js_codegen.dart
@@ -68,6 +68,8 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
ConstantEvaluator _constEvaluator;
+ ClassElement _currentClassElement = null;
+
/// Imported libraries, and the temporaries used to refer to them.
final _imports = new Map<LibraryElement, JS.TemporaryId>();
final _exports = new Set<String>();
@@ -332,6 +334,10 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
if (jsName != null) return _emitJsType(node.name.name, jsName);
+ // Set current class
+ assert(_currentClassElement == null);
+ _currentClassElement = classElem;
+
var ctors = <ConstructorDeclaration>[];
var fields = <FieldDeclaration>[];
var staticFields = <FieldDeclaration>[];
@@ -355,6 +361,10 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
var body = _finishClassMembers(
classElem, classExpr, ctors, fields, staticFields, jsPeerName);
+ // Unset current class
+ assert(_currentClassElement == classElem);
+ _currentClassElement = null;
+
var result = _finishClassDef(type, body);
if (jsPeerName != null) {
@@ -1235,9 +1245,17 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
var typeArgs = null;
if (type is ParameterizedType) {
var args = type.typeArguments;
+ var isCurrentClass =
+ type is InterfaceType ? type.element == _currentClassElement : false;
if (args.any((a) => a != types.dynamicType)) {
name = '$name\$';
typeArgs = args.map(_emitTypeName);
+ } else if (args.isNotEmpty && isCurrentClass) {
+ // When creating a `new S<dynamic>` we try and use the raw form `new S()`,
Jennifer Messerly 2015/05/11 17:52:56 maybe a long line?
vsm 2015/05/11 17:56:03 Done.
+ // but this does not work if we're inside the same class, because `S` refers
+ // to the current S<T> we are generating.
+ name = '$name\$';
+ typeArgs = [];
}
}
« no previous file with comments | « lib/runtime/dart/math.js ('k') | test/browser/runtime_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698