@@ -5134,15 +5134,17 @@ class SsaBuilder extends ast.Visitor
5134
5134
stack.add (graph.addConstantNull (compiler));
5135
5135
return ;
5136
5136
}
5137
+
5137
5138
if (checkTypeVariableBounds (node, type)) return ;
5138
5139
5139
- var inputs = < HInstruction > [];
5140
- if (constructor.isGenerativeConstructor &&
5141
- backend. isNativeOrExtendsNative ( constructor.enclosingClass) &&
5142
- ! backend. isJsInterop ( constructor) ) {
5143
- // Native class generative constructors take a pre-constructed object.
5144
- inputs. add (graph. addConstantNull (compiler)) ;
5140
+ // Abstract class instantiation error takes precedence over argument
5141
+ // mismatch.
5142
+ ClassElement cls = constructor.enclosingClass;
5143
+ if (cls.isAbstract && constructor.isGenerativeConstructor ) {
5144
+ generateAbstractClassInstantiationError (send, cls.name);
5145
+ return ;
5145
5146
}
5147
+
5146
5148
// TODO(5347): Try to avoid the need for calling [implementation] before
5147
5149
// calling [makeStaticArgumentList].
5148
5150
constructorImplementation = constructor.implementation;
@@ -5152,6 +5154,14 @@ class SsaBuilder extends ast.Visitor
5152
5154
generateWrongArgumentCountError (send, constructor, send.arguments);
5153
5155
return ;
5154
5156
}
5157
+
5158
+ var inputs = < HInstruction > [];
5159
+ if (constructor.isGenerativeConstructor &&
5160
+ backend.isNativeOrExtendsNative (constructor.enclosingClass) &&
5161
+ ! backend.isJsInterop (constructor)) {
5162
+ // Native class generative constructors take a pre-constructed object.
5163
+ inputs.add (graph.addConstantNull (compiler));
5164
+ }
5155
5165
inputs.addAll (makeStaticArgumentList (callStructure,
5156
5166
send.arguments,
5157
5167
constructorImplementation));
@@ -5198,13 +5208,7 @@ class SsaBuilder extends ast.Visitor
5198
5208
} else {
5199
5209
SourceInformation sourceInformation =
5200
5210
sourceInformationBuilder.buildNew (send);
5201
- ClassElement cls = constructor.enclosingClass;
5202
- if (cls.isAbstract && constructor.isGenerativeConstructor) {
5203
- generateAbstractClassInstantiationError (send, cls.name);
5204
- return ;
5205
- }
5206
5211
potentiallyAddTypeArguments (inputs, cls, expectedType);
5207
-
5208
5212
addInlinedInstantiation (expectedType);
5209
5213
pushInvokeStatic (node, constructor, inputs,
5210
5214
typeMask: elementType,
0 commit comments