mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:09:49 +00:00
4bebe882be
Some named elements were colliding with existing properties on record object instances. Use a symbol in the runtime library for the shape and values properties. Ensure that the `.constructor` and `.prototype` getters are renamed to match the expectation when compiling the access. Add regression test for all 4 named elements. Fixes: https://github.com/dart-lang/sdk/issues/54375 Change-Id: I7f3577455bfcff7dece6350e8c7e3ee7ffdbbac6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342703 Reviewed-by: Sigmund Cherem <sigmund@google.com> Commit-Queue: Nicholas Shahan <nshahan@google.com> Reviewed-by: Mark Zhou <markzipan@google.com>
39 lines
1 KiB
Dart
39 lines
1 KiB
Dart
// Copyright (c) 2023, 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.
|
|
|
|
/// Regression test for https://github.com/dart-lang/sdk/issues/54375.
|
|
///
|
|
/// Records should support named elements with the names 'shape', 'values',
|
|
/// 'constructor', and 'prototype'.
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
@pragma('dart2js:noInline')
|
|
@pragma('dart2js:assumeDynamic')
|
|
confuse(x) {
|
|
return x;
|
|
}
|
|
|
|
void main() {
|
|
var r = (shape: 123);
|
|
Expect.equals(123, r.shape);
|
|
var d = confuse(r);
|
|
Expect.equals(123, d.shape);
|
|
|
|
var r2 = (values: 'hello');
|
|
Expect.equals('hello', r2.values);
|
|
d = confuse(r2);
|
|
Expect.equals('hello', d.values);
|
|
|
|
var r3 = (constructor: Duration.zero);
|
|
Expect.equals(Duration.zero, r3.constructor);
|
|
d = confuse(r3);
|
|
Expect.equals(Duration.zero, d.constructor);
|
|
|
|
var r4 = (prototype: null);
|
|
Expect.equals(null, r4.prototype);
|
|
d = confuse(r4);
|
|
Expect.equals(null, d.prototype);
|
|
}
|