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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/warnings.dart

Issue 51843005: Emit a compile-time error when using default values in a redirecting factory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Language status changes. Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 dart2js; 5 part of dart2js;
6 6
7 const DONT_KNOW_HOW_TO_FIX = ""; 7 const DONT_KNOW_HOW_TO_FIX = "";
8 8
9 /** 9 /**
10 * The messages in this file should meet the following guide lines: 10 * The messages in this file should meet the following guide lines:
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 main() { 637 main() {
638 F f; 638 F f;
639 }""", """ 639 }""", """
640 typedef void F({int arg: 0}); 640 typedef void F({int arg: 0});
641 641
642 main() { 642 main() {
643 F f; 643 F f;
644 }"""]); 644 }"""]);
645 645
646 static const MessageKind FUNCTION_TYPE_FORMAL_WITH_DEFAULT = const MessageKind ( 646 static const MessageKind FUNCTION_TYPE_FORMAL_WITH_DEFAULT = const MessageKind (
647 "Error: A function type parameters can't specify a default value.", 647 "Error: A function type parameter can't specify a default value.",
648 howToFix: 648 howToFix:
649 "Try removing the default value.", 649 "Try removing the default value.",
650 examples: const [""" 650 examples: const ["""
651 foo(f(int i, [a = 1])) {} 651 foo(f(int i, [a = 1])) {}
652 652
653 main() { 653 main() {
654 foo(1, 2); 654 foo(1, 2);
655 }""", """ 655 }""", """
656 foo(f(int i, {a: 1})) {} 656 foo(f(int i, {a: 1})) {}
657 657
658 main() { 658 main() {
659 foo(1, a: 2); 659 foo(1, a: 2);
660 }"""]); 660 }"""]);
661 661
662 static const MessageKind REDIRECTING_FACTORY_WITH_DEFAULT = const MessageKind(
663 "Error: A parameter of a redirecting factory constructor can't specify a "
664 "default value.",
665 howToFix:
666 "Try removing the default value.",
667 examples: const ["""
668 class A {
669 A([a]);
670 factory A.foo([a = 1]) = A;
671 }
672
673 main() {
674 new A.foo(1);
675 }""", """
676 class A {
677 A({a});
678 factory A.foo({a: 1}) = A;
679 }
680
681 main() {
682 new A.foo(a: 1);
683 }"""]);
684
662 static const MessageKind FORMAL_DECLARED_CONST = const MessageKind( 685 static const MessageKind FORMAL_DECLARED_CONST = const MessageKind(
663 "Error: A formal parameter can't be declared const.", 686 "Error: A formal parameter can't be declared const.",
664 howToFix: "Try removing 'const'.", 687 howToFix: "Try removing 'const'.",
665 examples: const [""" 688 examples: const ["""
666 foo(const x) {} 689 foo(const x) {}
667 main() => foo(42); 690 main() => foo(42);
668 """, """ 691 """, """
669 foo({const x}) {} 692 foo({const x}) {}
670 main() => foo(42); 693 main() => foo(42);
671 """, """ 694 """, """
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 1555
1533 class CompileTimeConstantError extends Diagnostic { 1556 class CompileTimeConstantError extends Diagnostic {
1534 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse) 1557 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse)
1535 : super(kind, arguments, terse); 1558 : super(kind, arguments, terse);
1536 } 1559 }
1537 1560
1538 class CompilationError extends Diagnostic { 1561 class CompilationError extends Diagnostic {
1539 CompilationError(MessageKind kind, Map arguments, bool terse) 1562 CompilationError(MessageKind kind, Map arguments, bool terse)
1540 : super(kind, arguments, terse); 1563 : super(kind, arguments, terse);
1541 } 1564 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/resolution/members.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698