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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/language/abstract_beats_arguments_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of ssa; 5 part of ssa;
6 6
7 class SsaFunctionCompiler implements FunctionCompiler { 7 class SsaFunctionCompiler implements FunctionCompiler {
8 final SsaCodeGeneratorTask generator; 8 final SsaCodeGeneratorTask generator;
9 final SsaBuilderTask builder; 9 final SsaBuilderTask builder;
10 final SsaOptimizerTask optimizer; 10 final SsaOptimizerTask optimizer;
(...skipping 5116 matching lines...) Expand 10 before | Expand all | Expand 10 after
5127 InterfaceType type = elements.getType(node); 5127 InterfaceType type = elements.getType(node);
5128 InterfaceType expectedType = 5128 InterfaceType expectedType =
5129 constructorDeclaration.computeEffectiveTargetType(type); 5129 constructorDeclaration.computeEffectiveTargetType(type);
5130 expectedType = localsHandler.substInContext(expectedType); 5130 expectedType = localsHandler.substInContext(expectedType);
5131 5131
5132 if (compiler.elementHasCompileTimeError(constructor)) { 5132 if (compiler.elementHasCompileTimeError(constructor)) {
5133 // TODO(ahe): Do something like [generateWrongArgumentCountError]. 5133 // TODO(ahe): Do something like [generateWrongArgumentCountError].
5134 stack.add(graph.addConstantNull(compiler)); 5134 stack.add(graph.addConstantNull(compiler));
5135 return; 5135 return;
5136 } 5136 }
5137
5137 if (checkTypeVariableBounds(node, type)) return; 5138 if (checkTypeVariableBounds(node, type)) return;
sra1 2015/12/04 00:22:23 TODO (later): in checked mode, does the type varia
5138 5139
5139 var inputs = <HInstruction>[]; 5140 // Abstract class instantiation error takes precedence over argument
5140 if (constructor.isGenerativeConstructor && 5141 // mismatch.
5141 backend.isNativeOrExtendsNative(constructor.enclosingClass) && 5142 ClassElement cls = constructor.enclosingClass;
5142 !backend.isJsInterop(constructor)) { 5143 if (cls.isAbstract && constructor.isGenerativeConstructor) {
5143 // Native class generative constructors take a pre-constructed object. 5144 generateAbstractClassInstantiationError(send, cls.name);
5144 inputs.add(graph.addConstantNull(compiler)); 5145 return;
5145 } 5146 }
5147
5146 // TODO(5347): Try to avoid the need for calling [implementation] before 5148 // TODO(5347): Try to avoid the need for calling [implementation] before
5147 // calling [makeStaticArgumentList]. 5149 // calling [makeStaticArgumentList].
5148 constructorImplementation = constructor.implementation; 5150 constructorImplementation = constructor.implementation;
5149 if (constructorImplementation.isMalformed || 5151 if (constructorImplementation.isMalformed ||
5150 !callStructure.signatureApplies( 5152 !callStructure.signatureApplies(
5151 constructorImplementation.functionSignature)) { 5153 constructorImplementation.functionSignature)) {
5152 generateWrongArgumentCountError(send, constructor, send.arguments); 5154 generateWrongArgumentCountError(send, constructor, send.arguments);
5153 return; 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 inputs.addAll(makeStaticArgumentList(callStructure, 5165 inputs.addAll(makeStaticArgumentList(callStructure,
5156 send.arguments, 5166 send.arguments,
5157 constructorImplementation)); 5167 constructorImplementation));
5158 5168
5159 TypeMask elementType = computeType(constructor); 5169 TypeMask elementType = computeType(constructor);
5160 if (isFixedListConstructorCall) { 5170 if (isFixedListConstructorCall) {
5161 if (!inputs[0].isNumber(compiler)) { 5171 if (!inputs[0].isNumber(compiler)) {
5162 HTypeConversion conversion = new HTypeConversion( 5172 HTypeConversion conversion = new HTypeConversion(
5163 null, HTypeConversion.ARGUMENT_TYPE_CHECK, backend.numType, 5173 null, HTypeConversion.ARGUMENT_TYPE_CHECK, backend.numType,
5164 inputs[0], null); 5174 inputs[0], null);
(...skipping 26 matching lines...) Expand all
5191 // We need a finer grained side effect. 5201 // We need a finer grained side effect.
5192 add(new HForeignCode(code, backend.nullType, [stack.last], 5202 add(new HForeignCode(code, backend.nullType, [stack.last],
5193 throwBehavior: native.NativeThrowBehavior.MAY)); 5203 throwBehavior: native.NativeThrowBehavior.MAY));
5194 } 5204 }
5195 } else if (isGrowableListConstructorCall) { 5205 } else if (isGrowableListConstructorCall) {
5196 push(buildLiteralList(<HInstruction>[])); 5206 push(buildLiteralList(<HInstruction>[]));
5197 stack.last.instructionType = elementType; 5207 stack.last.instructionType = elementType;
5198 } else { 5208 } else {
5199 SourceInformation sourceInformation = 5209 SourceInformation sourceInformation =
5200 sourceInformationBuilder.buildNew(send); 5210 sourceInformationBuilder.buildNew(send);
5201 ClassElement cls = constructor.enclosingClass;
5202 if (cls.isAbstract && constructor.isGenerativeConstructor) {
5203 generateAbstractClassInstantiationError(send, cls.name);
5204 return;
5205 }
5206 potentiallyAddTypeArguments(inputs, cls, expectedType); 5211 potentiallyAddTypeArguments(inputs, cls, expectedType);
5207
5208 addInlinedInstantiation(expectedType); 5212 addInlinedInstantiation(expectedType);
5209 pushInvokeStatic(node, constructor, inputs, 5213 pushInvokeStatic(node, constructor, inputs,
5210 typeMask: elementType, 5214 typeMask: elementType,
5211 instanceType: expectedType, 5215 instanceType: expectedType,
5212 sourceInformation: sourceInformation); 5216 sourceInformation: sourceInformation);
5213 removeInlinedInstantiation(expectedType); 5217 removeInlinedInstantiation(expectedType);
5214 } 5218 }
5215 HInstruction newInstance = stack.last; 5219 HInstruction newInstance = stack.last;
5216 if (isFixedList) { 5220 if (isFixedList) {
5217 // Overwrite the element type, in case the allocation site has 5221 // Overwrite the element type, in case the allocation site has
(...skipping 3955 matching lines...) Expand 10 before | Expand all | Expand 10 after
9173 if (unaliased is TypedefType) throw 'unable to unalias $type'; 9177 if (unaliased is TypedefType) throw 'unable to unalias $type';
9174 unaliased.accept(this, builder); 9178 unaliased.accept(this, builder);
9175 } 9179 }
9176 9180
9177 void visitDynamicType(DynamicType type, SsaBuilder builder) { 9181 void visitDynamicType(DynamicType type, SsaBuilder builder) {
9178 JavaScriptBackend backend = builder.compiler.backend; 9182 JavaScriptBackend backend = builder.compiler.backend;
9179 ClassElement cls = backend.helpers.DynamicRuntimeType; 9183 ClassElement cls = backend.helpers.DynamicRuntimeType;
9180 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); 9184 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld)));
9181 } 9185 }
9182 } 9186 }
OLDNEW
« 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