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

Unified Diff: dart/frog/leg/resolver.dart

Issue 9646030: Find diagnostic locations for use in new compiler API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 8 years, 9 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 | « dart/frog/leg/frog_leg.dart ('k') | dart/frog/leg/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/resolver.dart
diff --git a/dart/frog/leg/resolver.dart b/dart/frog/leg/resolver.dart
index 0a4a7695c6226ac5bc9d42ac9c7249f1ef034165..ce73e2213b234c18150556e08909a14555128690 100644
--- a/dart/frog/leg/resolver.dart
+++ b/dart/frog/leg/resolver.dart
@@ -70,13 +70,9 @@ class ResolverTask extends CompilerTask {
[noConstructor(Element)]) {
final SourceString constructorName = getConstructorName(send);
final SourceString className = classElement.name;
- FunctionElement result = classElement.lookupConstructor(className,
- constructorName,
- noConstructor);
- if (result === null && send.arguments.isEmpty()) {
- result = classElement.getSynthesizedConstructor();
- }
- return result;
+ return classElement.lookupConstructor(className,
+ constructorName,
+ noConstructor);
}
FunctionElement resolveConstructorRedirection(FunctionElement constructor) {
@@ -180,13 +176,6 @@ class ResolverTask extends CompilerTask {
defaultClass.name.slowToString()));
constructor.defaultImplementation = defaultClass.lookupConstructor(name);
- if (constructor.defaultImplementation === null
- && name == defaultClass.name
- && constructor.computeParameters(compiler).parameterCount === 0) {
- constructor.defaultImplementation =
- defaultClass.getSynthesizedConstructor();
- }
-
if (constructor.defaultImplementation === null) {
// We failed find a constrcutor named either
// "MyInterface.name" or "MyClass.name".
@@ -1147,6 +1136,7 @@ class ClassResolverVisitor extends CommonResolverVisitor<Type> {
element.interfaces = element.interfaces.prepend(visit(link.head));
}
calculateAllSupertypes(element, new Set<ClassElement>());
+ addDefaultConstructorIfNeeded(element);
return element.computeType(compiler);
}
@@ -1241,6 +1231,24 @@ class ClassResolverVisitor extends CommonResolverVisitor<Type> {
}
}
+ /**
+ * Add a synthetic nullary constructor if there are no other
+ * constructors.
+ */
+ void addDefaultConstructorIfNeeded(ClassElement element) {
+ if (element.constructors.length != 0) return;
+ SynthesizedConstructorElement constructor =
+ new SynthesizedConstructorElement(element);
+ element.constructors[element.name] = constructor;
+ Type returnType = compiler.types.voidType;
+ constructor.type = new FunctionType(returnType, const EmptyLink<Type>(),
+ constructor);
+ constructor.cachedNode =
+ new FunctionExpression(new Identifier(element.position()),
+ new NodeList.empty(),
+ new Block(new NodeList.empty()),
+ null, null, null, null);
+ }
}
class VariableDefinitionsVisitor extends CommonResolverVisitor<SourceString> {
@@ -1443,12 +1451,7 @@ class ConstructorResolver extends CommonResolverVisitor<Element> {
if (cls.isInterface() && (cls.defaultClass === null)) {
error(selector, MessageKind.CANNOT_INSTANTIATE_INTERFACE, [cls.name]);
}
- FunctionElement constructor = cls.lookupConstructor(cls.name);
- if (constructor === null && node.send.argumentsNode.isEmpty()) {
- e = cls.getSynthesizedConstructor();
- } else {
- e = constructor;
- }
+ e = cls.lookupConstructor(cls.name);
}
return e;
}
« no previous file with comments | « dart/frog/leg/frog_leg.dart ('k') | dart/frog/leg/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698