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

Unified Diff: frog/minfrog

Issue 8878001: frog: improve errors with named param (bug 507) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: missed adding the new test Created 9 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 | « frog/member.dart ('k') | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/minfrog
diff --git a/frog/minfrog b/frog/minfrog
index d90745ecd0482448c6f268a97c8dd95a170aa650..5ec4fcbddd7f69e7a66446f274a7243ec03b9d2a 100755
--- a/frog/minfrog
+++ b/frog/minfrog
@@ -4295,7 +4295,14 @@ Library.prototype.visitSources = function() {
Library.prototype.toString = function() {
return this.baseSource.filename;
}
+Library.prototype.hashCode = function() {
+ return this.baseSource.filename.hashCode();
+}
+Library.prototype.$eq = function(other) {
+ return (other instanceof Library) && $eq(other.get$baseSource().get$filename(), this.baseSource.filename);
+}
Library.prototype.findTypeByName$1 = Library.prototype.findTypeByName;
+Library.prototype.hashCode$0 = Library.prototype.hashCode;
Library.prototype.resolve$0 = Library.prototype.resolve;
Library.prototype.toString$0 = Library.prototype.toString;
Library.prototype.visitSources$0 = Library.prototype.visitSources;
@@ -4672,7 +4679,12 @@ Member.prototype.get$generatedFactoryName = function() {
}
}
Member.prototype.hashCode = function() {
- return (this.declaringType.hashCode() << 4) ^ this.name.hashCode();
+ var typeCode = this.declaringType == null ? 1 : this.declaringType.hashCode();
+ var nameCode = this.get$isConstructor() ? this.get$constructorName().hashCode() : this.name.hashCode();
+ return (typeCode << 4) ^ nameCode;
+}
+Member.prototype.$eq = function(other) {
+ return (other instanceof Member) && $eq(this.get$isConstructor(), other.get$isConstructor()) && $eq(this.declaringType, other.get$declaringType()) && (this.get$isConstructor() ? this.get$constructorName() == other.get$constructorName() : this.name == other.get$name());
}
Member.prototype._get$3 = Member.prototype._get;
Member.prototype._get$3$isDynamic = Member.prototype._get;
@@ -5345,14 +5357,14 @@ MethodMember.prototype.needsArgumentConversion = function(args) {
return false;
}
MethodMember._argCountMsg = function(actual, expected, atLeast) {
- return 'wrong number of arguments, expected ' + ('' + (atLeast ? "at least " : "") + expected + ' but found ' + actual);
+ return 'wrong number of positional arguments, expected ' + ('' + (atLeast ? "at least " : "") + expected + ' but found ' + actual);
}
-MethodMember.prototype._argError = function(context, node, target, args, msg) {
+MethodMember.prototype._argError = function(context, node, target, args, msg, span) {
if (this.isStatic || this.get$isConstructor()) {
- $globals.world.error(msg, node.span);
+ $globals.world.error(msg, span);
}
else {
- $globals.world.warning(msg, node.span);
+ $globals.world.warning(msg, span);
}
return target.invokeNoSuchMethod(context, this.name, node, args);
}
@@ -5386,7 +5398,7 @@ MethodMember.prototype.invoke = function(context, node, target, args, isDynamic)
var arg = args.values.$index(i);
if (i >= this.parameters.length) {
var msg = MethodMember._argCountMsg(args.get$length(), this.parameters.length, false);
- return this._argError(context, node, target, args, msg);
+ return this._argError(context, node, target, args, msg, args.nodes.$index(i).get$span());
}
arg = arg.convertTo$4(context, this.parameters.$index(i).get$type(), node, isDynamic);
if (this.isConst && arg.get$isConst()) {
@@ -5396,9 +5408,9 @@ MethodMember.prototype.invoke = function(context, node, target, args, isDynamic)
argsCode.add$1(arg.get$code());
}
}
+ var namedArgsUsed = 0;
if (bareCount < this.parameters.length) {
this.genParameterValues();
- var namedArgsUsed = 0;
for (var i = bareCount;
i < this.parameters.length; i++) {
var arg = args.getValue(this.parameters.$index(i).get$name());
@@ -5411,32 +5423,32 @@ MethodMember.prototype.invoke = function(context, node, target, args, isDynamic)
}
if (arg == null || !this.parameters.$index(i).get$isOptional()) {
var msg = MethodMember._argCountMsg(Math.min(i, args.get$length()), i + 1, true);
- return this._argError(context, node, target, args, msg);
+ return this._argError(context, node, target, args, msg, args.nodes.$index(i).get$span());
}
else {
argsCode.add$1(this.isConst && arg.get$isConst() ? arg.get$canonicalCode() : arg.get$code());
}
}
- if (namedArgsUsed < args.get$nameCount()) {
- var seen = new HashSetImplementation();
- for (var i = bareCount;
- i < args.get$length(); i++) {
- var name = args.getName(i);
- if (seen.contains$1(name)) {
- return this._argError(context, node, target, args, ('duplicate argument "' + name + '"'));
- }
- seen.add$1(name);
- var p = this.indexOfParameter(name);
- if (p < 0) {
- return this._argError(context, node, target, args, ('method does not have optional parameter "' + name + '"'));
- }
- else if (p < bareCount) {
- return this._argError(context, node, target, args, ('argument "' + name + '" passed as positional and named'));
- }
+ Arguments.removeTrailingNulls(argsCode);
+ }
+ if (namedArgsUsed < args.get$nameCount()) {
+ var seen = new HashSetImplementation();
+ for (var i = bareCount;
+ i < args.get$length(); i++) {
+ var name = args.getName(i);
+ if (seen.contains$1(name)) {
+ return this._argError(context, node, target, args, ('duplicate argument "' + name + '"'), args.nodes.$index(i).get$span());
+ }
+ seen.add$1(name);
+ var p = this.indexOfParameter(name);
+ if (p < 0) {
+ return this._argError(context, node, target, args, ('method does not have optional parameter "' + name + '"'), args.nodes.$index(i).get$span());
+ }
+ else if (p < bareCount) {
+ return this._argError(context, node, target, args, ('argument "' + name + '" passed as positional and named'), args.nodes.$index(p).get$span());
}
- $globals.world.internalError(('wrong named arguments calling ' + this.name), node.span);
}
- Arguments.removeTrailingNulls(argsCode);
+ $globals.world.internalError(('wrong named arguments calling ' + this.name), node.span);
}
var argsString = Strings.join(argsCode, ', ');
if (this.get$isConstructor()) {
@@ -10835,6 +10847,14 @@ Type.prototype.isSubtypeOf = function(other) {
}
return false;
}
+Type.prototype.hashCode = function() {
+ var libraryCode = this.get$library() == null ? 1 : this.get$library().hashCode();
+ var nameCode = this.name == null ? 1 : this.name.hashCode();
+ return (libraryCode << 4) ^ nameCode;
+}
+Type.prototype.$eq = function(other) {
+ return (other instanceof Type) && $eq(other.get$name(), this.name) && $eq(this.get$library(), other.get$library());
+}
Type._isFunctionSubtypeOf = function(t, s) {
if (!s.returnType.get$isVoid() && !s.returnType.isAssignable(t.returnType)) {
return false;
@@ -10858,6 +10878,7 @@ Type.prototype.getConstructor$1 = Type.prototype.getConstructor;
Type.prototype.getFactory$2 = Type.prototype.getFactory;
Type.prototype.getMember$1 = Type.prototype.getMember;
Type.prototype.getOrMakeConcreteType$1 = Type.prototype.getOrMakeConcreteType;
+Type.prototype.hashCode$0 = Type.prototype.hashCode;
Type.prototype.isAssignable$1 = Type.prototype.isAssignable;
Type.prototype.isSubtypeOf$1 = Type.prototype.isSubtypeOf;
Type.prototype.markUsed$0 = Type.prototype.markUsed;
« no previous file with comments | « frog/member.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698