Version 2.17.0-45.0.dev
Merge commit '61de22db596b7b605d69e4722c2d451f15b2f40d' into 'dev'
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart b/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart
index 490b25f..983ff52 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart
@@ -322,22 +322,8 @@
}
/// Return the feature for the not-yet-imported property.
- double isNotImportedFeature(bool isNotImported, Element element) {
- if (isNotImported) {
- var enclosing = element.enclosingElement;
- // The most often case is that we suggest a class.
- if (enclosing is CompilationUnitElement) {
- return -1.0;
- }
- // But we could also suggest an extension method.
- if (enclosing is ExtensionElement) {
- if (!element.isStaticExtensionMember) {
- return -1.0;
- }
- }
- }
- // The library is imported, or an unexpected element.
- return 0.0;
+ double isNotImportedFeature(bool isNotImported) {
+ return isNotImported ? -1.0 : 0.0;
}
/// Return the value of the _keyword_ feature for the [keyword] when
@@ -1059,11 +1045,3 @@
return null;
}
}
-
-extension on Element {
- bool get isStaticExtensionMember {
- final self = this;
- return self is PropertyAccessorElement && self.isStatic ||
- self is MethodElement && self.isStatic;
- }
-}
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
index 56f5717..829a3e5 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
@@ -273,8 +273,8 @@
elementKind: elementKind,
hasDeprecated: hasDeprecated,
isConstant: isConstant,
- isNotImported: request.featureComputer
- .isNotImportedFeature(isNotImportedLibrary, accessor),
+ isNotImported:
+ request.featureComputer.isNotImportedFeature(isNotImportedLibrary),
startsWithDollar: startsWithDollar,
superMatches: superMatches,
inheritanceDistance: inheritanceDistance,
@@ -668,8 +668,8 @@
hasDeprecated: hasDeprecated,
isConstant: isConstant,
isNoSuchMethod: isNoSuchMethod,
- isNotImported: request.featureComputer
- .isNotImportedFeature(isNotImportedLibrary, method),
+ isNotImported:
+ request.featureComputer.isNotImportedFeature(isNotImportedLibrary),
startsWithDollar: startsWithDollar,
superMatches: superMatches,
inheritanceDistance: inheritanceDistance,
@@ -946,8 +946,8 @@
elementKind: elementKind,
hasDeprecated: hasDeprecated,
isConstant: isConstant,
- isNotImported: request.featureComputer
- .isNotImportedFeature(isNotImportedLibrary, accessor),
+ isNotImported:
+ request.featureComputer.isNotImportedFeature(isNotImportedLibrary),
startsWithDollar: startsWithDollar,
superMatches: superMatches,
);
@@ -1114,8 +1114,8 @@
elementKind: elementKind,
hasDeprecated: hasDeprecated,
isConstant: isConstant,
- isNotImported: request.featureComputer
- .isNotImportedFeature(isNotImportedLibrary, element),
+ isNotImported:
+ request.featureComputer.isNotImportedFeature(isNotImportedLibrary),
);
}
diff --git a/pkg/analysis_server/test/domain_completion_test.dart b/pkg/analysis_server/test/domain_completion_test.dart
index aa70c28..82c6e44 100644
--- a/pkg/analysis_server/test/domain_completion_test.dart
+++ b/pkg/analysis_server/test/domain_completion_test.dart
@@ -296,6 +296,48 @@
..suggestions.isEmpty;
}
+ Future<void> test_isNotImportedFeature_prefixed_classInstanceMethod() async {
+ newFile('$testPackageLibPath/a.dart', content: '''
+class A {
+ void foo01() {}
+}
+''');
+
+ newFile('$testPackageLibPath/b.dart', content: '''
+import 'a.dart';
+
+class B extends A {
+ void foo02() {}
+}
+''');
+
+ await _configureWithWorkspaceRoot();
+
+ var response = await _getTestCodeSuggestions('''
+import 'b.dart';
+
+void f(B b) {
+ b.foo0^
+}
+''');
+
+ check(response)
+ ..assertComplete()
+ ..hasReplacement(left: 4);
+
+ // The fact that `b.dart` is imported, and `a.dart` is not, does not affect
+ // the order of suggestions added with an expression prefix. We are not
+ // going to import anything, so this does not matter.
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..libraryUriToImport.isNull,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..libraryUriToImport.isNull,
+ ]);
+ }
+
Future<void> test_notImported_dart() async {
await _configureWithWorkspaceRoot();
@@ -334,6 +376,44 @@
..suggestions.withElementClass.isEmpty;
}
+ Future<void> test_notImported_lowerRelevance_enumConstant() async {
+ newFile('$testPackageLibPath/a.dart', content: '''
+enum E1 {
+ foo01
+}
+''');
+
+ newFile('$testPackageLibPath/b.dart', content: '''
+enum E2 {
+ foo02
+}
+''');
+
+ await _configureWithWorkspaceRoot();
+
+ var response = await _getTestCodeSuggestions('''
+import 'b.dart';
+
+void f() {
+ foo0^
+}
+''');
+
+ check(response)
+ ..assertComplete()
+ ..hasReplacement(left: 4);
+
+ // `foo01` relevance is decreased because it is not yet imported.
+ check(response).suggestions.matches([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('E2.foo02')
+ ..libraryUriToImport.isNull,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('E1.foo01')
+ ..libraryUriToImport.isEqualTo('package:test/a.dart'),
+ ]);
+ }
+
Future<void> test_notImported_lowerRelevance_extension_getter() async {
await _configureWithWorkspaceRoot();
diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart
index 1913f4e..a57892b 100644
--- a/pkg/compiler/lib/src/dart2js.dart
+++ b/pkg/compiler/lib/src/dart2js.dart
@@ -1141,28 +1141,25 @@
// before and after running the compiler. Another two lines may be
// used to print an error message.
print('''
-Usage: dart compile js [options] dartfile
+Compile Dart to JavaScript.
-Compiles Dart to JavaScript.
-
-Common options:
- -o <file> Generate the output into <file>.
- -m Generate minified output.
- -h Display this message (add -v for information about all options).''');
+Usage: dart compile js [arguments] <dart entry point>
+ -h, --help Print this usage information (add -v for information about all options).
+ -o, --output Write the output to <file name>.
+ -O<0,1,2,3,4> Set the compiler optimization level (defaults to -O1).
+ ''');
}
void verboseHelp() {
print(r'''
-Usage: dart compile js [options] dartfile
+Compile Dart to JavaScript.
-Compiles Dart to JavaScript.
-
-Supported options:
+Usage: dart compile js [arguments] <dart entry point>
-h, /h, /?, --help
- Display this message (add -v for information about all options).
+ Print this usage information (add -v for information about all options).
- -o <file>, --out=<file>
- Generate the output into <file>.
+ -o <file name>, --out=<file name>
+ Write the output to <file name>.
-m, --minify
Generate minified output.
diff --git a/runtime/vm/custom_isolate_test.cc b/runtime/vm/custom_isolate_test.cc
index 21fbaec..278039a 100644
--- a/runtime/vm/custom_isolate_test.cc
+++ b/runtime/vm/custom_isolate_test.cc
@@ -306,7 +306,6 @@
VM_UNIT_TEST_CASE(CustomIsolates) {
bool saved_flag = FLAG_trace_shutdown;
FLAG_trace_shutdown = true;
- FLAG_verify_handles = true;
event_queue = new EventQueue();
Dart_Isolate dart_isolate = TestCase::CreateTestIsolate();
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 42021bd..1f0baa6 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -66,7 +66,6 @@
#define Z (T->zone())
DECLARE_FLAG(bool, print_class_table);
-DECLARE_FLAG(bool, verify_handles);
#if defined(DEBUG) && !defined(DART_PRECOMPILED_RUNTIME)
DEFINE_FLAG(bool,
check_function_fingerprints,
@@ -372,10 +371,6 @@
ASSERT(thread->execution_state() == Thread::kThreadInVM);
ASSERT(thread->IsMutatorThread());
ASSERT(thread->isolate() != NULL);
- ASSERT(!FLAG_verify_handles || thread->IsValidLocalHandle(object) ||
- thread->isolate()->group()->api_state()->IsActivePersistentHandle(
- reinterpret_cast<Dart_PersistentHandle>(object)) ||
- Dart::IsReadOnlyApiHandle(object));
ASSERT(FinalizablePersistentHandle::ptr_offset() == 0 &&
PersistentHandle::ptr_offset() == 0 && LocalHandle::ptr_offset() == 0);
#endif
diff --git a/runtime/vm/handles.cc b/runtime/vm/handles.cc
index b088957..8b44b78 100644
--- a/runtime/vm/handles.cc
+++ b/runtime/vm/handles.cc
@@ -17,8 +17,6 @@
namespace dart {
-DEFINE_FLAG(bool, verify_handles, false, "Verify handles.");
-
void VMHandles::VisitObjectPointers(ObjectPointerVisitor* visitor) {
return Handles<kVMHandleSizeInWords, kVMHandlesPerChunk,
kOffsetOfRawPtr>::VisitObjectPointers(visitor);
diff --git a/runtime/vm/handles.h b/runtime/vm/handles.h
index f2f9005..d59a1ba 100644
--- a/runtime/vm/handles.h
+++ b/runtime/vm/handles.h
@@ -50,8 +50,6 @@
class ObjectPointerVisitor;
class HandleVisitor;
-DECLARE_FLAG(bool, verify_handles);
-
template <int kHandleSizeInWords, int kHandlesPerChunk, int kOffsetOfRawPtr>
class Handles {
public:
diff --git a/runtime/vm/heap/verifier.cc b/runtime/vm/heap/verifier.cc
index 71ea299..1a726dd 100644
--- a/runtime/vm/heap/verifier.cc
+++ b/runtime/vm/heap/verifier.cc
@@ -107,16 +107,6 @@
: thread_(thread), instanceHandle_(Instance::Handle(thread->zone())) {}
void VerifyCanonicalVisitor::VisitObject(ObjectPtr obj) {
- // The caller of this function is walking heap pages using the
- // ExclusivePageIterator - which holds the pages lock.
- //
- // If we allow handle verification, then any assignment to a handle will call
- // `heap()->Contains()` for heap objects, which in return is implemented by
- // walking pages using ExclusivePageIterator, which can cause a deadlock.
- //
- // Therefore we disable the handle verification here.
- const bool old_verify_flag = FLAG_verify_handles;
- FLAG_verify_handles = false;
if (!IsInternalOnlyClassId(obj->GetClassId()) &&
(obj->GetClassId() != kTypeArgumentsCid)) {
if (obj->untag()->IsCanonical()) {
@@ -129,7 +119,6 @@
ASSERT(is_canonical);
}
}
- FLAG_verify_handles = old_verify_flag;
}
#endif // defined(DEBUG)
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index b2b35a6..093014b 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -2510,15 +2510,6 @@
#if defined(DEBUG)
bool Object::InVMIsolateHeap() const {
- if (FLAG_verify_handles && ptr()->untag()->InVMIsolateHeap()) {
- Heap* vm_isolate_heap = Dart::vm_isolate_group()->heap();
- uword addr = UntaggedObject::ToAddr(ptr());
- if (!vm_isolate_heap->Contains(addr)) {
- ASSERT(FLAG_write_protect_code);
- addr = UntaggedObject::ToAddr(OldPage::ToWritable(ptr()));
- ASSERT(vm_isolate_heap->Contains(addr));
- }
- }
return ptr()->untag()->InVMIsolateHeap();
}
#endif // DEBUG
@@ -2610,19 +2601,6 @@
cid = kInstanceCid;
}
ASSERT(vtable() == builtin_vtables_[cid]);
- if (FLAG_verify_handles && ptr_->IsHeapObject()) {
- Heap* isolate_heap = IsolateGroup::Current()->heap();
- if (!isolate_heap->new_space()->scavenging()) {
- Heap* vm_isolate_heap = Dart::vm_isolate_group()->heap();
- uword addr = UntaggedObject::ToAddr(ptr_);
- if (!isolate_heap->Contains(addr) && !vm_isolate_heap->Contains(addr)) {
- ASSERT(FLAG_write_protect_code);
- addr = UntaggedObject::ToAddr(OldPage::ToWritable(ptr_));
- ASSERT(isolate_heap->Contains(addr) ||
- vm_isolate_heap->Contains(addr));
- }
- }
- }
}
#endif
}
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 99c91df..b830f12 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -12134,22 +12134,6 @@
cid = kInstanceCid;
}
set_vtable(builtin_vtables_[cid]);
-#if defined(DEBUG)
- if (FLAG_verify_handles && ptr_->IsHeapObject() && (ptr_ != Object::null())) {
- Heap* isolate_heap = IsolateGroup::Current()->heap();
- // TODO(rmacnak): Remove after rewriting StackFrame::VisitObjectPointers
- // to not use handles.
- if (!isolate_heap->new_space()->scavenging()) {
- Heap* vm_isolate_heap = Dart::vm_isolate_group()->heap();
- uword addr = UntaggedObject::ToAddr(ptr_);
- if (!isolate_heap->Contains(addr) && !vm_isolate_heap->Contains(addr)) {
- ASSERT(FLAG_write_protect_code);
- addr = UntaggedObject::ToAddr(OldPage::ToWritable(ptr_));
- ASSERT(isolate_heap->Contains(addr) || vm_isolate_heap->Contains(addr));
- }
- }
- }
-#endif
}
intptr_t Field::HostOffset() const {
diff --git a/tools/VERSION b/tools/VERSION
index 663e7c4..d40a15f 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 17
PATCH 0
-PRERELEASE 44
+PRERELEASE 45
PRERELEASE_PATCH 0
\ No newline at end of file