[cfe] Reinstate access full access to Record when enabled by default

This reinstate the support for access Record from all libraries, opt-in
_and_ opt-out, when 'records' is enabled by default. This was wrongfully
removed in a previous CL.

Change-Id: Iede9257302754ca862edb5573203a251cb7bac9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261647
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Johnni Winther 2022-10-07 10:06:28 +00:00 committed by Commit Queue
parent 9df6656aa9
commit 49b0503702
2 changed files with 11 additions and 2 deletions

View file

@ -411,7 +411,7 @@ abstract class NamedTypeBuilder extends TypeBuilder {
assert(hierarchy != null || isExplicit, "Cannot build $this.");
DartType builtType = _buildAliasedInternal(library, typeUse, hierarchy);
if (library is SourceLibraryBuilder &&
!library.libraryFeatures.records.isEnabled &&
!isRecordAccessAllowed(library.libraryFeatures) &&
isRecordOrItsAlias(builtType)) {
library.reportFeatureNotEnabled(library.libraryFeatures.records,
fileUri ?? library.fileUri, charOffset!, nameText.length);
@ -707,7 +707,7 @@ class _ExplicitNamedTypeBuilder extends NamedTypeBuilder {
DartType builtType = _buildInternal(library, typeUse, hierarchy);
if (library is SourceLibraryBuilder &&
!library.libraryFeatures.records.isEnabled &&
!isRecordAccessAllowed(library.libraryFeatures) &&
isRecordOrItsAlias(builtType)) {
library.reportFeatureNotEnabled(library.libraryFeatures.records,
fileUri ?? library.fileUri, charOffset!, nameText.length);

View file

@ -4,11 +4,20 @@
import 'package:kernel/ast.dart';
import '../../api_prototype/experimental_flags.dart';
abstract class DelayedActionPerformer {
bool get hasDelayedActions;
void performDelayedActions({required bool allowFurtherDelays});
}
/// Returns `true` if access to `Record` from `dart:core` is allowed.
bool isRecordAccessAllowed(LibraryFeatures libraryFeatures) {
return ExperimentalFlag.records.isEnabledByDefault ||
libraryFeatures.records.isEnabled;
}
/// Returns `true` if [type] is `Record` from `dart:core` or an alias of it.
bool isRecordOrItsAlias(DartType type) {
Class? targetClass;
if (type is InterfaceType) {