[tests] Add regression tests for identifiers

Issue: https://github.com/dart-lang/sdk/issues/52431
Issue: https://github.com/dart-lang/sdk/issues/39595
Change-Id: Iae9c02ad632264d1eb14fb0958f714b4faee55b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304262
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Nicholas Shahan 2023-05-18 20:33:20 +00:00 committed by Commit Queue
parent 327a680c34
commit 5091631de1
5 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1 @@
final fromFalse = 'from a library named "false"';

View file

@ -0,0 +1 @@
final fromNull = 'from a library named "null"';

View file

@ -0,0 +1,19 @@
// 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/39595.
///
/// Libraries with the names 'true', 'false', and 'null' should not shadow
/// those terms.
import 'package:expect/expect.dart';
import 'true.dart';
import 'false.dart';
import 'null.dart';
main() {
Expect.equals('from a library named "true"', fromTrue);
Expect.equals('from a library named "false"', fromFalse);
Expect.equals('from a library named "null"', fromNull);
}

View file

@ -0,0 +1 @@
final fromTrue = 'from a library named "true"';

View file

@ -0,0 +1,37 @@
// 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/52431.
///
/// Type parameters can shadow the core Object type. This was causing a crash
/// in DDC compiled code because it was shadowing the native JavaScript Object.
import 'package:expect/expect.dart';
import 'dart:core' as core;
// Applying a mixin with a class cycle causes a crash when trying to walk up the
// prototype chain using `Object.getPrototypeOf()`.
class A<Object> extends B with C<A> {
get extractType => Object;
// Calling super here caused a crash when trying to walk up the prototype
// chain using `Object.getPrototypeOf()`.
A() : super();
}
class B {
final core.int bar;
B() : bar = 0;
}
mixin C<T> {}
void main() {
var a = A();
Expect.notEquals(core.Object, a.extractType);
a = A<core.Object>();
Expect.equals(core.Object, a.extractType);
}