Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b776411

Browse files
author
Dart CI
committed
Version 2.13.0-110.0.dev
Merge commit '3f5694c8277ad181fca994e660bf0c7a7169571a' into 'dev'
2 parents f4b051e + 3f5694c commit b776411

File tree

10 files changed

+150
-82
lines changed

10 files changed

+150
-82
lines changed

pkg/analysis_server/lib/src/computer/computer_signature.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ class DartUnitSignatureComputer {
4949
final args = argsNode;
5050
String name;
5151
ExecutableElement execElement;
52-
if (args.parent is MethodInvocation) {
53-
MethodInvocation method = args.parent;
54-
name = method.methodName.name;
55-
execElement = ElementLocator.locate(method) as ExecutableElement;
56-
} else if (args.parent is InstanceCreationExpression) {
57-
InstanceCreationExpression constructor = args.parent;
58-
name = constructor.constructorName.type.name.name;
59-
if (constructor.constructorName.name != null) {
60-
name += '.${constructor.constructorName.name.name}';
52+
final parent = args.parent;
53+
if (parent is MethodInvocation) {
54+
name = parent.methodName.name;
55+
var element = ElementLocator.locate(parent);
56+
execElement = element is ExecutableElement ? element : null;
57+
} else if (parent is InstanceCreationExpression) {
58+
name = parent.constructorName.type.name.name;
59+
if (parent.constructorName.name != null) {
60+
name += '.${parent.constructorName.name.name}';
6161
}
62-
execElement = ElementLocator.locate(constructor) as ExecutableElement;
62+
execElement = ElementLocator.locate(parent) as ExecutableElement;
6363
}
6464

6565
if (execElement == null) {

pkg/analysis_server/lib/src/status/element_writer.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class ElementWriter extends GeneralizingElementVisitor with TreeWriter {
5353
properties['isStatic'] = element.isStatic;
5454
}
5555
if (element is CompilationUnitElement) {
56-
properties['hasLoadLibraryFunction'] = element.hasLoadLibraryFunction;
5756
properties['source'] = element.source;
5857
}
5958
if (element is ConstFieldElementImpl) {
@@ -109,7 +108,6 @@ class ElementWriter extends GeneralizingElementVisitor with TreeWriter {
109108
properties['definingCompilationUnit'] = element.definingCompilationUnit;
110109
properties['entryPoint'] = element.entryPoint;
111110
properties['hasExtUri'] = element.hasExtUri;
112-
properties['hasLoadLibraryFunction'] = element.hasLoadLibraryFunction;
113111
properties['isBrowserApplication'] = element.isBrowserApplication;
114112
properties['isDartAsync'] = element.isDartAsync;
115113
properties['isDartCore'] = element.isDartCore;

pkg/analysis_server/test/lsp/signature_help_test.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,31 @@ class SignatureHelpTest extends AbstractLspAnalysisServerTest
8484
);
8585
}
8686

87+
Future<void> test_error_methodInvocation_importPrefix() async {
88+
final content = '''
89+
import 'dart:async' as prefix;
90+
91+
void f() {
92+
prefix(^);
93+
}
94+
''';
95+
96+
await initialize(
97+
textDocumentCapabilities: withSignatureHelpContentFormat(
98+
emptyTextDocumentClientCapabilities,
99+
[MarkupKind.Markdown],
100+
),
101+
);
102+
await openFile(mainFileUri, withoutMarkers(content));
103+
104+
// Expect no result.
105+
final res = await getSignatureHelp(
106+
mainFileUri,
107+
positionFromMarker(content),
108+
);
109+
expect(res, isNull);
110+
}
111+
87112
Future<void> test_formats_markdown() async {
88113
final content = '''
89114
/// Does foo.

pkg/analyzer/lib/dart/element/element.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ abstract class CompilationUnitElement implements Element, UriReferencedElement {
408408

409409
/// Return `true` if this compilation unit defines a top-level function named
410410
/// `loadLibrary`.
411+
@Deprecated('Not useful for clients')
411412
bool get hasLoadLibraryFunction;
412413

413414
/// Return the [LineInfo] for the [source], or `null` if not computed yet.
@@ -1328,6 +1329,7 @@ abstract class LibraryElement implements _ExistingElement {
13281329

13291330
/// Return `true` if this library defines a top-level function named
13301331
/// `loadLibrary`.
1332+
@Deprecated('Not useful for clients')
13311333
bool get hasLoadLibraryFunction;
13321334

13331335
/// Return an identifier that uniquely identifies this element among the

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,7 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
13381338
@override
13391339
int get hashCode => source.hashCode;
13401340

1341+
@Deprecated('Not useful for clients')
13411342
@override
13421343
bool get hasLoadLibraryFunction {
13431344
List<FunctionElement> functions = this.functions;
@@ -5029,6 +5030,7 @@ class LibraryElementImpl extends _ExistingElementImpl
50295030
setModifier(Modifier.HAS_EXT_URI, hasExtUri);
50305031
}
50315032

5033+
@Deprecated('Not useful for clients')
50325034
@override
50335035
bool get hasLoadLibraryFunction {
50345036
for (int i = 0; i < units.length; i++) {

pkg/analyzer/lib/src/error/best_practices_verifier.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,11 +1130,15 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
11301130
/// See [CompileTimeErrorCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION].
11311131
bool _checkForLoadLibraryFunction(
11321132
ImportDirective node, ImportElement importElement) {
1133-
LibraryElement? importedLibrary = importElement.importedLibrary;
1134-
if (importedLibrary == null) {
1133+
var importedLibrary = importElement.importedLibrary;
1134+
var prefix = importElement.prefix;
1135+
if (importedLibrary == null || prefix == null) {
11351136
return false;
11361137
}
1137-
if (importedLibrary.hasLoadLibraryFunction) {
1138+
var importNamespace = importElement.namespace;
1139+
var loadLibraryElement = importNamespace.getPrefixed(
1140+
prefix.name, FunctionElement.LOAD_LIBRARY_NAME);
1141+
if (loadLibraryElement != null) {
11381142
_errorReporter.reportErrorForNode(
11391143
HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION,
11401144
node,

pkg/analyzer/test/src/diagnostics/import_deferred_library_with_load_function_test.dart

Lines changed: 73 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import 'package:analyzer/src/error/codes.dart';
66
import 'package:test_reflective_loader/test_reflective_loader.dart';
77

8-
import '../../generated/test_support.dart';
98
import '../dart/resolution/context_collection_resolution.dart';
109

1110
main() {
@@ -18,59 +17,90 @@ main() {
1817
class ImportDeferredLibraryWithLoadFunctionTest
1918
extends PubPackageResolutionTest {
2019
test_deferredImport_withLoadLibraryFunction() async {
21-
newFile('$testPackageLibPath/lib1.dart', content: r'''
22-
library lib1;
23-
loadLibrary() {}
24-
f() {}''');
20+
newFile('$testPackageLibPath/a.dart', content: r'''
21+
void loadLibrary() {}
22+
void f() {}
23+
''');
2524

26-
newFile('$testPackageLibPath/lib2.dart', content: r'''
27-
library root;
28-
import 'lib1.dart' deferred as lib1;
29-
main() { lib1.f(); }''');
30-
31-
await _resolveFile('$testPackageLibPath/lib1.dart');
32-
await _resolveFile('$testPackageLibPath/lib2.dart', [
33-
error(HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION, 14, 36),
25+
await assertErrorsInCode(r'''
26+
import 'a.dart' deferred as p;
27+
void main() {
28+
p.f();
29+
}
30+
''', [
31+
error(HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION, 0, 30),
3432
]);
3533
}
3634

37-
test_deferredImport_withoutLoadLibraryFunction() async {
38-
newFile('$testPackageLibPath/lib1.dart', content: r'''
39-
library lib1;
40-
f() {}''');
35+
test_deferredImport_withLoadLibraryFunction_hide() async {
36+
newFile('$testPackageLibPath/a.dart', content: r'''
37+
void loadLibrary() {}
38+
void f() {}
39+
''');
4140

42-
newFile('$testPackageLibPath/lib2.dart', content: r'''
43-
library root;
44-
import 'lib1.dart' deferred as lib1;
45-
main() { lib1.f(); }''');
41+
await assertNoErrorsInCode(r'''
42+
import 'a.dart' deferred as p hide loadLibrary;
43+
void main() {
44+
p.f();
45+
}
46+
''');
47+
}
4648

47-
await _resolveFile('$testPackageLibPath/lib1.dart');
48-
await _resolveFile('$testPackageLibPath/lib2.dart');
49+
test_deferredImport_withLoadLibraryFunction_hide2() async {
50+
newFile('$testPackageLibPath/a.dart', content: r'''
51+
void loadLibrary() {}
52+
void f() {}
53+
void f2() {}
54+
''');
55+
56+
await assertErrorsInCode(r'''
57+
import 'a.dart' deferred as p hide f2;
58+
void main() {
59+
p.f();
60+
}
61+
''', [
62+
error(HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION, 0, 38),
63+
]);
4964
}
5065

51-
test_nonDeferredImport_withLoadLibraryFunction() async {
52-
newFile('$testPackageLibPath/lib1.dart', content: r'''
53-
library lib1;
54-
loadLibrary() {}
55-
f() {}''');
66+
test_deferredImport_withLoadLibraryFunction_show() async {
67+
newFile('$testPackageLibPath/a.dart', content: r'''
68+
void loadLibrary() {}
69+
void f() {}
70+
''');
5671

57-
newFile('$testPackageLibPath/lib2.dart', content: r'''
58-
library root;
59-
import 'lib1.dart' as lib1;
60-
main() { lib1.f(); }''');
72+
await assertNoErrorsInCode(r'''
73+
import 'a.dart' deferred as p show f;
74+
void main() {
75+
p.f();
76+
}
77+
''');
78+
}
79+
80+
test_deferredImport_withoutLoadLibraryFunction() async {
81+
newFile('$testPackageLibPath/a.dart', content: r'''
82+
void f() {}
83+
''');
6184

62-
await _resolveFile('$testPackageLibPath/lib1.dart');
63-
await _resolveFile('$testPackageLibPath/lib2.dart');
85+
await assertNoErrorsInCode(r'''
86+
import 'a.dart' deferred as p;
87+
void main() {
88+
p.f();
89+
}
90+
''');
6491
}
6592

66-
/// Resolve the file with the given [path].
67-
///
68-
/// Similar to ResolutionTest.resolveTestFile, but a custom path is supported.
69-
Future<void> _resolveFile(
70-
String path, [
71-
List<ExpectedError> expectedErrors = const [],
72-
]) async {
73-
result = await resolveFile(convertPath(path));
74-
assertErrorsInResolvedUnit(result, expectedErrors);
93+
test_nonDeferredImport_withLoadLibraryFunction() async {
94+
newFile('$testPackageLibPath/a.dart', content: r'''
95+
void loadLibrary() {}
96+
void f() {}
97+
''');
98+
99+
await assertNoErrorsInCode(r'''
100+
import 'a.dart' as p;
101+
void main() {
102+
p.f();
103+
}
104+
''');
75105
}
76106
}

runtime/vm/isolate.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,6 +1716,7 @@ Isolate::Isolate(IsolateGroup* isolate_group,
17161716
#if !defined(DART_PRECOMPILED_RUNTIME)
17171717
native_callback_trampolines_(),
17181718
#endif
1719+
isolate_flags_(0),
17191720
#if !defined(PRODUCT)
17201721
last_resume_timestamp_(OS::GetCurrentTimeMillis()),
17211722
vm_tag_counters_(),

0 commit comments

Comments
 (0)