Files
sdk/pkg/front_end/testcases/rasta/super_initializer.dart.strong.expect
T
Johnni Winther 4cfd3da965 [cfe][PrimaryConstructors] Update reporting for mixin class with initializer/constructor body
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>
2026-04-01 01:17:28 -07:00

49 lines
1.6 KiB
Plaintext

library;
//
// Problems in library:
//
// pkg/front_end/testcases/rasta/super_initializer.dart:15:9: Error: Can't have initializers after 'super'.
// field = 42;
// ^
//
// pkg/front_end/testcases/rasta/super_initializer.dart:18:9: Error: Can't have initializers after 'super'.
// field = 42;
// ^
//
// pkg/front_end/testcases/rasta/super_initializer.dart:21:9: Error: Can't have initializers after 'super'.
// field = 42;
// ^
//
import self as self;
import "dart:core" as core;
class Super extends core::Object {
constructor arg0() → self::Super
: super core::Object::•()
;
constructor arg1(dynamic a) → self::Super
: super core::Object::•()
;
constructor arg2(dynamic a, dynamic b) → self::Super
: super core::Object::•()
;
}
class Sub extends self::Super {
field dynamic field;
erroneous constructor arg0() → self::Sub
: invalid-initializer "pkg/front_end/testcases/rasta/super_initializer.dart:15:9: Error: Can't have initializers after 'super'.
field = 42;
^", super self::Super::arg0()
;
erroneous constructor arg1(dynamic a) → self::Sub
: invalid-initializer "pkg/front_end/testcases/rasta/super_initializer.dart:18:9: Error: Can't have initializers after 'super'.
field = 42;
^", super self::Super::arg1(a)
;
erroneous constructor arg2(dynamic a, dynamic b) → self::Sub
: invalid-initializer "pkg/front_end/testcases/rasta/super_initializer.dart:21:9: Error: Can't have initializers after 'super'.
field = 42;
^", super self::Super::arg2(a, b)
;
}