Skip to content

Commit f91e5d7

Browse files
authored
#1399. [Records] Allow legacy libraries that don't support records to still be able to see the Record class in "dart:core" (#1571)
1 parent e56c6c3 commit f91e5d7

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// @description Non-legacy library for interaction with legacy ones
6+
/// @author [email protected]
7+
8+
// SharedOptions=--enable-experiment=records
9+
10+
library interaction_with_legacy_2_lib;
11+
import "dart:core" as core;
12+
13+
typedef Record = core.Record;

LanguageFeatures/Records/interaction_with_legacy_A01_t01.dart

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,27 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
/// @assertion Assuming that v is the language version in which records are
6-
/// released, the following errors apply.
5+
/// @assertion The records feature is language versioned, as usual with new Dart
6+
/// features. This means that it will be an error to use the syntax for records
7+
/// in libraries which do not have a language version greater than or equal to
8+
/// the language version in which records are released.
79
///
8-
/// It is an error for the identifier [Record], denoting the [Record] class from
9-
/// dart:core, where that import scope name is only imported from platform
10-
/// libraries, to appear in a library whose language version is less than v.
11-
///
12-
/// @description Check that it is a compile-time error if class [Record] from
13-
/// dart:core is used in a library whose language version is less than v.
10+
/// @description Check that it is not an error if class [Record] from dart:core
11+
/// is used in a library whose language version is less than language version in
12+
/// which records are released.
1413
/// @author [email protected]
1514
1615
// SharedOptions=--enable-experiment=records
1716

1817
// @dart = 2.18
1918

19+
import "interaction_with_legacy_A01_lib.dart";
20+
2021
typedef T1 = Record;
21-
// ^^^^^^
22-
// [analyzer] unspecified
23-
// [cfe] unspecified
2422

2523
T? foo<T>(T? t) => t;
2624

2725
main() {
2826
Record? r = null;
29-
//^^^^^^
30-
// [analyzer] unspecified
31-
// [cfe] unspecified
3227
foo<Record>(null);
33-
// ^^^^^^
34-
// [analyzer] unspecified
35-
// [cfe] unspecified
3628
}

0 commit comments

Comments
 (0)