Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions LanguageFeatures/Parts-with-imports/scope_A06_t02_part2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,4 @@ testPart2() async {
Expect.equals("scope_lib1 LibMixin", l.LibMixin.id);
Expect.equals("scope_lib1 LibEnum", l.LibEnum.id);
Expect.equals("scope_lib1 LibET", l.LibET.id);
// From parts_lib.dart
Expect.equals(0, l.counter);
}
2 changes: 2 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A06_t03_part2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ testPart2() async {
l.libVar; // l is not loaded
});
await l.loadLibrary();
// `libVar` is also defined in parts_lib.dart imported in `_part1` as `l`. But
// it is shadowed by the import in this part.
Expect.equals("scope_lib1 libVar", l.libVar);
}
34 changes: 34 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A06_t04.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2025, 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 Let `P`, the combined import scope of `F`, be a scope with `I` as
/// enclosing scope and a namespace containing every import prefix declared by
/// an import declaration of `F`.
/// ...
/// - If `Pname` is not `deferred`, and the enclosing scope in `C` has a
/// non-deferred prefix import scope with the same name, `Cname`, then the
/// enclosing scope of `Pname` is `Cname`. A part file can have an import with
/// the same prefix as a prefix that it inherits. The new import's
/// declarations will all be available through the prefix, but any declaration
/// of the inherited prefix which isn't shadowed by a new import, will also be
/// available. The imported declarations will shadow the parent file's import
/// scope declarations, just like imports in the top-level import scope will
/// shadow top-level imports with the same name inherited from parent files.
///
/// Deferred prefix scopes always correspond to a single import directive, in
/// a single library, which can be loaded independently of any other import.
///
/// @description Check that a part file can use the same deferred import prefix
/// as one it inherits. In this case, it shadows the inherited declarations, and
/// it is a compile-time error to access the shadowed declaration.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=enhanced-parts

part 'scope_A06_t04_part1.dart';

main() async {
await testPart1();
await testPart2();
}
37 changes: 37 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A06_t04_part1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) 2025, 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 Let `P`, the combined import scope of `F`, be a scope with `I` as
/// enclosing scope and a namespace containing every import prefix declared by
/// an import declaration of `F`.
/// ...
/// - If `Pname` is not `deferred`, and the enclosing scope in `C` has a
/// non-deferred prefix import scope with the same name, `Cname`, then the
/// enclosing scope of `Pname` is `Cname`. A part file can have an import with
/// the same prefix as a prefix that it inherits. The new import's
/// declarations will all be available through the prefix, but any declaration
/// of the inherited prefix which isn't shadowed by a new import, will also be
/// available. The imported declarations will shadow the parent file's import
/// scope declarations, just like imports in the top-level import scope will
/// shadow top-level imports with the same name inherited from parent files.
///
/// Deferred prefix scopes always correspond to a single import directive, in
/// a single library, which can be loaded independently of any other import.
///
/// @description Check that a part file can use the same deferred import prefix
/// as one it inherits. In this case, it shadows the inherited declarations, and
/// it is a compile-time error to access the shadowed declaration.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=enhanced-parts

part of 'scope_A06_t04.dart';

import 'parts_lib.dart' deferred as l hide LibExt;

part 'scope_A06_t04_part2.dart';

testPart1() async {
await l.loadLibrary();
}
39 changes: 39 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A06_t04_part2.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) 2025, 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 Let `P`, the combined import scope of `F`, be a scope with `I` as
/// enclosing scope and a namespace containing every import prefix declared by
/// an import declaration of `F`.
/// ...
/// - If `Pname` is not `deferred`, and the enclosing scope in `C` has a
/// non-deferred prefix import scope with the same name, `Cname`, then the
/// enclosing scope of `Pname` is `Cname`. A part file can have an import with
/// the same prefix as a prefix that it inherits. The new import's
/// declarations will all be available through the prefix, but any declaration
/// of the inherited prefix which isn't shadowed by a new import, will also be
/// available. The imported declarations will shadow the parent file's import
/// scope declarations, just like imports in the top-level import scope will
/// shadow top-level imports with the same name inherited from parent files.
///
/// Deferred prefix scopes always correspond to a single import directive, in
/// a single library, which can be loaded independently of any other import.
///
/// @description Check that a part file can use the same deferred import prefix
/// as one it inherits. In this case, it shadows the inherited declarations, and
/// it is a compile-time error to access the shadowed declaration.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=enhanced-parts

part of 'scope_A06_t04_part1.dart';

import 'scope_lib1.dart' deferred as l hide LibExt;

testPart2() async {
await l.loadLibrary();
l.counter; // From parts_lib.dart
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}