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

Unified Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 1499793002: AbstractClassInstantiationError beats NoSuchMethodError (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years 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 | « no previous file | tests/language/abstract_beats_arguments_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 3668109ef34cf1720a21eaaf3ebf059d00f71f44..e1a9d20ef94853ce1e9cf681df424da5785ed68f 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -5134,15 +5134,17 @@ class SsaBuilder extends ast.Visitor
stack.add(graph.addConstantNull(compiler));
return;
}
+
if (checkTypeVariableBounds(node, type)) return;
sra1 2015/12/04 00:22:23 TODO (later): in checked mode, does the type varia
- var inputs = <HInstruction>[];
- if (constructor.isGenerativeConstructor &&
- backend.isNativeOrExtendsNative(constructor.enclosingClass) &&
- !backend.isJsInterop(constructor)) {
- // Native class generative constructors take a pre-constructed object.
- inputs.add(graph.addConstantNull(compiler));
+ // Abstract class instantiation error takes precedence over argument
+ // mismatch.
+ ClassElement cls = constructor.enclosingClass;
+ if (cls.isAbstract && constructor.isGenerativeConstructor) {
+ generateAbstractClassInstantiationError(send, cls.name);
+ return;
}
+
// TODO(5347): Try to avoid the need for calling [implementation] before
// calling [makeStaticArgumentList].
constructorImplementation = constructor.implementation;
@@ -5152,6 +5154,14 @@ class SsaBuilder extends ast.Visitor
generateWrongArgumentCountError(send, constructor, send.arguments);
return;
}
+
+ var inputs = <HInstruction>[];
+ if (constructor.isGenerativeConstructor &&
+ backend.isNativeOrExtendsNative(constructor.enclosingClass) &&
+ !backend.isJsInterop(constructor)) {
+ // Native class generative constructors take a pre-constructed object.
+ inputs.add(graph.addConstantNull(compiler));
+ }
inputs.addAll(makeStaticArgumentList(callStructure,
send.arguments,
constructorImplementation));
@@ -5198,13 +5208,7 @@ class SsaBuilder extends ast.Visitor
} else {
SourceInformation sourceInformation =
sourceInformationBuilder.buildNew(send);
- ClassElement cls = constructor.enclosingClass;
- if (cls.isAbstract && constructor.isGenerativeConstructor) {
- generateAbstractClassInstantiationError(send, cls.name);
- return;
- }
potentiallyAddTypeArguments(inputs, cls, expectedType);
-
addInlinedInstantiation(expectedType);
pushInvokeStatic(node, constructor, inputs,
typeMask: elementType,
« no previous file with comments | « no previous file | tests/language/abstract_beats_arguments_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698