4cfd3da965
This update the position used for reporting a mixin class primary constructor with a primary constructor by declaration with initializers or an explicit body. Since mixin classes can have simple constructors, it makes more sense to report the error on the offending syntax than on the primary constructor itself. The CL also updates the offset used for field initializers to the field name rather than the `=`. This align the offset with what is used for property sets. Change-Id: Id5ccd55536b2c3b9d9336d2854772c1bcc5a175a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490800 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Erik Ernst <eernst@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
93 lines
3.5 KiB
Plaintext
93 lines
3.5 KiB
Plaintext
library;
|
|
//
|
|
// Problems in library:
|
|
//
|
|
// pkg/front_end/testcases/general/issue43363.dart:10:9: Error: 'this' can't be used as an identifier because it's a keyword.
|
|
// Try renaming this to be an identifier that isn't a keyword.
|
|
// this.y = 2;
|
|
// ^^^^
|
|
//
|
|
// pkg/front_end/testcases/general/issue43363.dart:10:9: Error: A method declaration needs an explicit list of parameters.
|
|
// Try adding a parameter list to the method declaration.
|
|
// this.y = 2;
|
|
// ^^^^
|
|
//
|
|
// pkg/front_end/testcases/general/issue43363.dart:10:16: Error: Only factory constructor can specify '=' redirection.
|
|
// Try making this a factory constructor, or remove the redirection.
|
|
// this.y = 2;
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/general/issue43363.dart:10:18: Error: Expected an identifier, but got '2'.
|
|
// Try inserting an identifier before '2'.
|
|
// this.y = 2;
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/general/issue43363.dart:10:16: Error: Expected ';' after this.
|
|
// this.y = 2;
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/general/issue43363.dart:10:9: Error: The name of a constructor must match the name of the enclosing class.
|
|
// this.y = 2;
|
|
// ^^^^
|
|
//
|
|
// pkg/front_end/testcases/general/issue43363.dart:10:18: Error: Expected a class member, but got '2'.
|
|
// this.y = 2;
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/general/issue43363.dart:10:19: Error: Expected a class member, but got ';'.
|
|
// this.y = 2;
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/general/issue43363.dart:9:14: Error: A redirecting constructor can't have other initializers.
|
|
// this.x = 1;
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/general/issue43363.dart:10:16: Error: Expected a function body or '=>'.
|
|
// Try adding {}.
|
|
// this.y = 2;
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/general/issue43363.dart:10:18: Error: Constructors can't have a return type.
|
|
// Try removing the return type.
|
|
// this.y = 2;
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/general/issue43363.dart:10:9: Error: Final field 'x' is not initialized by this constructor.
|
|
// Try to initialize the field using an initializing formal or a field initializer.
|
|
// this.y = 2;
|
|
// ^
|
|
// pkg/front_end/testcases/general/issue43363.dart:6:13: Context: 'x' is defined here.
|
|
// final int x;
|
|
// ^
|
|
//
|
|
// pkg/front_end/testcases/general/issue43363.dart:10:9: Error: Final field 'y' is not initialized by this constructor.
|
|
// Try to initialize the field using an initializing formal or a field initializer.
|
|
// this.y = 2;
|
|
// ^
|
|
// pkg/front_end/testcases/general/issue43363.dart:7:13: Context: 'y' is defined here.
|
|
// final int y;
|
|
// ^
|
|
//
|
|
import self as self;
|
|
import "dart:core" as core;
|
|
|
|
class E extends core::Object {
|
|
final field core::int x;
|
|
final field core::int y;
|
|
erroneous constructor y() → self::E
|
|
: self::E::y = null, self::E::x = null, super core::Object::•()
|
|
invalid-expression "pkg/front_end/testcases/general/issue43363.dart:10:18: Error: Constructors can't have a return type.
|
|
Try removing the return type.
|
|
this.y = 2;
|
|
^";
|
|
erroneous constructor •() → self::E
|
|
: invalid-initializer "pkg/front_end/testcases/general/issue43363.dart:9:14: Error: A redirecting constructor can't have other initializers.
|
|
this.x = 1;
|
|
^", this self::E::named()
|
|
;
|
|
constructor named() → self::E
|
|
: self::E::x = 5, self::E::y = 6, super core::Object::•()
|
|
;
|
|
}
|
|
static method main() → dynamic {}
|