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

Side by Side Diff: pkg/front_end/lib/src/fasta/source/outline_builder.dart

Issue 2782843002: Complain about bad operator parameters. (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library fasta.outline_builder; 5 library fasta.outline_builder;
6 6
7 import 'package:kernel/ast.dart' show AsyncMarker, ProcedureKind; 7 import 'package:kernel/ast.dart' show AsyncMarker, ProcedureKind;
8 8
9 import '../fasta_codes.dart' show FastaMessage, codeExpectedBlockToSkip; 9 import '../fasta_codes.dart' show FastaMessage, codeExpectedBlockToSkip;
10 10
(...skipping 13 matching lines...) Expand all
24 24
25 import '../modifier.dart' show Modifier; 25 import '../modifier.dart' show Modifier;
26 26
27 import 'source_library_builder.dart' show SourceLibraryBuilder; 27 import 'source_library_builder.dart' show SourceLibraryBuilder;
28 28
29 import 'unhandled_listener.dart' show NullValue, Unhandled, UnhandledListener; 29 import 'unhandled_listener.dart' show NullValue, Unhandled, UnhandledListener;
30 30
31 import '../parser/dart_vm_native.dart' 31 import '../parser/dart_vm_native.dart'
32 show removeNativeClause, skipNativeClause; 32 show removeNativeClause, skipNativeClause;
33 33
34 import '../operator.dart' show Operator, operatorFromString, operatorToString; 34 import '../operator.dart'
35 show
36 Operator,
37 operatorFromString,
38 operatorToString,
39 operatorRequiredArgumentCount;
35 40
36 import '../quote.dart' show unescapeString; 41 import '../quote.dart' show unescapeString;
37 42
38 enum MethodBody { 43 enum MethodBody {
39 Abstract, 44 Abstract,
40 Regular, 45 Regular,
41 RedirectingFactoryBody, 46 RedirectingFactoryBody,
42 } 47 }
43 48
44 AsyncMarker asyncMarkerFromTokens(Token asyncToken, Token starToken) { 49 AsyncMarker asyncMarkerFromTokens(Token asyncToken, Token starToken) {
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 int charOffset = pop(); 367 int charOffset = pop();
363 dynamic nameOrOperator = pop(); 368 dynamic nameOrOperator = pop();
364 if (Operator.subtract == nameOrOperator && formals == null) { 369 if (Operator.subtract == nameOrOperator && formals == null) {
365 nameOrOperator = Operator.unaryMinus; 370 nameOrOperator = Operator.unaryMinus;
366 } 371 }
367 String name; 372 String name;
368 ProcedureKind kind; 373 ProcedureKind kind;
369 if (nameOrOperator is Operator) { 374 if (nameOrOperator is Operator) {
370 name = operatorToString(nameOrOperator); 375 name = operatorToString(nameOrOperator);
371 kind = ProcedureKind.Operator; 376 kind = ProcedureKind.Operator;
377 int requiredArgumentCount = operatorRequiredArgumentCount(nameOrOperator);
378 if ((formals?.length ?? 0) != requiredArgumentCount) {
379 library.addCompileTimeError(
380 charOffset,
381 "Operator '$name' must have exactly $requiredArgumentCount "
382 "parameters.");
383 } else {
384 if (formals != null) {
385 for (FormalParameterBuilder formal in formals) {
386 if (!formal.isRequired) {
387 library.addCompileTimeError(formal.charOffset,
388 "An operator can't have optional parameters.");
389 }
390 }
391 }
392 }
372 } else { 393 } else {
373 name = nameOrOperator; 394 name = nameOrOperator;
374 kind = computeProcedureKind(getOrSet); 395 kind = computeProcedureKind(getOrSet);
375 } 396 }
376 TypeBuilder returnType = pop(); 397 TypeBuilder returnType = pop();
377 int modifiers = 398 int modifiers =
378 Modifier.validate(pop(), isAbstract: bodyKind == MethodBody.Abstract); 399 Modifier.validate(pop(), isAbstract: bodyKind == MethodBody.Abstract);
379 List<MetadataBuilder> metadata = pop(); 400 List<MetadataBuilder> metadata = pop();
380 library.addProcedure( 401 library.addProcedure(
381 metadata, 402 metadata,
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 Link<Token> handleMemberName(Link<Token> identifiers) { 818 Link<Token> handleMemberName(Link<Token> identifiers) {
798 if (!isDartLibrary || identifiers.isEmpty) return identifiers; 819 if (!isDartLibrary || identifiers.isEmpty) return identifiers;
799 return removeNativeClause(identifiers); 820 return removeNativeClause(identifiers);
800 } 821 }
801 822
802 @override 823 @override
803 void debugEvent(String name) { 824 void debugEvent(String name) {
804 // printEvent(name); 825 // printEvent(name);
805 } 826 }
806 } 827 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698