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

Unified Diff: lib/compiler/implementation/ssa/builder.dart

Issue 11109012: Land Alexander's change that throw on abstract class instantiations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge. Created 8 years, 2 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/compiler/implementation/lib/js_helper.dart ('k') | lib/core/errors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/builder.dart
diff --git a/lib/compiler/implementation/ssa/builder.dart b/lib/compiler/implementation/ssa/builder.dart
index 5cf3d37c737b44c54e279c727081e810881ac1d7..b31cd847f1f3c1cd4fac1ecb754b05732837ad5f 100644
--- a/lib/compiler/implementation/ssa/builder.dart
+++ b/lib/compiler/implementation/ssa/builder.dart
@@ -119,6 +119,11 @@ class Interceptors {
return compiler.findHelper(const SourceString('throwRuntimeError'));
}
+ Element getThrowAbstractClassInstantiationError() {
+ return compiler.findHelper(
+ const SourceString('throwAbstractClassInstantiationError'));
+ }
+
Element getClosureConverter() {
return compiler.findHelper(const SourceString('convertDartClosureToJS'));
}
@@ -2937,6 +2942,11 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
compiler.internalError("malformed send in new expression");
}
InterfaceType type = elements.getType(annotation);
+ if (type.element.modifiers.isAbstract() &&
+ constructor.isGenerativeConstructor()) {
+ generateAbstractClassInstantiationError(node, type.name.slowToString());
+ return;
+ }
if (compiler.world.needsRti(constructor.enclosingElement)) {
type.arguments.forEach((DartType argument) {
inputs.add(analyzeTypeArgument(argument, node));
@@ -3011,15 +3021,24 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
compiler.internalError(reason, node: node);
}
- void generateRuntimeError(Node node, String message) {
+ void generateError(Node node, String message, Element helper) {
DartString messageObject = new DartString.literal(message);
Constant messageConstant =
constantSystem.createString(messageObject, node);
HInstruction errorMessage = graph.addConstant(messageConstant);
- Element helper = interceptors.getThrowRuntimeError();
pushInvokeHelper1(helper, errorMessage);
}
+ void generateRuntimeError(Node node, String message) {
+ generateError(node, message, interceptors.getThrowRuntimeError());
+ }
+
+ void generateAbstractClassInstantiationError(Node node, String message) {
+ generateError(node,
+ message,
+ interceptors.getThrowAbstractClassInstantiationError());
+ }
+
void generateThrowNoSuchMethod(Node diagnosticNode,
String methodName,
[Link<Node> argumentNodes,
« no previous file with comments | « lib/compiler/implementation/lib/js_helper.dart ('k') | lib/core/errors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698