| Index: pkg/dev_compiler/lib/src/compiler/code_generator.dart
|
| diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
|
| index 79ac857a76947ee40b01748cc93354bdf5504444..3db18c433c4eaabe163af9c417d873e8151ec40b 100644
|
| --- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
|
| +++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
|
| @@ -3707,7 +3707,7 @@ class CodeGenerator extends GeneralizingAstVisitor
|
| // arg[0] is static return type, used in `RestrictedStaticTypeAnalyzer`
|
| var code = args[1];
|
| List<AstNode> templateArgs;
|
| - var source;
|
| + String source;
|
| if (code is StringInterpolation) {
|
| if (args.length > 2) {
|
| throw new ArgumentError(
|
| @@ -3727,6 +3727,28 @@ class CodeGenerator extends GeneralizingAstVisitor
|
| source = (code as StringLiteral).stringValue;
|
| }
|
|
|
| + // TODO(vsm): Constructors in dart:html and friends are trying to
|
| + // allocate a type defined on window/self, but this often conflicts a
|
| + // with the generated extenstion class in scope. We really should
|
| + // qualify explicitly in dart:html itself.
|
| + var constructorPattern = new RegExp("new [A-Z][A-Za-z]+\\(");
|
| + if (constructorPattern.matchAsPrefix(source) != null) {
|
| + var containingClass = node.parent;
|
| + while (
|
| + containingClass != null && containingClass is! ClassDeclaration) {
|
| + containingClass = containingClass.parent;
|
| + }
|
| + if (containingClass is ClassDeclaration &&
|
| + _extensionTypes.isNativeClass(containingClass.element)) {
|
| + var constructorName = source.substring(4, source.indexOf('('));
|
| + var className = containingClass.name.name;
|
| + if (className == constructorName) {
|
| + source =
|
| + source.replaceFirst('new $className(', 'new self.$className(');
|
| + }
|
| + }
|
| + }
|
| +
|
| // TODO(rnystrom): The JS() calls are almost never nested, and probably
|
| // really shouldn't be, but there are at least a couple of calls in the
|
| // HTML library where an argument to JS() is itself a JS() call. If those
|
|
|