Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2861. Hide public extension methods if an import is deferred #2866

Merged
merged 1 commit into from
Sep 11, 2024
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
38 changes: 28 additions & 10 deletions LanguageFeatures/Parts-with-imports/scope_A05_t01_part1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,39 @@

part of 'scope_A05_t01.dart';

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

part 'scope_A05_t01_part2.dart';

testPart1() async {
// If a deferred library is not loaded then an attempt to access its members
// is a runtime error. But it's also possible that if some configuration
// doesn't support deferred loading then it'll be not an error.
Expect.throws(() {print(l1.libVar);});
Expect.throws(() {print(l1.libGetter);});
Expect.throws(() {l1.libSetter = "x";});
Expect.throws(() {print(l1.libFunc);});
Expect.throws(() {print(l1.LibClass.id);});
Expect.throws(() {print(l1.LibMixin.id);});
Expect.throws(() {print(l1.LibEnum.id);});
Expect.throws(() {print(l1.LibExt.id);});
Expect.throws(() {print(l1.LibET.id);});
try {
Expect.equals("scope_lib1 libVar", l1.libVar);
} catch (_) {}
try {
Expect.equals("scope_lib1 libGetter", l1.libGetter);
} catch (_) {}
try {
l1.libSetter = "x";
} catch (_) {}
try {
Expect.equals("scope_lib1 libFunc", l1.libFunc);
} catch (_) {}
try {
Expect.equals("scope_lib1 LibClass", l1.LibClass.id);
} catch (_) {}
try {
Expect.equals("scope_lib1 LibMixin", l1.LibMixin.id);
} catch (_) {}
try {
Expect.equals("scope_lib1 LibEnum", l1.LibEnum.id);
} catch (_) {}
try {
Expect.equals("scope_lib1 LibET", l1.LibET.id);
} catch (_) {}

await l1.loadLibrary();

Expand All @@ -42,7 +61,6 @@ testPart1() async {
Expect.equals("scope_lib1 LibClass", l1.LibClass.id);
Expect.equals("scope_lib1 LibMixin", l1.LibMixin.id);
Expect.equals("scope_lib1 LibEnum", l1.LibEnum.id);
Expect.equals("scope_lib1 LibExt", l1.LibExt.id);
Expect.equals("scope_lib1 LibET", l1.LibET.id);

await l1.loadLibrary(); // Not an error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ testPart2() async {
Expect.equals("scope_lib1 LibClass", l1.LibClass.id);
Expect.equals("scope_lib1 LibMixin", l1.LibMixin.id);
Expect.equals("scope_lib1 LibEnum", l1.LibEnum.id);
Expect.equals("scope_lib1 LibExt", l1.LibExt.id);
Expect.equals("scope_lib1 LibET", l1.LibET.id);

// From scope_lib2.dart
Expand Down