blob: a53d6cfe43f40799ef06d32b898b513eed10ebc5 [file] [log] [blame]
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// @assertion A record type declares all of the members defined on [Object]. It
/// also exposes getters for each named field where the name of the getter is
/// the field's name and the getter's type is the field's type. For each
/// positional field, it exposes a getter whose name is $ followed by the number
/// of preceding positional fields and whose type is the type of the field.
///
/// @description Checks that a named field only exposes a getter. There
/// are no setters with the same name
/// @author sgrekhov22@gmail.com
typedef R = (int a, String, {int x, int y});
extension ER on R {
int get x => 42;
int get y => 21;
void set x(int val) {}
void set y(int val) {}
}
main() {
R r1 = (1, "", x: 3, y: 4);
r1.x = 0;
// ^
// [analyzer] unspecified
// [cfe] unspecified
r1.y = 0;
// ^
// [analyzer] unspecified
// [cfe] unspecified
(name: "pi", value: 3.14).value = 42;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
(name: "pi", value: 3.14).name = "e";
// ^^^^
// [analyzer] unspecified
// [cfe] unspecified
}