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

Unified Diff: lib/compiler/implementation/resolver.dart

Issue 11052012: Patch signatures checked in resolver. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | « no previous file | lib/compiler/implementation/warnings.dart » ('j') | lib/compiler/implementation/warnings.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index 91144c07a22cd284f7bdfb17509ae102bff710a9..b5ded2a42246ce5950d31dc542f10fb8ada5e338 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -133,9 +133,74 @@ class ResolverTask extends CompilerTask {
}
}
+ void checkMatchingPatchParameters(FunctionElement origin,
+ Link<Element> originParameters,
+ Link<Element> patchParameters) {
+ while (!originParameters.isEmpty()) {
+ Element originParameter = originParameters.head;
+ Element patchParameter = patchParameters.head;
+ // Hack: Use unparser to test parameter equality. This only works because
+ // we are restricting patch uses and the approach cannot be used
Lasse Reichstein Nielsen 2012/10/04 07:51:21 How are we restricting it? And isn't this incredib
Johnni Winther 2012/10/04 10:23:29 Restrictions: See the next comment. Inefficient: Y
+ // elsewhere.
+ String originParameterText =
+ originParameter.parseNode(compiler).toString();
+ String patchParameterText =
+ patchParameter.parseNode(compiler).toString();
+ if (originParameterText != patchParameterText) {
Lasse Reichstein Nielsen 2012/10/04 07:51:21 Does this require that the positional parameters h
Johnni Winther 2012/10/04 10:23:29 Yes, parameters must have the same name, and we do
+ error(originParameter.parseNode(compiler),
+ MessageKind.PATCH_PARAMETER_MISMATCH,
+ [origin.name, originParameterText, patchParameterText]);
+ }
+
+ originParameters = originParameters.tail;
+ patchParameters = patchParameters.tail;
+ }
+ }
+
void checkMatchingPatchSignatures(FunctionElement origin,
FunctionElement patch) {
- // TODO(johnniwinther): Stub. Implementation in a later CL.
+ // TODO(johnniwinther): Show both origin and patch locations on errors.
+ FunctionExpression originTree = compiler.withCurrentElement(origin, () {
+ return origin.parseNode(compiler);
+ });
+ FunctionSignature originSignature = compiler.withCurrentElement(origin, () {
+ return origin.computeSignature(compiler);
+ });
+ FunctionExpression patchTree = compiler.withCurrentElement(patch, () {
+ return patch.parseNode(compiler);
+ });
+ FunctionSignature patchSignature = compiler.withCurrentElement(patch, () {
+ return patch.computeSignature(compiler);
+ });
+
Lasse Reichstein Nielsen 2012/10/04 07:51:21 Why is there not a == on FunctionSignature that do
Johnni Winther 2012/10/04 10:23:29 It would require the aforementioned equality on pa
+ if (originSignature.returnType != patchSignature.returnType) {
+ Node errorNode =
+ originTree.returnType !== null ? originTree.returnType : originTree;
ahe 2012/10/04 08:34:21 I think the errorNode should be derived from patch
Johnni Winther 2012/10/04 10:23:29 Done.
+ error(errorNode, MessageKind.PATCH_RETURN_TYPE_MISMATCH,
+ [origin.name, originSignature.returnType, patchSignature.returnType]);
+ }
+ if (originSignature.requiredParameterCount !=
+ patchSignature.requiredParameterCount) {
+ error(originTree,
ahe 2012/10/04 08:34:21 patchTree
Johnni Winther 2012/10/04 10:23:29 Done.
+ MessageKind.PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH,
+ [origin.name, originSignature.requiredParameterCount,
+ patchSignature.requiredParameterCount]);
+ } else {
+ checkMatchingPatchParameters(origin,
+ originSignature.requiredParameters,
+ patchSignature.requiredParameters);
+ }
+ if (originSignature.optionalParameterCount !=
+ patchSignature.optionalParameterCount) {
+ error(originTree,
+ MessageKind.PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH,
+ [origin.name, originSignature.optionalParameterCount,
+ patchSignature.optionalParameterCount]);
+ } else {
+ checkMatchingPatchParameters(origin,
+ originSignature.optionalParameters,
+ patchSignature.optionalParameters);
Lasse Reichstein Nielsen 2012/10/04 07:51:21 Does this handle both optional positional paramete
Johnni Winther 2012/10/04 10:23:29 Yes, but a check is added to ensure that both are
+ }
}
TreeElements resolveMethodElement(FunctionElement element) {
« no previous file with comments | « no previous file | lib/compiler/implementation/warnings.dart » ('j') | lib/compiler/implementation/warnings.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698