mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:45:06 +00:00
Unify four diagnostic codes for the purpose of documentation
I would have prefered to have renamed them all to undefined_super_member, but that would have broken existing links. Some day we should add the support necessary to allow for forwarding so that we can rename codes. Change-Id: I81e416407e3464b5b60a4dbbfe60a375eb47bb84 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157921 Commit-Queue: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
7a8b267a39
commit
e224540b1c
|
@ -9633,19 +9633,19 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
|
|||
hasPublishedDocs: true);
|
||||
|
||||
/**
|
||||
* 12.17 Getter Invocation: Let <i>T</i> be the static type of <i>e</i>. It is
|
||||
* a static type warning if <i>T</i> does not have a getter named <i>m</i>.
|
||||
*
|
||||
* Parameters:
|
||||
* 0: the name of the getter
|
||||
* 1: the name of the enclosing type where the getter is being looked for
|
||||
*/
|
||||
static const CompileTimeErrorCode UNDEFINED_SUPER_GETTER =
|
||||
CompileTimeErrorCode('UNDEFINED_SUPER_GETTER',
|
||||
CompileTimeErrorCodeWithUniqueName(
|
||||
'UNDEFINED_SUPER_MEMBER',
|
||||
'UNDEFINED_SUPER_GETTER',
|
||||
"The getter '{0}' isn't defined in a superclass of '{1}'.",
|
||||
correction:
|
||||
"Try correcting the name to the name of an existing getter, or "
|
||||
"defining a getter or field named '{0}' in a superclass.");
|
||||
"defining a getter or field named '{0}' in a superclass.",
|
||||
hasPublishedDocs: true);
|
||||
|
||||
/**
|
||||
* Parameters:
|
||||
|
@ -9654,14 +9654,14 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
|
|||
*/
|
||||
// #### Description
|
||||
//
|
||||
// The analyzer produces this diagnostic when an inherited method is
|
||||
// referenced using `super`, but there’s no method with that name in the
|
||||
// The analyzer produces this diagnostic when an inherited member is
|
||||
// referenced using `super`, but there’s no member with that name in the
|
||||
// superclass chain.
|
||||
//
|
||||
// #### Examples
|
||||
//
|
||||
// The following code produces this diagnostic because `Object` doesn't define
|
||||
// a member named `n`:
|
||||
// a method named `n`:
|
||||
//
|
||||
// ```dart
|
||||
// class C {
|
||||
|
@ -9671,18 +9671,31 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
|
|||
// }
|
||||
// ```
|
||||
//
|
||||
// The following code produces this diagnostic because `Object` doesn't define
|
||||
// a getter named `g`:
|
||||
//
|
||||
// ```dart
|
||||
// class C {
|
||||
// void m() {
|
||||
// super.[!g!];
|
||||
// }
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// #### Common fixes
|
||||
//
|
||||
// If the inherited method you intend to invoke has a different name, then
|
||||
// make the name of the invoked method match the inherited method.
|
||||
// If the inherited member you intend to invoke has a different name, then
|
||||
// make the name of the invoked member match the inherited member.
|
||||
//
|
||||
// If the method you intend to invoke is defined in the same class, then
|
||||
// If the member you intend to invoke is defined in the same class, then
|
||||
// remove the `super.`.
|
||||
//
|
||||
// If not, then either add the method to one of the superclasses or remove the
|
||||
// If not, then either add the member to one of the superclasses or remove the
|
||||
// invocation.
|
||||
static const CompileTimeErrorCode UNDEFINED_SUPER_METHOD =
|
||||
CompileTimeErrorCode('UNDEFINED_SUPER_METHOD',
|
||||
CompileTimeErrorCodeWithUniqueName(
|
||||
'UNDEFINED_SUPER_MEMBER',
|
||||
'UNDEFINED_SUPER_METHOD',
|
||||
"The method '{0}' isn't defined in a superclass of '{1}'.",
|
||||
correction:
|
||||
"Try correcting the name to the name of an existing method, or "
|
||||
|
@ -9690,45 +9703,32 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
|
|||
hasPublishedDocs: true);
|
||||
|
||||
/**
|
||||
* 12.18 Assignment: Evaluation of an assignment of the form
|
||||
* <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] = <i>e<sub>3</sub></i> is
|
||||
* equivalent to the evaluation of the expression (a, i, e){a.[]=(i, e);
|
||||
* return e;} (<i>e<sub>1</sub></i>, <i>e<sub>2</sub></i>,
|
||||
* <i>e<sub>2</sub></i>).
|
||||
*
|
||||
* 12.29 Assignable Expressions: An assignable expression of the form
|
||||
* <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] is evaluated as a method
|
||||
* invocation of the operator method [] on <i>e<sub>1</sub></i> with argument
|
||||
* <i>e<sub>2</sub></i>.
|
||||
*
|
||||
* 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>.
|
||||
* It is a static type warning if <i>T</i> does not have an accessible
|
||||
* instance member named <i>m</i>.
|
||||
*
|
||||
* Parameters:
|
||||
* 0: the name of the operator
|
||||
* 1: the name of the enclosing type where the operator is being looked for
|
||||
*/
|
||||
static const CompileTimeErrorCode UNDEFINED_SUPER_OPERATOR =
|
||||
CompileTimeErrorCode('UNDEFINED_SUPER_OPERATOR',
|
||||
CompileTimeErrorCodeWithUniqueName(
|
||||
'UNDEFINED_SUPER_MEMBER',
|
||||
'UNDEFINED_SUPER_OPERATOR',
|
||||
"The operator '{0}' isn't defined in a superclass of '{1}'.",
|
||||
correction: "Try defining the operator '{0}' in a superclass.");
|
||||
correction: "Try defining the operator '{0}' in a superclass.",
|
||||
hasPublishedDocs: true);
|
||||
|
||||
/**
|
||||
* 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>.
|
||||
* It is a static type warning if <i>T</i> does not have an accessible
|
||||
* instance setter named <i>v=</i>.
|
||||
*
|
||||
* Parameters:
|
||||
* 0: the name of the setter
|
||||
* 1: the name of the enclosing type where the setter is being looked for
|
||||
*/
|
||||
static const CompileTimeErrorCode UNDEFINED_SUPER_SETTER =
|
||||
CompileTimeErrorCode('UNDEFINED_SUPER_SETTER',
|
||||
CompileTimeErrorCodeWithUniqueName(
|
||||
'UNDEFINED_SUPER_MEMBER',
|
||||
'UNDEFINED_SUPER_SETTER',
|
||||
"The setter '{0}' isn't defined in a superclass of '{1}'.",
|
||||
correction:
|
||||
"Try correcting the name to the name of an existing setter, or "
|
||||
"defining a setter or field named '{0}' in a superclass.");
|
||||
"defining a setter or field named '{0}' in a superclass.",
|
||||
hasPublishedDocs: true);
|
||||
|
||||
/**
|
||||
* 12.15.1 Ordinary Invocation: It is a static type warning if <i>T</i> does
|
||||
|
|
|
@ -7808,20 +7808,26 @@ import 'dart:math' show min;
|
|||
var x = min(0, 1);
|
||||
{% endprettify %}
|
||||
|
||||
### undefined_super_method
|
||||
### undefined_super_member
|
||||
|
||||
_The getter '{0}' isn't defined in a superclass of '{1}'._
|
||||
|
||||
_The method '{0}' isn't defined in a superclass of '{1}'._
|
||||
|
||||
_The operator '{0}' isn't defined in a superclass of '{1}'._
|
||||
|
||||
_The setter '{0}' isn't defined in a superclass of '{1}'._
|
||||
|
||||
#### Description
|
||||
|
||||
The analyzer produces this diagnostic when an inherited method is
|
||||
referenced using `super`, but there’s no method with that name in the
|
||||
The analyzer produces this diagnostic when an inherited member is
|
||||
referenced using `super`, but there’s no member with that name in the
|
||||
superclass chain.
|
||||
|
||||
#### Examples
|
||||
|
||||
The following code produces this diagnostic because `Object` doesn't define
|
||||
a member named `n`:
|
||||
a method named `n`:
|
||||
|
||||
{% prettify dart tag=pre+code %}
|
||||
class C {
|
||||
|
@ -7831,15 +7837,26 @@ class C {
|
|||
}
|
||||
{% endprettify %}
|
||||
|
||||
The following code produces this diagnostic because `Object` doesn't define
|
||||
a getter named `g`:
|
||||
|
||||
{% prettify dart tag=pre+code %}
|
||||
class C {
|
||||
void m() {
|
||||
super.[!g!];
|
||||
}
|
||||
}
|
||||
{% endprettify %}
|
||||
|
||||
#### Common fixes
|
||||
|
||||
If the inherited method you intend to invoke has a different name, then
|
||||
make the name of the invoked method match the inherited method.
|
||||
If the inherited member you intend to invoke has a different name, then
|
||||
make the name of the invoked member match the inherited member.
|
||||
|
||||
If the method you intend to invoke is defined in the same class, then
|
||||
If the member you intend to invoke is defined in the same class, then
|
||||
remove the `super.`.
|
||||
|
||||
If not, then either add the method to one of the superclasses or remove the
|
||||
If not, then either add the member to one of the superclasses or remove the
|
||||
invocation.
|
||||
|
||||
### unnecessary_cast
|
||||
|
@ -8525,3 +8542,7 @@ class C<E> {}
|
|||
|
||||
void f(C<int> x) {}
|
||||
{% endprettify %}
|
||||
|
||||
### undefined_super_method
|
||||
|
||||
See [undefined_super_member](#undefined-super-member).
|
||||
|
|
|
@ -161,6 +161,7 @@ class DocumentationGenerator {
|
|||
_writeHeader(sink);
|
||||
_writeGlossary(sink);
|
||||
_writeDiagnostics(sink);
|
||||
_writeForwards(sink);
|
||||
}
|
||||
|
||||
/// Extract documentation from all of the files containing the definitions of
|
||||
|
@ -382,6 +383,17 @@ that might work in unexpected ways.
|
|||
}
|
||||
}
|
||||
|
||||
/// Write the forwarding documentation for all of the diagnostics that have
|
||||
/// been renamed.
|
||||
void _writeForwards(StringSink sink) {
|
||||
sink.write('''
|
||||
|
||||
### undefined_super_method
|
||||
|
||||
See [undefined_super_member](#undefined-super-member).
|
||||
''');
|
||||
}
|
||||
|
||||
/// Write the glossary.
|
||||
void _writeGlossary(StringSink sink) {
|
||||
sink.write('''
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import "package:expect/expect.dart";
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
|
||||
// [cfe] Superclass has no setter named 'foo'.
|
||||
import "super_dependency_lib.dart" deferred as lib;
|
||||
|
||||
|
|
|
@ -11,22 +11,22 @@ class P0 {
|
|||
super.toString();
|
||||
super.foo();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_METHOD
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
|
||||
// [cfe] Superclass has no method named 'foo'.
|
||||
super.bar = 100;
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
|
||||
// [cfe] Superclass has no setter named 'bar'.
|
||||
|
||||
void inner() {
|
||||
super.toString();
|
||||
super.foo();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_METHOD
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
|
||||
// [cfe] Superclass has no method named 'foo'.
|
||||
super.bar = 100;
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
|
||||
// [cfe] Superclass has no setter named 'bar'.
|
||||
}
|
||||
inner();
|
||||
|
@ -35,11 +35,11 @@ class P0 {
|
|||
super.toString();
|
||||
super.foo();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_METHOD
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
|
||||
// [cfe] Superclass has no method named 'foo'.
|
||||
super.bar = 100;
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
|
||||
// [cfe] Superclass has no setter named 'bar'.
|
||||
})();
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import "package:expect/expect.dart";
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
|
||||
// [cfe] Superclass has no setter named 'foo'.
|
||||
import "super_dependency_lib.dart" deferred as lib;
|
||||
|
||||
|
|
|
@ -11,22 +11,22 @@ class P0 {
|
|||
super.toString();
|
||||
super.foo();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_METHOD
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
|
||||
// [cfe] Superclass has no method named 'foo'.
|
||||
super.bar = 100;
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
|
||||
// [cfe] Superclass has no setter named 'bar'.
|
||||
|
||||
void inner() {
|
||||
super.toString();
|
||||
super.foo();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_METHOD
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
|
||||
// [cfe] Superclass has no method named 'foo'.
|
||||
super.bar = 100;
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
|
||||
// [cfe] Superclass has no setter named 'bar'.
|
||||
}
|
||||
inner();
|
||||
|
@ -35,11 +35,11 @@ class P0 {
|
|||
super.toString();
|
||||
super.foo();
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_METHOD
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
|
||||
// [cfe] Superclass has no method named 'foo'.
|
||||
super.bar = 100;
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_SETTER
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_SUPER_MEMBER
|
||||
// [cfe] Superclass has no setter named 'bar'.
|
||||
})();
|
||||
|
||||
|
|
Loading…
Reference in a new issue