Version 2.15.0-111.0.dev
Merge commit '2bd0759ec9bc19ec6ad581f0a70c34c84aac19e2' into 'dev'
diff --git a/pkg/analysis_server/test/abstract_context.dart b/pkg/analysis_server/test/abstract_context.dart
index 94e46a7..4c466d1 100644
--- a/pkg/analysis_server/test/abstract_context.dart
+++ b/pkg/analysis_server/test/abstract_context.dart
@@ -300,11 +300,6 @@
}
}
-mixin WithNullSafetyMixin on AbstractContextTest {
- @override
- String get testPackageLanguageVersion => '2.12';
-}
-
/// Wraps the given [_ElementVisitorFunction] into an instance of
/// [engine.GeneralizingElementVisitor].
class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor<void> {
diff --git a/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
index a9f5b6a..789ff5f 100644
--- a/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
@@ -9,13 +9,11 @@
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../abstract_context.dart';
import 'completion_contributor_util.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(ArgListContributorTest);
- defineReflectiveTests(ArgListContributorWithNullSafetyTest);
});
}
@@ -1095,26 +1093,6 @@
assertNoSuggestions();
}
- Future<void> test_superConstructorInvocation() async {
- addTestSource('''
-class A {
- final bool field1;
- final int field2;
- A({this.field1, this.field2});
-}
-class B extends A {
- B() : super(^);
-}
-''');
- await computeSuggestions();
- assertSuggestArgumentsAndTypes(
- namedArgumentsWithTypes: {'field1': 'bool', 'field2': 'int'});
- }
-}
-
-@reflectiveTest
-class ArgListContributorWithNullSafetyTest extends DartCompletionContributorTest
- with WithNullSafetyMixin, ArgListContributorMixin {
Future<void> test_ArgumentList_nnbd_function_named_param() async {
addTestSource(r'''
f({int? nullable, int nonnullable}) {}
@@ -1155,4 +1133,20 @@
'named': 'int*',
});
}
+
+ Future<void> test_superConstructorInvocation() async {
+ addTestSource('''
+class A {
+ final bool field1;
+ final int field2;
+ A({this.field1, this.field2});
+}
+class B extends A {
+ B() : super(^);
+}
+''');
+ await computeSuggestions();
+ assertSuggestArgumentsAndTypes(
+ namedArgumentsWithTypes: {'field1': 'bool', 'field2': 'int'});
+ }
}
diff --git a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
index d37b156..5148c7d 100644
--- a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
@@ -9,13 +9,11 @@
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../abstract_context.dart';
import 'completion_contributor_util.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(ImportedReferenceContributorTest);
- defineReflectiveTests(ImportedReferenceContributorWithNullSafetyTest);
});
}
@@ -2352,6 +2350,75 @@
expect(suggestion.hasNamedParameters, true);
}
+ Future<void> test_function_parameters_nnbd_required() async {
+ createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
+ resolveSource('/home/test/lib/a.dart', '''
+void m(int? nullable, int nonNullable) {}
+''');
+ addTestSource('''
+import 'a.dart';
+
+void f() {^}
+''');
+ await computeSuggestions();
+ var suggestion = assertSuggestFunction('m', 'void');
+ var parameterNames = suggestion.parameterNames!;
+ var parameterTypes = suggestion.parameterTypes!;
+ expect(parameterNames, hasLength(2));
+ expect(parameterNames[0], 'nullable');
+ expect(parameterTypes[0], 'int?');
+ expect(parameterNames[1], 'nonNullable');
+ expect(parameterTypes[1], 'int');
+ expect(suggestion.requiredParameterCount, 2);
+ expect(suggestion.hasNamedParameters, false);
+ }
+
+ Future<void> test_function_parameters_nnbd_required_into_legacy() async {
+ createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
+ resolveSource('/home/test/lib/a.dart', '''
+void m(int? nullable, int nonNullable) {}
+''');
+ addTestSource('''
+// @dart = 2.8
+import 'a.dart';
+
+void f() {^}
+''');
+ await computeSuggestions();
+ var suggestion = assertSuggestFunction('m', 'void');
+ var parameterNames = suggestion.parameterNames!;
+ var parameterTypes = suggestion.parameterTypes!;
+ expect(parameterNames, hasLength(2));
+ expect(parameterNames[0], 'nullable');
+ expect(parameterTypes[0], 'int');
+ expect(parameterNames[1], 'nonNullable');
+ expect(parameterTypes[1], 'int');
+ expect(suggestion.requiredParameterCount, 2);
+ expect(suggestion.hasNamedParameters, false);
+ }
+
+ Future<void> test_function_parameters_nnbd_required_legacy() async {
+ createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
+ resolveSource('/home/test/lib/a.dart', '''
+// @dart = 2.8
+void m(int param) {}
+''');
+ addTestSource('''
+import 'a.dart';
+
+void f() {^}
+''');
+ await computeSuggestions();
+ var suggestion = assertSuggestFunction('m', 'void');
+ var parameterNames = suggestion.parameterNames!;
+ var parameterTypes = suggestion.parameterTypes!;
+ expect(parameterNames, hasLength(1));
+ expect(parameterNames[0], 'param');
+ expect(parameterTypes[0], 'int*');
+ expect(suggestion.requiredParameterCount, 1);
+ expect(suggestion.hasNamedParameters, false);
+ }
+
Future<void> test_function_parameters_none() async {
resolveSource('/home/test/lib/a.dart', '''
void m() {}
@@ -4830,77 +4897,3 @@
assertSuggestClass('Object');
}
}
-
-@reflectiveTest
-class ImportedReferenceContributorWithNullSafetyTest
- extends DartCompletionContributorTest
- with WithNullSafetyMixin, ImportedReferenceContributorMixin {
- Future<void> test_function_parameters_nnbd_required() async {
- createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
- resolveSource('/home/test/lib/a.dart', '''
-void m(int? nullable, int nonNullable) {}
-''');
- addTestSource('''
-import 'a.dart';
-
-void f() {^}
-''');
- await computeSuggestions();
- var suggestion = assertSuggestFunction('m', 'void');
- var parameterNames = suggestion.parameterNames!;
- var parameterTypes = suggestion.parameterTypes!;
- expect(parameterNames, hasLength(2));
- expect(parameterNames[0], 'nullable');
- expect(parameterTypes[0], 'int?');
- expect(parameterNames[1], 'nonNullable');
- expect(parameterTypes[1], 'int');
- expect(suggestion.requiredParameterCount, 2);
- expect(suggestion.hasNamedParameters, false);
- }
-
- Future<void> test_function_parameters_nnbd_required_into_legacy() async {
- createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
- resolveSource('/home/test/lib/a.dart', '''
-void m(int? nullable, int nonNullable) {}
-''');
- addTestSource('''
-// @dart = 2.8
-import 'a.dart';
-
-void f() {^}
-''');
- await computeSuggestions();
- var suggestion = assertSuggestFunction('m', 'void');
- var parameterNames = suggestion.parameterNames!;
- var parameterTypes = suggestion.parameterTypes!;
- expect(parameterNames, hasLength(2));
- expect(parameterNames[0], 'nullable');
- expect(parameterTypes[0], 'int');
- expect(parameterNames[1], 'nonNullable');
- expect(parameterTypes[1], 'int');
- expect(suggestion.requiredParameterCount, 2);
- expect(suggestion.hasNamedParameters, false);
- }
-
- Future<void> test_function_parameters_nnbd_required_legacy() async {
- createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
- resolveSource('/home/test/lib/a.dart', '''
-// @dart = 2.8
-void m(int param) {}
-''');
- addTestSource('''
-import 'a.dart';
-
-void f() {^}
-''');
- await computeSuggestions();
- var suggestion = assertSuggestFunction('m', 'void');
- var parameterNames = suggestion.parameterNames!;
- var parameterTypes = suggestion.parameterTypes!;
- expect(parameterNames, hasLength(1));
- expect(parameterNames[0], 'param');
- expect(parameterTypes[0], 'int*');
- expect(suggestion.requiredParameterCount, 1);
- expect(suggestion.hasNamedParameters, false);
- }
-}
diff --git a/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
index b8d35f4..1673cfd 100644
--- a/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
@@ -11,13 +11,11 @@
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../abstract_context.dart';
import 'completion_contributor_util.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(KeywordContributorTest);
- defineReflectiveTests(KeywordContributorWithNullSafetyTest);
});
}
@@ -2331,7 +2329,3 @@
return true;
}
}
-
-@reflectiveTest
-class KeywordContributorWithNullSafetyTest extends KeywordContributorTest
- with WithNullSafetyMixin {}
diff --git a/pkg/analysis_server/test/services/completion/postfix/postfix_completion_test.dart b/pkg/analysis_server/test/services/completion/postfix/postfix_completion_test.dart
index f09ca3f..5e73ef0 100644
--- a/pkg/analysis_server/test/services/completion/postfix/postfix_completion_test.dart
+++ b/pkg/analysis_server/test/services/completion/postfix/postfix_completion_test.dart
@@ -7,7 +7,6 @@
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../abstract_context.dart';
import '../../../abstract_single_unit.dart';
void main() {
@@ -635,7 +634,7 @@
}
@reflectiveTest
-class _TryTest extends PostfixCompletionTest with WithNullSafetyMixin {
+class _TryTest extends PostfixCompletionTest {
Future<void> test_try() async {
await _prepareCompletion('.try', '''
f() {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/shadow_field_test.dart b/pkg/analysis_server/test/src/services/correction/assist/shadow_field_test.dart
index c6a0061..b40d609 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/shadow_field_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/shadow_field_test.dart
@@ -6,13 +6,11 @@
import 'package:analyzer_plugin/utilities/assist/assist.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'assist_processor.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(ShadowFieldTest);
- defineReflectiveTests(ShadowFieldWithNullSafetyTest);
});
}
@@ -105,11 +103,7 @@
}
''');
}
-}
-@reflectiveTest
-class ShadowFieldWithNullSafetyTest extends ShadowFieldTest
- with WithNullSafetyMixin {
Future<void> test_notNull() async {
await resolveTestCode('''
class C {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_async_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_async_test.dart
index 6825440..df3eb40 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_async_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_async_test.dart
@@ -8,13 +8,11 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(AddAsyncTest);
- defineReflectiveTests(AddAsyncWithNullSafetyTest);
defineReflectiveTests(AvoidReturningNullForFutureTest);
});
}
@@ -115,6 +113,90 @@
});
}
+ Future<void> test_missingReturn_method_hasReturn() async {
+ await resolveTestCode('''
+class C {
+ Future<int> m(bool b) {
+ if (b) {
+ return 0;
+ }
+ }
+}
+''');
+ await assertNoFix(errorFilter: (error) {
+ return error.errorCode ==
+ CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_METHOD;
+ });
+ }
+
+ Future<void> test_missingReturn_method_notVoid() async {
+ await resolveTestCode('''
+class C {
+ Future<int> m() {
+ print('');
+ }
+}
+''');
+ await assertNoFix();
+ }
+
+ Future<void> test_missingReturn_method_notVoid_inherited() async {
+ await resolveTestCode('''
+abstract class A {
+ Future<int> foo();
+}
+
+class B implements A {
+ foo() {
+ print('');
+ }
+}
+''');
+ await assertNoFix();
+ }
+
+ Future<void> test_missingReturn_method_void() async {
+ await resolveTestCode('''
+class C {
+ Future<void> m() {
+ print('');
+ }
+}
+''');
+ await assertHasFix('''
+class C {
+ Future<void> m() async {
+ print('');
+ }
+}
+''');
+ }
+
+ Future<void> test_missingReturn_method_void_inherited() async {
+ await resolveTestCode('''
+abstract class A {
+ Future<void> foo();
+}
+
+class B implements A {
+ foo() {
+ print('');
+ }
+}
+''');
+ await assertHasFix('''
+abstract class A {
+ Future<void> foo();
+}
+
+class B implements A {
+ foo() async {
+ print('');
+ }
+}
+''');
+ }
+
Future<void> test_missingReturn_notVoid() async {
await resolveTestCode('''
Future<int> f() {
@@ -124,6 +206,42 @@
await assertNoFix();
}
+ Future<void> test_missingReturn_topLevel_hasReturn() async {
+ await resolveTestCode('''
+Future<int> f(bool b) {
+ if (b) {
+ return 0;
+ }
+}
+''');
+ await assertNoFix(errorFilter: (error) {
+ return error.errorCode ==
+ CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION;
+ });
+ }
+
+ Future<void> test_missingReturn_topLevel_notVoid() async {
+ await resolveTestCode('''
+Future<int> f() {
+ print('');
+}
+''');
+ await assertNoFix();
+ }
+
+ Future<void> test_missingReturn_topLevel_void() async {
+ await resolveTestCode('''
+Future<void> f() {
+ print('');
+}
+''');
+ await assertHasFix('''
+Future<void> f() async {
+ print('');
+}
+''');
+ }
+
Future<void> test_missingReturn_void() async {
await resolveTestCode('''
Future<void> f() {
@@ -216,133 +334,6 @@
}
@reflectiveTest
-class AddAsyncWithNullSafetyTest extends FixProcessorTest
- with WithNullSafetyMixin {
- @override
- FixKind get kind => DartFixKind.ADD_ASYNC;
-
- Future<void> test_missingReturn_method_hasReturn() async {
- await resolveTestCode('''
-class C {
- Future<int> m(bool b) {
- if (b) {
- return 0;
- }
- }
-}
-''');
- await assertNoFix(errorFilter: (error) {
- return error.errorCode ==
- CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_METHOD;
- });
- }
-
- Future<void> test_missingReturn_method_notVoid() async {
- await resolveTestCode('''
-class C {
- Future<int> m() {
- print('');
- }
-}
-''');
- await assertNoFix();
- }
-
- Future<void> test_missingReturn_method_notVoid_inherited() async {
- await resolveTestCode('''
-abstract class A {
- Future<int> foo();
-}
-
-class B implements A {
- foo() {
- print('');
- }
-}
-''');
- await assertNoFix();
- }
-
- Future<void> test_missingReturn_method_void() async {
- await resolveTestCode('''
-class C {
- Future<void> m() {
- print('');
- }
-}
-''');
- await assertHasFix('''
-class C {
- Future<void> m() async {
- print('');
- }
-}
-''');
- }
-
- Future<void> test_missingReturn_method_void_inherited() async {
- await resolveTestCode('''
-abstract class A {
- Future<void> foo();
-}
-
-class B implements A {
- foo() {
- print('');
- }
-}
-''');
- await assertHasFix('''
-abstract class A {
- Future<void> foo();
-}
-
-class B implements A {
- foo() async {
- print('');
- }
-}
-''');
- }
-
- Future<void> test_missingReturn_topLevel_hasReturn() async {
- await resolveTestCode('''
-Future<int> f(bool b) {
- if (b) {
- return 0;
- }
-}
-''');
- await assertNoFix(errorFilter: (error) {
- return error.errorCode ==
- CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION;
- });
- }
-
- Future<void> test_missingReturn_topLevel_notVoid() async {
- await resolveTestCode('''
-Future<int> f() {
- print('');
-}
-''');
- await assertNoFix();
- }
-
- Future<void> test_missingReturn_topLevel_void() async {
- await resolveTestCode('''
-Future<void> f() {
- print('');
-}
-''');
- await assertHasFix('''
-Future<void> f() async {
- print('');
-}
-''');
- }
-}
-
-@reflectiveTest
class AvoidReturningNullForFutureTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.ADD_ASYNC;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_explicit_cast_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_explicit_cast_test.dart
index 797f097..bdcfb2a 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_explicit_cast_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_explicit_cast_test.dart
@@ -7,13 +7,11 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(AddExplicitCastTest);
- defineReflectiveTests(AddExplicitCastWithNullSafetyTest);
});
}
@@ -215,6 +213,24 @@
''');
}
+ Future<void> test_assignment_null() async {
+ await resolveTestCode('''
+void f(int x) {
+ x = null;
+}
+''');
+ await assertNoFix();
+ }
+
+ Future<void> test_assignment_nullable() async {
+ await resolveTestCode('''
+void f(int x, int? y) {
+ x = y;
+}
+''');
+ await assertNoFix();
+ }
+
Future<void> test_assignment_set() async {
await resolveTestCode('''
f(Set<A> a) {
@@ -486,25 +502,3 @@
);
}
}
-
-@reflectiveTest
-class AddExplicitCastWithNullSafetyTest extends AddExplicitCastTest
- with WithNullSafetyMixin {
- Future<void> test_assignment_null() async {
- await resolveTestCode('''
-void f(int x) {
- x = null;
-}
-''');
- await assertNoFix();
- }
-
- Future<void> test_assignment_nullable() async {
- await resolveTestCode('''
-void f(int x, int? y) {
- x = y;
-}
-''');
- await assertNoFix();
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_missing_required_argument_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_missing_required_argument_test.dart
index 8c49597..dc08b79 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_missing_required_argument_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_missing_required_argument_test.dart
@@ -7,13 +7,11 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(AddMissingRequiredArgumentTest);
- defineReflectiveTests(AddMissingRequiredArgumentWithNullSafetyTest);
});
}
@@ -231,6 +229,91 @@
''');
}
+ Future<void> test_constructor_single_closure_nnbd() async {
+ addSource('/home/test/lib/a.dart', r'''
+typedef int Callback(int? a);
+
+class A {
+ A({required Callback callback}) {}
+}
+''');
+ await resolveTestCode('''
+import 'package:test/a.dart';
+
+main() {
+ A a = new A();
+ print(a);
+}
+''');
+ await assertHasFix('''
+import 'package:test/a.dart';
+
+main() {
+ A a = new A(callback: (int? a) { });
+ print(a);
+}
+''');
+ }
+
+ Future<void> test_constructor_single_closure_nnbd_from_legacy() async {
+ addSource('/home/test/lib/a.dart', r'''
+// @dart = 2.8
+import 'package:meta/meta.dart';
+
+typedef int Callback(int a);
+
+class A {
+ A({@required Callback callback}) {}
+}
+''');
+ await resolveTestCode('''
+import 'package:test/a.dart';
+
+main() {
+ A a = new A();
+ print(a);
+}
+''');
+ await assertHasFix('''
+import 'package:test/a.dart';
+
+main() {
+ A a = new A(callback: (int a) { });
+ print(a);
+}
+''',
+ errorFilter: (error) =>
+ error.errorCode == HintCode.MISSING_REQUIRED_PARAM);
+ }
+
+ Future<void> test_constructor_single_closure_nnbd_into_legacy() async {
+ addSource('/home/test/lib/a.dart', r'''
+typedef int Callback(int? a);
+
+class A {
+ A({required Callback callback}) {}
+}
+''');
+ await resolveTestCode('''
+// @dart = 2.8
+import 'package:test/a.dart';
+
+main() {
+ A a = new A();
+ print(a);
+}
+''');
+ await assertHasFix('''
+// @dart = 2.8
+import 'package:test/a.dart';
+
+main() {
+ A a = new A(callback: (int a) { });
+ print(a);
+}
+''');
+ }
+
Future<void> test_constructor_single_list() async {
addSource('/home/test/lib/a.dart', r'''
class A {
@@ -300,6 +383,36 @@
''', errorFilter: (error) => error.message.contains("'bcd'"));
}
+ Future<void> test_nonNullable() async {
+ await resolveTestCode('''
+void f({required int x}) {}
+void g() {
+ f();
+}
+''');
+ await assertHasFix('''
+void f({required int x}) {}
+void g() {
+ f(x: null);
+}
+''');
+ }
+
+ Future<void> test_nullable() async {
+ await resolveTestCode('''
+void f({required int? x}) {}
+void g() {
+ f();
+}
+''');
+ await assertHasFix('''
+void f({required int? x}) {}
+void g() {
+ f(x: null);
+}
+''');
+ }
+
Future<void> test_param_child() async {
await resolveTestCode('''
import 'package:flutter/widgets.dart';
@@ -391,131 +504,3 @@
''');
}
}
-
-@reflectiveTest
-class AddMissingRequiredArgumentWithNullSafetyTest extends FixProcessorTest
- with WithNullSafetyMixin {
- @override
- FixKind get kind => DartFixKind.ADD_MISSING_REQUIRED_ARGUMENT;
-
- @override
- void setUp() {
- super.setUp();
- writeTestPackageConfig(meta: true);
- }
-
- Future<void> test_constructor_single_closure_nnbd() async {
- addSource('/home/test/lib/a.dart', r'''
-typedef int Callback(int? a);
-
-class A {
- A({required Callback callback}) {}
-}
-''');
- await resolveTestCode('''
-import 'package:test/a.dart';
-
-main() {
- A a = new A();
- print(a);
-}
-''');
- await assertHasFix('''
-import 'package:test/a.dart';
-
-main() {
- A a = new A(callback: (int? a) { });
- print(a);
-}
-''');
- }
-
- Future<void> test_constructor_single_closure_nnbd_from_legacy() async {
- addSource('/home/test/lib/a.dart', r'''
-// @dart = 2.8
-import 'package:meta/meta.dart';
-
-typedef int Callback(int a);
-
-class A {
- A({@required Callback callback}) {}
-}
-''');
- await resolveTestCode('''
-import 'package:test/a.dart';
-
-main() {
- A a = new A();
- print(a);
-}
-''');
- await assertHasFix('''
-import 'package:test/a.dart';
-
-main() {
- A a = new A(callback: (int a) { });
- print(a);
-}
-''',
- errorFilter: (error) =>
- error.errorCode == HintCode.MISSING_REQUIRED_PARAM);
- }
-
- Future<void> test_constructor_single_closure_nnbd_into_legacy() async {
- addSource('/home/test/lib/a.dart', r'''
-typedef int Callback(int? a);
-
-class A {
- A({required Callback callback}) {}
-}
-''');
- await resolveTestCode('''
-// @dart = 2.8
-import 'package:test/a.dart';
-
-main() {
- A a = new A();
- print(a);
-}
-''');
- await assertHasFix('''
-// @dart = 2.8
-import 'package:test/a.dart';
-
-main() {
- A a = new A(callback: (int a) { });
- print(a);
-}
-''');
- }
-
- Future<void> test_nonNullable() async {
- await resolveTestCode('''
-void f({required int x}) {}
-void g() {
- f();
-}
-''');
- await assertHasFix('''
-void f({required int x}) {}
-void g() {
- f(x: null);
-}
-''');
- }
-
- Future<void> test_nullable() async {
- await resolveTestCode('''
-void f({required int? x}) {}
-void g() {
- f();
-}
-''');
- await assertHasFix('''
-void f({required int? x}) {}
-void g() {
- f(x: null);
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_ne_null_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_ne_null_test.dart
index 0d52849..6207ad2 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_ne_null_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_ne_null_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
@@ -18,7 +17,7 @@
}
@reflectiveTest
-class AddNeNullMultiTest extends FixProcessorTest with WithNullSafetyMixin {
+class AddNeNullMultiTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.ADD_NE_NULL_MULTI;
@@ -61,7 +60,7 @@
}
@reflectiveTest
-class AddNeNullTest extends FixProcessorTest with WithNullSafetyMixin {
+class AddNeNullTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.ADD_NE_NULL;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_null_check_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_null_check_test.dart
index e516e85..5cb45e5 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_null_check_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_null_check_test.dart
@@ -8,7 +8,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
@@ -18,7 +17,7 @@
}
@reflectiveTest
-class AddNullCheckTest extends FixProcessorTest with WithNullSafetyMixin {
+class AddNullCheckTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.ADD_NULL_CHECK;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart
index 3d633b0..1da0c9d 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
@@ -69,8 +68,7 @@
}
@reflectiveTest
-class AddRequiredWithNullSafetyTest extends FixProcessorTest
- with WithNullSafetyMixin {
+class AddRequiredWithNullSafetyTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.ADD_REQUIRED2;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_null_aware_spread_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_null_aware_spread_test.dart
index 8cdcb25..f5b0205 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_null_aware_spread_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_null_aware_spread_test.dart
@@ -6,7 +6,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
@@ -16,8 +15,7 @@
}
@reflectiveTest
-class ConvertToNullAwareSpreadTest extends FixProcessorTest
- with WithNullSafetyMixin {
+class ConvertToNullAwareSpreadTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_NULL_AWARE_SPREAD;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_constructor_for_final_fields_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_constructor_for_final_fields_test.dart
index 6230cde..92c5799 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_constructor_for_final_fields_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_constructor_for_final_fields_test.dart
@@ -7,13 +7,11 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(CreateConstructorForFinalFieldsTest);
- defineReflectiveTests(CreateConstructorForFinalFieldsWithNullSafetyTest);
});
}
@@ -22,6 +20,23 @@
@override
FixKind get kind => DartFixKind.CREATE_CONSTRUCTOR_FOR_FINAL_FIELDS;
+ Future<void> test_excludesLate() async {
+ await resolveTestCode('''
+class Test {
+ final int a;
+ late final int b;
+}
+''');
+ await assertHasFix('''
+class Test {
+ final int a;
+ late final int b;
+
+ Test(this.a);
+}
+''');
+ }
+
Future<void> test_flutter() async {
writeTestPackageConfig(flutter: true);
await resolveTestCode('''
@@ -160,27 +175,3 @@
await assertNoFix();
}
}
-
-@reflectiveTest
-class CreateConstructorForFinalFieldsWithNullSafetyTest extends FixProcessorTest
- with WithNullSafetyMixin {
- @override
- FixKind get kind => DartFixKind.CREATE_CONSTRUCTOR_FOR_FINAL_FIELDS;
-
- Future<void> test_excludesLate() async {
- await resolveTestCode('''
-class Test {
- final int a;
- late final int b;
-}
-''');
- await assertHasFix('''
-class Test {
- final int a;
- late final int b;
-
- Test(this.a);
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_missing_overrides_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_missing_overrides_test.dart
index 0f08223..de7daf0 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_missing_overrides_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_missing_overrides_test.dart
@@ -8,13 +8,11 @@
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(CreateMissingOverridesTest);
- defineReflectiveTests(CreateMissingOverridesWithNullSafetyTest);
});
}
@@ -438,6 +436,52 @@
''');
}
+ Future<void> test_method_generic_nullable_dynamic() async {
+ // https://github.com/dart-lang/sdk/issues/43535
+ await resolveTestCode('''
+class A {
+ void doSomething(Map<String, dynamic>? m) {}
+}
+
+class B implements A {}
+''');
+ await assertHasFix('''
+class A {
+ void doSomething(Map<String, dynamic>? m) {}
+}
+
+class B implements A {
+ @override
+ void doSomething(Map<String, dynamic>? m) {
+ // TODO: implement doSomething
+ }
+}
+''');
+ }
+
+ Future<void> test_method_generic_nullable_Never() async {
+ // https://github.com/dart-lang/sdk/issues/43535
+ await resolveTestCode('''
+class A {
+ void doSomething(Map<String, Never>? m) {}
+}
+
+class B implements A {}
+''');
+ await assertHasFix('''
+class A {
+ void doSomething(Map<String, Never>? m) {}
+}
+
+class B implements A {
+ @override
+ void doSomething(Map<String, Never>? m) {
+ // TODO: implement doSomething
+ }
+}
+''');
+ }
+
Future<void> test_method_generic_withBounds() async {
// https://github.com/dart-lang/sdk/issues/31199
await resolveTestCode('''
@@ -685,56 +729,3 @@
''');
}
}
-
-@reflectiveTest
-class CreateMissingOverridesWithNullSafetyTest extends FixProcessorTest
- with WithNullSafetyMixin {
- @override
- FixKind get kind => DartFixKind.CREATE_MISSING_OVERRIDES;
-
- Future<void> test_method_generic_nullable_dynamic() async {
- // https://github.com/dart-lang/sdk/issues/43535
- await resolveTestCode('''
-class A {
- void doSomething(Map<String, dynamic>? m) {}
-}
-
-class B implements A {}
-''');
- await assertHasFix('''
-class A {
- void doSomething(Map<String, dynamic>? m) {}
-}
-
-class B implements A {
- @override
- void doSomething(Map<String, dynamic>? m) {
- // TODO: implement doSomething
- }
-}
-''');
- }
-
- Future<void> test_method_generic_nullable_Never() async {
- // https://github.com/dart-lang/sdk/issues/43535
- await resolveTestCode('''
-class A {
- void doSomething(Map<String, Never>? m) {}
-}
-
-class B implements A {}
-''');
- await assertHasFix('''
-class A {
- void doSomething(Map<String, Never>? m) {}
-}
-
-class B implements A {
- @override
- void doSomething(Map<String, Never>? m) {
- // TODO: implement doSomething
- }
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/make_return_type_nullable_test.dart b/pkg/analysis_server/test/src/services/correction/fix/make_return_type_nullable_test.dart
index 7e976e7..1b3a4cc 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/make_return_type_nullable_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/make_return_type_nullable_test.dart
@@ -6,7 +6,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
@@ -16,8 +15,7 @@
}
@reflectiveTest
-class MakeReturnTypeNullableTest extends FixProcessorTest
- with WithNullSafetyMixin {
+class MakeReturnTypeNullableTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.MAKE_RETURN_TYPE_NULLABLE;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/make_variable_nullable_test.dart b/pkg/analysis_server/test/src/services/correction/fix/make_variable_nullable_test.dart
index f619f67..611de4e 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/make_variable_nullable_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/make_variable_nullable_test.dart
@@ -6,7 +6,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
@@ -16,8 +15,7 @@
}
@reflectiveTest
-class MakeVariableNullableTest extends FixProcessorTest
- with WithNullSafetyMixin {
+class MakeVariableNullableTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.MAKE_VARIABLE_NULLABLE;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_comparison_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_comparison_test.dart
index 3e73604..0a1f5f7 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_comparison_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_comparison_test.dart
@@ -8,7 +8,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
@@ -20,7 +19,7 @@
}
@reflectiveTest
-class RemoveComparisonTest extends FixProcessorTest with WithNullSafetyMixin {
+class RemoveComparisonTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.REMOVE_COMPARISON;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart
index d9d83cb..81cd56c 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart
@@ -6,13 +6,11 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(RemoveDeadCodeTest);
- defineReflectiveTests(RemoveDeadCodeWithNullSafetyTest);
});
}
@@ -105,46 +103,6 @@
''');
}
- Future<void> test_statements_one() async {
- await resolveTestCode('''
-int f() {
- print(0);
- return 42;
- print(1);
-}
-''');
- await assertHasFix('''
-int f() {
- print(0);
- return 42;
-}
-''');
- }
-
- Future<void> test_statements_two() async {
- await resolveTestCode('''
-int f() {
- print(0);
- return 42;
- print(1);
- print(2);
-}
-''');
- await assertHasFix('''
-int f() {
- print(0);
- return 42;
-}
-''');
- }
-}
-
-@reflectiveTest
-class RemoveDeadCodeWithNullSafetyTest extends FixProcessorTest
- with WithNullSafetyMixin {
- @override
- FixKind get kind => DartFixKind.REMOVE_DEAD_CODE;
-
@failingTest
Future<void> test_do_returnInBody() async {
// https://github.com/dart-lang/sdk/issues/43511
@@ -180,4 +138,37 @@
}
''');
}
+
+ Future<void> test_statements_one() async {
+ await resolveTestCode('''
+int f() {
+ print(0);
+ return 42;
+ print(1);
+}
+''');
+ await assertHasFix('''
+int f() {
+ print(0);
+ return 42;
+}
+''');
+ }
+
+ Future<void> test_statements_two() async {
+ await resolveTestCode('''
+int f() {
+ print(0);
+ return 42;
+ print(1);
+ print(2);
+}
+''');
+ await assertHasFix('''
+int f() {
+ print(0);
+ return 42;
+}
+''');
+ }
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart
index e210ebc..0b58dcb 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
@@ -20,8 +19,7 @@
}
@reflectiveTest
-class DeadNullAwareAssignmentExpressionTest extends FixProcessorTest
- with WithNullSafetyMixin {
+class DeadNullAwareAssignmentExpressionTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.REMOVE_IF_NULL_OPERATOR;
@@ -85,8 +83,7 @@
}
@reflectiveTest
-class DeadNullAwareExpressionTest extends FixProcessorTest
- with WithNullSafetyMixin {
+class DeadNullAwareExpressionTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.REMOVE_IF_NULL_OPERATOR;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart
index ee3e204..948fc7c 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart
@@ -6,7 +6,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
@@ -17,8 +16,7 @@
}
@reflectiveTest
-class RemoveNonNullAssertionBulkTest extends BulkFixProcessorTest
- with WithNullSafetyMixin {
+class RemoveNonNullAssertionBulkTest extends BulkFixProcessorTest {
Future<void> test_singleFile() async {
await resolveTestCode('''
void f(String a) {
@@ -34,8 +32,7 @@
}
@reflectiveTest
-class RemoveNonNullAssertionTest extends FixProcessorTest
- with WithNullSafetyMixin {
+class RemoveNonNullAssertionTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.REMOVE_NON_NULL_ASSERTION;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart
index 20ee77f..da6cc96 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
@@ -44,7 +43,7 @@
}
@reflectiveTest
-class RemoveQuestionMarkTest extends FixProcessorTest with WithNullSafetyMixin {
+class RemoveQuestionMarkTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.REMOVE_QUESTION_MARK;
@@ -125,7 +124,7 @@
@reflectiveTest
class UnnecessaryNullableForFinalVariableDeclarationsTest
- extends FixProcessorLintTest with WithNullSafetyMixin {
+ extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_QUESTION_MARK;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_with_filled_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_with_filled_test.dart
index cdfb2bc..a9efc25 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_with_filled_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_with_filled_test.dart
@@ -6,7 +6,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
@@ -16,7 +15,7 @@
}
@reflectiveTest
-class ReplaceWithFilledTest extends FixProcessorTest with WithNullSafetyMixin {
+class ReplaceWithFilledTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.REPLACE_WITH_FILLED;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_with_not_null_aware_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_with_not_null_aware_test.dart
index edd6679..a525dd3 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_with_not_null_aware_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_with_not_null_aware_test.dart
@@ -6,7 +6,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
@@ -17,8 +16,7 @@
}
@reflectiveTest
-class ReplaceWithNotNullAwareBulkTest extends BulkFixProcessorTest
- with WithNullSafetyMixin {
+class ReplaceWithNotNullAwareBulkTest extends BulkFixProcessorTest {
Future<void> test_notShortCircuit() async {
await resolveTestCode('''
void f(A a) {
@@ -65,8 +63,7 @@
}
@reflectiveTest
-class ReplaceWithNotNullAwareTest extends FixProcessorTest
- with WithNullSafetyMixin {
+class ReplaceWithNotNullAwareTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.REPLACE_WITH_NOT_NULL_AWARE;
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 5515c76..3049ed4 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -291,6 +291,11 @@
late final SimpleIdentifierResolver _simpleIdentifierResolver =
SimpleIdentifierResolver(this, flowAnalysis);
+ late final PropertyElementResolver _propertyElementResolver =
+ PropertyElementResolver(this);
+
+ late final AnnotationResolver _annotationResolver = AnnotationResolver(this);
+
/// Initialize a newly created visitor to resolve the nodes in an AST node.
///
/// The [definingLibrary] is the element for the library containing the node
@@ -696,8 +701,7 @@
node.target?.accept(this);
startNullAwareIndexExpression(node);
- var resolver = PropertyElementResolver(this);
- var result = resolver.resolveIndexExpression(
+ var result = _propertyElementResolver.resolveIndexExpression(
node: node,
hasRead: hasRead,
hasWrite: true,
@@ -717,8 +721,7 @@
} else if (node is PrefixedIdentifier) {
node.prefix.accept(this);
- var resolver = PropertyElementResolver(this);
- return resolver.resolvePrefixedIdentifier(
+ return _propertyElementResolver.resolvePrefixedIdentifier(
node: node,
hasRead: hasRead,
hasWrite: true,
@@ -727,16 +730,14 @@
node.target?.accept(this);
startNullAwarePropertyAccess(node);
- var resolver = PropertyElementResolver(this);
- return resolver.resolvePropertyAccess(
+ return _propertyElementResolver.resolvePropertyAccess(
node: node,
hasRead: hasRead,
hasWrite: true,
);
- } else if (node is SimpleIdentifier) {
- var resolver = PropertyElementResolver(this);
- var result = resolver.resolveSimpleIdentifier(
- node: node as SimpleIdentifierImpl,
+ } else if (node is SimpleIdentifierImpl) {
+ var result = _propertyElementResolver.resolveSimpleIdentifier(
+ node: node,
hasRead: hasRead,
hasWrite: true,
);
@@ -892,7 +893,7 @@
@override
void visitAnnotation(covariant AnnotationImpl node) {
var whyNotPromotedList = <Map<DartType, NonPromotionReason> Function()>[];
- AnnotationResolver(this).resolve(node, whyNotPromotedList);
+ _annotationResolver.resolve(node, whyNotPromotedList);
var arguments = node.arguments;
if (arguments != null) {
checkForArgumentTypesNotAssignableInList(arguments, whyNotPromotedList);
@@ -1569,8 +1570,7 @@
node.target?.accept(this);
startNullAwareIndexExpression(node);
- var resolver = PropertyElementResolver(this);
- var result = resolver.resolveIndexExpression(
+ var result = _propertyElementResolver.resolveIndexExpression(
node: node,
hasRead: true,
hasWrite: false,
@@ -1773,8 +1773,7 @@
node.target?.accept(this);
startNullAwarePropertyAccess(node);
- var resolver = PropertyElementResolver(this);
- var result = resolver.resolvePropertyAccess(
+ var result = _propertyElementResolver.resolvePropertyAccess(
node: node,
hasRead: true,
hasWrite: false,
diff --git a/pkg/dds/lib/src/dap/adapters/dart_cli.dart b/pkg/dds/lib/src/dap/adapters/dart_cli_adapter.dart
similarity index 100%
rename from pkg/dds/lib/src/dap/adapters/dart_cli.dart
rename to pkg/dds/lib/src/dap/adapters/dart_cli_adapter.dart
diff --git a/pkg/dds/lib/src/dap/adapters/dart_test_adapter.dart b/pkg/dds/lib/src/dap/adapters/dart_test_adapter.dart
new file mode 100644
index 0000000..534166d
--- /dev/null
+++ b/pkg/dds/lib/src/dap/adapters/dart_test_adapter.dart
@@ -0,0 +1,188 @@
+// Copyright (c) 2021, 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.
+
+import 'dart:async';
+import 'dart:convert';
+import 'dart:io';
+
+import 'package:path/path.dart' as path;
+import 'package:pedantic/pedantic.dart';
+import 'package:vm_service/vm_service.dart' as vm;
+
+import '../logging.dart';
+import '../protocol_common.dart';
+import '../protocol_stream.dart';
+import '../stream_transformers.dart';
+import 'dart.dart';
+import 'mixins.dart';
+
+/// A DAP Debug Adapter for running and debugging Dart test scripts.
+class DartTestDebugAdapter extends DartDebugAdapter<DartLaunchRequestArguments,
+ DartAttachRequestArguments>
+ with PidTracker, VmServiceInfoFileUtils, PackageConfigUtils {
+ Process? _process;
+
+ @override
+ final parseLaunchArgs = DartLaunchRequestArguments.fromJson;
+
+ @override
+ final parseAttachArgs = DartAttachRequestArguments.fromJson;
+
+ DartTestDebugAdapter(
+ ByteStreamServerChannel channel, {
+ bool ipv6 = false,
+ bool enableDds = true,
+ bool enableAuthCodes = true,
+ Logger? logger,
+ }) : super(
+ channel,
+ ipv6: ipv6,
+ enableDds: enableDds,
+ enableAuthCodes: enableAuthCodes,
+ logger: logger,
+ ) {
+ channel.closed.then((_) => shutdown());
+ }
+
+ /// Whether the VM Service closing should be used as a signal to terminate the
+ /// debug session.
+ ///
+ /// Since we do not support attaching for tests, this is always false.
+ bool get terminateOnVmServiceClose => false;
+
+ Future<void> debuggerConnected(vm.VM vmInfo) async {
+ // Capture the PID from the VM Service so that we can terminate it when
+ // cleaning up. Terminating the process might not be enough as it could be
+ // just a shell script (e.g. pub on Windows) and may not pass the
+ // signal on correctly.
+ // See: https://github.com/Dart-Code/Dart-Code/issues/907
+ final pid = vmInfo.pid;
+ if (pid != null) {
+ pidsToTerminate.add(pid);
+ }
+ }
+
+ /// Called by [disconnectRequest] to request that we forcefully shut down the
+ /// app being run (or in the case of an attach, disconnect).
+ Future<void> disconnectImpl() async {
+ terminatePids(ProcessSignal.sigkill);
+ }
+
+ /// Called by [launchRequest] to request that we actually start the app to be
+ /// run/debugged.
+ ///
+ /// For debugging, this should start paused, connect to the VM Service, set
+ /// breakpoints, and resume.
+ Future<void> launchImpl() async {
+ final args = this.args as DartLaunchRequestArguments;
+ final vmPath = Platform.resolvedExecutable;
+ File? vmServiceInfoFile;
+
+ final debug = !(args.noDebug ?? false);
+ if (debug) {
+ vmServiceInfoFile = generateVmServiceInfoFile();
+ unawaited(waitForVmServiceInfoFile(logger, vmServiceInfoFile)
+ .then((uri) => connectDebugger(uri, resumeIfStarting: true)));
+ }
+
+ final vmArgs = <String>[
+ if (debug) ...[
+ '--enable-vm-service=${args.vmServicePort ?? 0}${ipv6 ? '/::1' : ''}',
+ '--pause_isolates_on_start',
+ if (!enableAuthCodes) '--disable-service-auth-codes'
+ ],
+ if (debug && vmServiceInfoFile != null) ...[
+ '-DSILENT_OBSERVATORY=true',
+ '--write-service-info=${Uri.file(vmServiceInfoFile.path)}'
+ ],
+ // Default to asserts on, this seems like the most useful behaviour for
+ // editor-spawned debug sessions.
+ if (args.enableAsserts ?? true) '--enable-asserts',
+ // TODO(dantup): This should be changed from "dart run test:test" to
+ // "dart test" once the started-paused flags are working correctly.
+ // Currently they start paused but do not write the vm-service-info file
+ // to give us the VM-service URI.
+ // https://github.com/dart-lang/sdk/issues/44200#issuecomment-726869539
+ // We should also ensure DDS is disabled (this may need a new flag since
+ // we can't disable-dart-dev to get "dart test") and devtools is not
+ // served.
+ // '--disable-dart-dev',
+ 'run',
+ '--no-serve-devtools',
+ 'test:test',
+ '-r',
+ 'json',
+ ];
+ final processArgs = [
+ ...vmArgs,
+ ...?args.toolArgs,
+ args.program,
+ ...?args.args,
+ ];
+
+ // Find the package_config file for this script.
+ // TODO(dantup): Remove this once
+ // https://github.com/dart-lang/sdk/issues/45530 is done as it will not be
+ // necessary.
+ var possibleRoot = path.isAbsolute(args.program)
+ ? path.dirname(args.program)
+ : path.dirname(path.normalize(path.join(args.cwd ?? '', args.program)));
+ final packageConfig = findPackageConfigFile(possibleRoot);
+ if (packageConfig != null) {
+ this.usePackageConfigFile(packageConfig);
+ }
+
+ // TODO(dantup): Support passing env to both of these.
+
+ logger?.call('Spawning $vmPath with $processArgs in ${args.cwd}');
+ final process = await Process.start(
+ vmPath,
+ processArgs,
+ workingDirectory: args.cwd,
+ );
+ _process = process;
+ pidsToTerminate.add(process.pid);
+
+ process.stdout.transform(ByteToLineTransformer()).listen(_handleStdout);
+ process.stderr.listen(_handleStderr);
+ unawaited(process.exitCode.then(_handleExitCode));
+ }
+
+ /// Called by [attachRequest] to request that we actually connect to the app
+ /// to be debugged.
+ Future<void> attachImpl() async {
+ sendOutput('console', '\nAttach is not supported for test runs');
+ handleSessionTerminate();
+ }
+
+ /// Called by [terminateRequest] to request that we gracefully shut down the
+ /// app being run (or in the case of an attach, disconnect).
+ Future<void> terminateImpl() async {
+ terminatePids(ProcessSignal.sigint);
+ await _process?.exitCode;
+ }
+
+ void _handleExitCode(int code) {
+ final codeSuffix = code == 0 ? '' : ' ($code)';
+ logger?.call('Process exited ($code)');
+ handleSessionTerminate(codeSuffix);
+ }
+
+ void _handleStderr(List<int> data) {
+ sendOutput('stderr', utf8.decode(data));
+ }
+
+ void _handleStdout(String data) {
+ // Output to stdout is expected to be JSON from the test runner. If we
+ // get non-JSON output we will just pass it through to the front-end so it
+ // shows up in the client and can be seen (although we generally expect
+ // package:test to have captured output and sent it in "print" events).
+ try {
+ final payload = jsonDecode(data);
+ sendEvent(RawEventBody(payload), eventType: 'dart.testNotification');
+ } catch (e) {
+ sendOutput('stdout', data);
+ }
+ }
+}
diff --git a/pkg/dds/lib/src/dap/server.dart b/pkg/dds/lib/src/dap/server.dart
index 8a38138..6de1eaa 100644
--- a/pkg/dds/lib/src/dap/server.dart
+++ b/pkg/dds/lib/src/dap/server.dart
@@ -4,9 +4,9 @@
import 'dart:async';
-import 'package:dds/src/dap/adapters/dart.dart';
-
-import 'adapters/dart_cli.dart';
+import 'adapters/dart.dart';
+import 'adapters/dart_cli_adapter.dart';
+import 'adapters/dart_test_adapter.dart';
import 'logging.dart';
import 'protocol_stream.dart';
@@ -22,6 +22,7 @@
final bool ipv6;
final bool enableDds;
final bool enableAuthCodes;
+ final bool test;
final Logger? logger;
DapServer(
@@ -30,15 +31,24 @@
this.ipv6 = false,
this.enableDds = true,
this.enableAuthCodes = true,
+ this.test = false,
this.logger,
}) : channel = ByteStreamServerChannel(_input, _output, logger) {
- adapter = DartCliDebugAdapter(
- channel,
- ipv6: ipv6,
- enableDds: enableDds,
- enableAuthCodes: enableAuthCodes,
- logger: logger,
- );
+ adapter = test
+ ? DartTestDebugAdapter(
+ channel,
+ ipv6: ipv6,
+ enableDds: enableDds,
+ enableAuthCodes: enableAuthCodes,
+ logger: logger,
+ )
+ : DartCliDebugAdapter(
+ channel,
+ ipv6: ipv6,
+ enableDds: enableDds,
+ enableAuthCodes: enableAuthCodes,
+ logger: logger,
+ );
}
void stop() {
diff --git a/pkg/dds/lib/src/dap/stream_transformers.dart b/pkg/dds/lib/src/dap/stream_transformers.dart
new file mode 100644
index 0000000..7e4540a
--- /dev/null
+++ b/pkg/dds/lib/src/dap/stream_transformers.dart
@@ -0,0 +1,44 @@
+// Copyright (c) 2021, 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.
+
+import 'dart:async';
+import 'dart:convert';
+
+/// Transforms a stream of bytes into strings whenever a newline is encountered.
+///
+/// This is used to consume output of processes like the package:test JSON
+/// reporter where the stream data may be buffered and we need to process
+/// specific JSON packets that are sent on their own lines.
+class ByteToLineTransformer extends StreamTransformerBase<List<int>, String> {
+ @override
+ Stream<String> bind(Stream<List<int>> stream) {
+ late StreamSubscription<int> input;
+ late StreamController<String> _output;
+ final buffer = <int>[];
+ _output = StreamController<String>(
+ onListen: () {
+ input = stream.expand((b) => b).listen(
+ (codeUnit) {
+ buffer.add(codeUnit);
+ if (_endsWithLf(buffer)) {
+ _output.add(utf8.decode(buffer));
+ buffer.clear();
+ }
+ },
+ onError: _output.addError,
+ onDone: _output.close,
+ );
+ },
+ onPause: () => input.pause(),
+ onResume: () => input.resume(),
+ onCancel: () => input.cancel(),
+ );
+ return _output.stream;
+ }
+
+ /// Whether [buffer] ends in '\n'.
+ static bool _endsWithLf(List<int> buffer) {
+ return buffer.isNotEmpty && buffer.last == 10;
+ }
+}
diff --git a/pkg/dds/test/dap/integration/dart_test_test.dart b/pkg/dds/test/dap/integration/dart_test_test.dart
new file mode 100644
index 0000000..02e980e
--- /dev/null
+++ b/pkg/dds/test/dap/integration/dart_test_test.dart
@@ -0,0 +1,149 @@
+// Copyright (c) 2021, 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.
+
+import 'package:test/test.dart';
+
+import 'test_client.dart';
+import 'test_scripts.dart';
+import 'test_support.dart';
+
+main() {
+ late DapTestSession dap;
+ setUp(() async {
+ dap = await DapTestSession.setUp(additionalArgs: ['--test']);
+ await dap.addPackageDependency(dap.testAppDir, 'test');
+ });
+ tearDown(() => dap.tearDown());
+
+ group('dart test', () {
+ /// A helper that verifies a full set of expected test results for the
+ /// [simpleTestProgram] script.
+ void expectStandardSimpleTestResults(TestEvents events) {
+ // Check we recieved all expected test events passed through from
+ // package:test.
+ final eventNames =
+ events.testNotifications.map((e) => e['type']).toList();
+
+ // start/done should always be first/last.
+ expect(eventNames.first, equals('start'));
+ expect(eventNames.last, equals('done'));
+
+ // allSuites should have occurred after start.
+ expect(
+ eventNames,
+ containsAllInOrder(['start', 'allSuites']),
+ );
+
+ // Expect two tests, with the failing one emitting an error.
+ expect(
+ eventNames,
+ containsAllInOrder([
+ 'testStart',
+ 'testDone',
+ 'testStart',
+ 'error',
+ 'print',
+ 'testDone',
+ ]),
+ );
+ }
+
+ test('can run without debugging', () async {
+ final client = dap.client;
+ final testFile = dap.createTestFile(simpleTestProgram);
+
+ // Collect output and test events while running the script.
+ final outputEvents = await client.collectTestOutput(
+ launch: () => client.launch(
+ testFile.path,
+ noDebug: true,
+ cwd: dap.testAppDir.path,
+ ),
+ );
+
+ // Check the printed output shows that the run finished, and it's exit
+ // code (which is 1 due to the failing test).
+ final output = outputEvents.output.map((e) => e.output).join();
+ expectLines(output, [
+ 'Exited (1).',
+ ]);
+
+ expectStandardSimpleTestResults(outputEvents);
+ });
+
+ test('can run a single test', () async {
+ final client = dap.client;
+ final testFile = dap.createTestFile(simpleTestProgram);
+
+ // Collect output and test events while running the script.
+ final outputEvents = await client.collectTestOutput(
+ launch: () => client.launch(
+ testFile.path,
+ noDebug: true,
+ cwd: dap.testAppDir.path,
+ // It's up to the calling IDE to pass the correct args for 'dart test'
+ // if it wants to run a subset of tests.
+ args: [
+ '--plain-name',
+ 'passing',
+ ],
+ ),
+ );
+
+ final testsNames = outputEvents.testNotifications
+ .where((e) => e['type'] == 'testStart')
+ .map((e) => (e['test'] as Map<String, Object?>)['name'])
+ .toList();
+
+ expect(testsNames, contains('group passing'));
+ expect(testsNames, isNot(contains('group failing')));
+ });
+
+ test('can hit and resume from a breakpoint', () async {
+ final client = dap.client;
+ final testFile = dap.createTestFile(simpleTestProgram);
+ final breakpointLine = lineWith(testFile, breakpointMarker);
+
+ // Collect output and test events while running the script.
+ final outputEvents = await client.collectTestOutput(
+ // When launching, hit a breakpoint and resume.
+ start: () => client
+ .hitBreakpoint(
+ testFile,
+ breakpointLine,
+ cwd: dap.testAppDir.path,
+ )
+ .then((stop) => client.continue_(stop.threadId!)),
+ );
+
+ // Check the usual output and test events to ensure breaking/resuming did
+ // not affect the results.
+ final output = outputEvents.output
+ .map((e) => e.output)
+ .skipWhile(dapVmServiceBannerPattern.hasMatch)
+ .join();
+ expectLines(output, ['Exited (1).']);
+ expectStandardSimpleTestResults(outputEvents);
+ });
+
+ test('rejects attaching', () async {
+ final client = dap.client;
+
+ final outputEvents = await client.collectTestOutput(
+ launch: () => client.attach(
+ vmServiceUri: 'ws://bogus.local/',
+ autoResume: false,
+ ),
+ );
+
+ final output = outputEvents.output.map((e) => e.output).join();
+ expectLines(output, [
+ 'Attach is not supported for test runs',
+ 'Exited.',
+ ]);
+ });
+
+ // These tests can be slow due to starting up the external server process.
+ }, timeout: Timeout.none);
+}
diff --git a/pkg/dds/test/dap/integration/debug_breakpoints_test.dart b/pkg/dds/test/dap/integration/debug_breakpoints_test.dart
index c67890b..974380e 100644
--- a/pkg/dds/test/dap/integration/debug_breakpoints_test.dart
+++ b/pkg/dds/test/dap/integration/debug_breakpoints_test.dart
@@ -287,7 +287,7 @@
debugExternalPackageLibraries: false,
// Include the packages folder as an additional project path so that
// it will be treated as local code.
- additionalProjectPaths: [dap.testPackageDir.path],
+ additionalProjectPaths: [dap.testPackagesDir.path],
),
);
diff --git a/pkg/dds/test/dap/integration/test_client.dart b/pkg/dds/test/dap/integration/test_client.dart
index 77ddc1a..f794ad7 100644
--- a/pkg/dds/test/dap/integration/test_client.dart
+++ b/pkg/dds/test/dap/integration/test_client.dart
@@ -59,6 +59,12 @@
Stream<OutputEventBody> get outputEvents => events('output')
.map((e) => OutputEventBody.fromJson(e.body as Map<String, Object?>));
+ /// Returns a stream of 'dart.testNotification' custom events from the
+ /// package:test JSON reporter.
+ Stream<Map<String, Object?>> get testNotificationEvents =>
+ events('dart.testNotification')
+ .map((e) => e.body as Map<String, Object?>);
+
/// Send an attachRequest to the server, asking it to attach to an existing
/// Dart program.
Future<Response> attach({
@@ -297,7 +303,7 @@
/// [launch] method.
Future<void> start({
File? file,
- Future<Response> Function()? launch,
+ Future<Object?> Function()? launch,
}) {
return Future.wait([
initialize(),
@@ -419,6 +425,17 @@
}
}
+/// Useful events produced by the debug adapter during a debug session.
+class TestEvents {
+ final List<OutputEventBody> output;
+ final List<Map<String, Object?>> testNotifications;
+
+ TestEvents({
+ required this.output,
+ required this.testNotifications,
+ });
+}
+
class _OutgoingRequest {
final Completer<Response> completer;
final String name;
@@ -442,6 +459,7 @@
File file,
int line, {
String? condition,
+ String? cwd,
Future<Response> Function()? launch,
}) async {
final stop = expectStop('breakpoint', file: file, line: line);
@@ -454,7 +472,7 @@
breakpoints: [SourceBreakpoint(line: line, condition: condition)],
),
),
- launch?.call() ?? this.launch(file.path),
+ launch?.call() ?? this.launch(file.path, cwd: cwd),
], eagerError: true);
return stop;
@@ -617,17 +635,63 @@
///
/// These results include all events in the order they are recieved, including
/// console, stdout and stderr.
+ ///
+ /// Only one of [start] or [launch] may be provided. Use [start] to customise
+ /// the whole start of the session (including initialise) or [launch] to only
+ /// customise the [launchRequest].
Future<List<OutputEventBody>> collectOutput({
File? file,
+ Future<Response> Function()? start,
Future<Response> Function()? launch,
}) async {
+ assert(
+ start == null || launch == null,
+ 'Only one of "start" or "launch" may be provided',
+ );
final outputEventsFuture = outputEvents.toList();
- await start(file: file, launch: launch);
+ if (start != null) {
+ await start();
+ } else {
+ await this.start(file: file, launch: launch);
+ }
return outputEventsFuture;
}
+ /// Collects all output and test events until the program terminates.
+ ///
+ /// These results include all events in the order they are recieved, including
+ /// console, stdout, stderr and test notifications from the test JSON reporter.
+ ///
+ /// Only one of [start] or [launch] may be provided. Use [start] to customise
+ /// the whole start of the session (including initialise) or [launch] to only
+ /// customise the [launchRequest].
+ Future<TestEvents> collectTestOutput({
+ File? file,
+ Future<Response> Function()? start,
+ Future<Object?> Function()? launch,
+ }) async {
+ assert(
+ start == null || launch == null,
+ 'Only one of "start" or "launch" may be provided',
+ );
+
+ final outputEventsFuture = outputEvents.toList();
+ final testNotificationEventsFuture = testNotificationEvents.toList();
+
+ if (start != null) {
+ await start();
+ } else {
+ await this.start(file: file, launch: launch);
+ }
+
+ return TestEvents(
+ output: await outputEventsFuture,
+ testNotifications: await testNotificationEventsFuture,
+ );
+ }
+
/// A helper that fetches scopes for a frame, checks for one with the name
/// [expectedName] and verifies its variables.
Future<Scope> expectScopeVariables(
diff --git a/pkg/dds/test/dap/integration/test_scripts.dart b/pkg/dds/test/dap/integration/test_scripts.dart
index 08b5390..0b70626 100644
--- a/pkg/dds/test/dap/integration/test_scripts.dart
+++ b/pkg/dds/test/dap/integration/test_scripts.dart
@@ -76,6 +76,25 @@
}
''';
+/// A simple package:test script that has a single group named 'group' with
+/// tests named 'passing' and 'failing' respectively.
+///
+/// The 'passing' test contains a [breakpointMarker].
+const simpleTestProgram = '''
+ import 'package:test/test.dart';
+
+ void main() {
+ group('group', () {
+ test('passing', () {
+ expect(1, equals(1)); $breakpointMarker
+ });
+ test('failing', () {
+ expect(1, equals(2));
+ });
+ });
+ }
+''';
+
/// A simple Dart script that throws in user code.
const simpleThrowingProgram = r'''
void main(List<String> args) async {
diff --git a/pkg/dds/test/dap/integration/test_server.dart b/pkg/dds/test/dap/integration/test_server.dart
index 3e4cb72..41ea32e 100644
--- a/pkg/dds/test/dap/integration/test_server.dart
+++ b/pkg/dds/test/dap/integration/test_server.dart
@@ -39,6 +39,7 @@
enableDds: !args.contains('--no-dds'),
ipv6: args.contains('--ipv6'),
enableAuthCodes: !args.contains('--no-auth-codes'),
+ test: args.contains('--test'),
);
}
diff --git a/pkg/dds/test/dap/integration/test_support.dart b/pkg/dds/test/dap/integration/test_support.dart
index a8cbd0f..4215bd3 100644
--- a/pkg/dds/test/dap/integration/test_support.dart
+++ b/pkg/dds/test/dap/integration/test_support.dart
@@ -8,7 +8,6 @@
import 'package:dds/src/dap/logging.dart';
import 'package:dds/src/dap/protocol_generated.dart';
-import 'package:package_config/package_config.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
@@ -134,12 +133,42 @@
final Directory _testDir =
Directory.systemTemp.createTempSync('dart-sdk-dap-test');
late final Directory testAppDir;
- late final Directory testPackageDir;
- var _packageConfig = PackageConfig.empty;
+ late final Directory testPackagesDir;
DapTestSession._(this.server, this.client) {
testAppDir = _testDir.createTempSync('app');
- testPackageDir = _testDir.createTempSync('packages');
+ createPubspec(testAppDir, 'my_test_project');
+ testPackagesDir = _testDir.createTempSync('packages');
+ }
+
+ /// Adds package with [name] (optionally at [packageFolderUri]) to the
+ /// project in [dir].
+ ///
+ /// If [packageFolderUri] is not supplied, will use [Isolate.resolvePackageUri]
+ /// assuming the package is available to the tests.
+ Future<void> addPackageDependency(
+ Directory dir,
+ String name, [
+ Uri? packageFolderUri,
+ ]) async {
+ final proc = await Process.run(
+ Platform.resolvedExecutable,
+ [
+ 'pub',
+ 'add',
+ name,
+ if (packageFolderUri != null) ...[
+ '--path',
+ packageFolderUri.toFilePath(),
+ ],
+ ],
+ workingDirectory: dir.path,
+ );
+ expect(
+ proc.exitCode,
+ isZero,
+ reason: '${proc.stdout}\n${proc.stderr}'.trim(),
+ );
}
/// Create a simple package named `foo` that has an empty `foo` function.
@@ -154,32 +183,38 @@
);
}
+ void createPubspec(Directory dir, String projectName) {
+ final pubspecFile = File(path.join(dir.path, 'pubspec.yaml'));
+ pubspecFile
+ ..createSync()
+ ..writeAsStringSync('''
+name: $projectName
+version: 1.0.0
+
+environment:
+ sdk: '>=2.13.0 <3.0.0'
+''');
+ }
+
/// Creates a simple package script and adds the package to
/// .dart_tool/package_config.json
Future<Uri> createSimplePackage(
String name,
String content,
) async {
- final dartToolDirectory =
- Directory(path.join(testAppDir.path, '.dart_tool'))..createSync();
- final packageConfigJsonFile =
- File(path.join(dartToolDirectory.path, 'package_config.json'));
- final packageConfigJsonUri = Uri.file(packageConfigJsonFile.path);
-
- // Write the packages Dart implementation file.
- final testPackageDirectory = Directory(path.join(testPackageDir.path, name))
+ final packageDir = Directory(path.join(testPackagesDir.path, name))
..createSync(recursive: true);
- final testFile = File(path.join(testPackageDirectory.path, '$name.dart'));
+ final packageLibDir = Directory(path.join(packageDir.path, 'lib'))
+ ..createSync(recursive: true);
+
+ // Create a pubspec and a implementation file in the lib folder.
+ createPubspec(packageDir, name);
+ final testFile = File(path.join(packageLibDir.path, '$name.dart'));
testFile.writeAsStringSync(content);
- // Add this new package to the PackageConfig.
- final newPackage = Package(name, Uri.file('${testPackageDirectory.path}/'));
- _packageConfig = PackageConfig([..._packageConfig.packages, newPackage]);
-
- // Write the PackageConfig to disk.
- final sink = packageConfigJsonFile.openWrite();
- PackageConfig.writeString(_packageConfig, sink, packageConfigJsonUri);
- await sink.close();
+ // Add this new package as a dependency for the app.
+ final fileUri = Uri.file('${packageDir.path}/');
+ await addPackageDependency(testAppDir, name, fileUri);
return Uri.parse('package:$name/$name.dart');
}
diff --git a/pkg/dds/tool/dap/run_server.dart b/pkg/dds/tool/dap/run_server.dart
index 0178e85..6130640 100644
--- a/pkg/dds/tool/dap/run_server.dart
+++ b/pkg/dds/tool/dap/run_server.dart
@@ -26,6 +26,7 @@
static const argIpv6 = 'ipv6';
static const argDds = 'dds';
static const argAuthCodes = 'auth-codes';
+ static const argTest = 'test';
final Stream<List<int>> _inputStream;
final StreamSink<List<int>> _outputSink;
@@ -52,6 +53,12 @@
argAuthCodes,
defaultsTo: true,
help: 'Whether to enable authentication codes for VM Services',
+ )
+ ..addFlag(
+ argTest,
+ defaultsTo: false,
+ help: 'Whether to use the "dart test" debug adapter to run tests'
+ ' and emit custom events for test progress',
);
}
@@ -65,6 +72,7 @@
ipv6: ipv6,
enableDds: args[argDds],
enableAuthCodes: args[argAuthCodes],
+ test: args[argTest],
);
await server.channel.closed;
diff --git a/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart b/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart
index 8c5b997..70e72af 100644
--- a/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart
+++ b/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart
@@ -16,6 +16,7 @@
messageTypeVariableInStaticContext,
messageTypedefCause,
noLength,
+ templateExperimentNotEnabled,
templateExtendingRestricted,
templateNotAType,
templateSupertypeIsIllegal,
@@ -149,16 +150,27 @@
Template<Message Function(String name)> template =
member == null ? templateTypeNotFound : templateNotAType;
String flatName = flattenName(name, charOffset, fileUri);
+ int length =
+ name is Identifier ? name.endCharOffset - charOffset : flatName.length;
+ Message message;
List<LocatedMessage>? context;
- if (member != null) {
+ if (member == null) {
+ template = templateTypeNotFound;
+ message = template.withArguments(flatName);
+ } else if (declaration != null &&
+ declaration!.isExtension &&
+ library is SourceLibraryBuilder &&
+ !library.enableExtensionTypesInLibrary) {
+ message = templateExperimentNotEnabled.withArguments('extension-types',
+ library.enableExtensionTypesVersionInLibrary.toText());
+ } else {
+ template = templateNotAType;
context = <LocatedMessage>[
messageNotATypeContext.withLocation(member.fileUri!, member.charOffset,
name is Identifier ? name.name.length : "$name".length)
];
+ message = template.withArguments(flatName);
}
- int length =
- name is Identifier ? name.endCharOffset - charOffset : flatName.length;
- Message message = template.withArguments(flatName);
library.addProblem(message, charOffset, length, fileUri, context: context);
declaration = buildInvalidTypeDeclarationBuilder(
message.withLocation(fileUri, charOffset, length),
diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
index 8ffe91a..515d205 100644
--- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
@@ -2495,6 +2495,15 @@
const NullabilityBuilder.omitted(),
<TypeBuilder>[],
charOffset);
+ if (currentTypeParameterScopeBuilder.parent?.kind ==
+ TypeParameterScopeKind.extensionDeclaration) {
+ // Make the synthesized return type invalid for extensions.
+ String name = currentTypeParameterScopeBuilder.parent!.name;
+ returnType.bind(new InvalidTypeDeclarationBuilder(
+ name,
+ messageExtensionDeclaresConstructor.withLocation(
+ fileUri, charOffset, name.length)));
+ }
// Nested declaration began in `OutlineBuilder.beginFactoryMethod`.
TypeParameterScopeBuilder factoryDeclaration = endNestedDeclaration(
TypeParameterScopeKind.factoryMethod, "#factory_method");
diff --git a/pkg/front_end/test/extensions/data/use_as_type.dart b/pkg/front_end/test/extensions/data/use_as_type.dart
index 5cdc007..c52ad6a 100644
--- a/pkg/front_end/test/extensions/data/use_as_type.dart
+++ b/pkg/front_end/test/extensions/data/use_as_type.dart
@@ -39,12 +39,12 @@
B1</*error: errors=['A2' isn't a type.]*/A2> var3;
}
-/*error: errors=['A2' isn't a type.]*/
+/*error: errors=[This requires the 'extension-types' language feature to be enabled.]*/
A2 method1() => null;
// TODO(johnniwinther): We should report an error on the number of type
// arguments here.
-/*error: errors=['B2' isn't a type.,Expected 0 type arguments.]*/
+/*error: errors=[Expected 0 type arguments.,This requires the 'extension-types' language feature to be enabled.]*/
B2<A1> method2() => null;
-B1</*error: errors=['A2' isn't a type.]*/A2> method3() => null;
+B1</*error: errors=[This requires the 'extension-types' language feature to be enabled.]*/A2> method3() => null;
diff --git a/pkg/front_end/testcases/extensions/extension_constructor.dart.weak.expect b/pkg/front_end/testcases/extensions/extension_constructor.dart.weak.expect
index e059431..8400d5d 100644
--- a/pkg/front_end/testcases/extensions/extension_constructor.dart.weak.expect
+++ b/pkg/front_end/testcases/extensions/extension_constructor.dart.weak.expect
@@ -22,20 +22,6 @@
// factory Extension.redirect() = Extension;
// ^^^^^^^
//
-// pkg/front_end/testcases/extensions/extension_constructor.dart:10:11: Error: 'Extension' isn't a type.
-// factory Extension.fact() => null;
-// ^^^^^^^^^
-// pkg/front_end/testcases/extensions/extension_constructor.dart:7:11: Context: This isn't a type.
-// extension Extension on Class {
-// ^^^^^^^^^
-//
-// pkg/front_end/testcases/extensions/extension_constructor.dart:11:11: Error: 'Extension' isn't a type.
-// factory Extension.redirect() = Extension;
-// ^^^^^^^^^
-// pkg/front_end/testcases/extensions/extension_constructor.dart:7:11: Context: This isn't a type.
-// extension Extension on Class {
-// ^^^^^^^^^
-//
import self as self;
import "dart:core" as core;
diff --git a/pkg/front_end/testcases/extensions/extension_constructor.dart.weak.outline.expect b/pkg/front_end/testcases/extensions/extension_constructor.dart.weak.outline.expect
index 5bcfb3c..fec0bcb 100644
--- a/pkg/front_end/testcases/extensions/extension_constructor.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/extensions/extension_constructor.dart.weak.outline.expect
@@ -22,20 +22,6 @@
// factory Extension.redirect() = Extension;
// ^^^^^^^
//
-// pkg/front_end/testcases/extensions/extension_constructor.dart:10:11: Error: 'Extension' isn't a type.
-// factory Extension.fact() => null;
-// ^^^^^^^^^
-// pkg/front_end/testcases/extensions/extension_constructor.dart:7:11: Context: This isn't a type.
-// extension Extension on Class {
-// ^^^^^^^^^
-//
-// pkg/front_end/testcases/extensions/extension_constructor.dart:11:11: Error: 'Extension' isn't a type.
-// factory Extension.redirect() = Extension;
-// ^^^^^^^^^
-// pkg/front_end/testcases/extensions/extension_constructor.dart:7:11: Context: This isn't a type.
-// extension Extension on Class {
-// ^^^^^^^^^
-//
import self as self;
import "dart:core" as core;
diff --git a/pkg/front_end/testcases/extensions/extension_constructor.dart.weak.transformed.expect b/pkg/front_end/testcases/extensions/extension_constructor.dart.weak.transformed.expect
index e059431..8400d5d 100644
--- a/pkg/front_end/testcases/extensions/extension_constructor.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/extensions/extension_constructor.dart.weak.transformed.expect
@@ -22,20 +22,6 @@
// factory Extension.redirect() = Extension;
// ^^^^^^^
//
-// pkg/front_end/testcases/extensions/extension_constructor.dart:10:11: Error: 'Extension' isn't a type.
-// factory Extension.fact() => null;
-// ^^^^^^^^^
-// pkg/front_end/testcases/extensions/extension_constructor.dart:7:11: Context: This isn't a type.
-// extension Extension on Class {
-// ^^^^^^^^^
-//
-// pkg/front_end/testcases/extensions/extension_constructor.dart:11:11: Error: 'Extension' isn't a type.
-// factory Extension.redirect() = Extension;
-// ^^^^^^^^^
-// pkg/front_end/testcases/extensions/extension_constructor.dart:7:11: Context: This isn't a type.
-// extension Extension on Class {
-// ^^^^^^^^^
-//
import self as self;
import "dart:core" as core;
diff --git a/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart b/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart
new file mode 100644
index 0000000..0a2236e
--- /dev/null
+++ b/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart
@@ -0,0 +1,13 @@
+// Copyright (c) 2021, 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.
+
+// @dart=2.14
+
+class A {}
+
+extension E on A {}
+
+test(E e) {} // Error.
+
+main() {}
diff --git a/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.textual_outline.expect b/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.textual_outline.expect
new file mode 100644
index 0000000..9bafc2d
--- /dev/null
+++ b/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.textual_outline.expect
@@ -0,0 +1,7 @@
+// @dart = 2.14
+class A {}
+
+extension E on A {}
+
+test(E e) {}
+main() {}
diff --git a/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..5ef7180
--- /dev/null
+++ b/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.textual_outline_modelled.expect
@@ -0,0 +1,7 @@
+// @dart = 2.14
+class A {}
+
+extension E on A {}
+
+main() {}
+test(E e) {}
diff --git a/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.weak.expect b/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.weak.expect
new file mode 100644
index 0000000..bc4eb86
--- /dev/null
+++ b/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.weak.expect
@@ -0,0 +1,25 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart:11:6: Error: This requires the 'extension-types' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// test(E e) {} // Error.
+// ^
+//
+// pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart:11:6: Error: 'E' isn't a type.
+// test(E e) {} // Error.
+// ^
+//
+import self as self;
+import "dart:core" as core;
+
+class A extends core::Object {
+ synthetic constructor •() → self::A
+ : super core::Object::•()
+ ;
+}
+extension E on self::A {
+}
+static method test(invalid-type e) → dynamic {}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.weak.outline.expect b/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.weak.outline.expect
new file mode 100644
index 0000000..1a1b4af
--- /dev/null
+++ b/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.weak.outline.expect
@@ -0,0 +1,22 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart:11:6: Error: This requires the 'extension-types' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// test(E e) {} // Error.
+// ^
+//
+import self as self;
+import "dart:core" as core;
+
+class A extends core::Object {
+ synthetic constructor •() → self::A
+ ;
+}
+extension E on self::A {
+}
+static method test(invalid-type e) → dynamic
+ ;
+static method main() → dynamic
+ ;
diff --git a/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.weak.transformed.expect b/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.weak.transformed.expect
new file mode 100644
index 0000000..bc4eb86
--- /dev/null
+++ b/pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart.weak.transformed.expect
@@ -0,0 +1,25 @@
+library /*isNonNullableByDefault*/;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart:11:6: Error: This requires the 'extension-types' language feature to be enabled.
+// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.15 or higher, and running 'pub get'.
+// test(E e) {} // Error.
+// ^
+//
+// pkg/front_end/testcases/general/extension_type_when_experiment_not_enabled.dart:11:6: Error: 'E' isn't a type.
+// test(E e) {} // Error.
+// ^
+//
+import self as self;
+import "dart:core" as core;
+
+class A extends core::Object {
+ synthetic constructor •() → self::A
+ : super core::Object::•()
+ ;
+}
+extension E on self::A {
+}
+static method test(invalid-type e) → dynamic {}
+static method main() → dynamic {}
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler.cc b/runtime/vm/compiler/backend/flow_graph_compiler.cc
index d920a61..274a04f 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler.cc
@@ -442,10 +442,9 @@
}
#endif
-void FlowGraphCompiler::RecordCatchEntryMoves(Environment* env,
- intptr_t try_index) {
+void FlowGraphCompiler::RecordCatchEntryMoves(Environment* env) {
#if defined(DART_PRECOMPILER)
- try_index = try_index != kInvalidTryIndex ? try_index : CurrentTryIndex();
+ const intptr_t try_index = CurrentTryIndex();
if (is_optimizing() && env != nullptr && (try_index != kInvalidTryIndex)) {
env = env->Outermost();
CatchBlockEntryInstr* catch_block =
@@ -487,7 +486,7 @@
catch_entry_moves_maps_builder_->EndMapping();
}
-#endif // defined(DART_PRECOMPILER) || defined(DART_PRECOMPILED_RUNTIME)
+#endif // defined(DART_PRECOMPILER)
}
void FlowGraphCompiler::EmitCallsiteMetadata(const InstructionSource& source,
@@ -1449,8 +1448,7 @@
}
if (is_optimizing()) {
- EmitMegamorphicInstanceCall(ic_data_in, deopt_id, source, locs,
- kInvalidTryIndex);
+ EmitMegamorphicInstanceCall(ic_data_in, deopt_id, source, locs);
return;
}
@@ -2394,9 +2392,8 @@
__ Bind(&next_test);
}
if (add_megamorphic_call) {
- int try_index = kInvalidTryIndex;
EmitMegamorphicInstanceCall(function_name, arguments_descriptor, deopt_id,
- source_index, locs, try_index);
+ source_index, locs);
}
}
@@ -3232,6 +3229,7 @@
#define __ compiler->assembler()->
void ThrowErrorSlowPathCode::EmitNativeCode(FlowGraphCompiler* compiler) {
+ RELEASE_ASSERT(try_index_ == compiler->CurrentTryIndex());
if (compiler::Assembler::EmittingComments()) {
__ Comment("slow path %s operation", name());
}
@@ -3254,18 +3252,17 @@
__ CallRuntime(runtime_entry_, num_args);
}
const intptr_t deopt_id = instruction()->deopt_id();
- compiler->AddDescriptor(UntaggedPcDescriptors::kOther,
- compiler->assembler()->CodeSize(), deopt_id,
- instruction()->source(), try_index_);
+ compiler->AddCurrentDescriptor(UntaggedPcDescriptors::kOther, deopt_id,
+ instruction()->source());
AddMetadataForRuntimeCall(compiler);
compiler->RecordSafepoint(locs, num_args);
- if (!FLAG_precompiled_mode || (try_index_ != kInvalidTryIndex) ||
+ if (!FLAG_precompiled_mode ||
(compiler->CurrentTryIndex() != kInvalidTryIndex)) {
Environment* env =
compiler->SlowPathEnvironmentFor(instruction(), num_args);
// TODO(47044): Should be able to say `FLAG_precompiled_mode` instead.
if (CompilerState::Current().is_aot()) {
- compiler->RecordCatchEntryMoves(env, try_index_);
+ compiler->RecordCatchEntryMoves(env);
} else if (compiler->is_optimizing()) {
ASSERT(env != nullptr);
compiler->AddSlowPathDeoptInfo(deopt_id, env);
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler.h b/runtime/vm/compiler/backend/flow_graph_compiler.h
index 4d80627..c6cda87 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler.h
+++ b/runtime/vm/compiler/backend/flow_graph_compiler.h
@@ -760,24 +760,19 @@
void EmitMegamorphicInstanceCall(const ICData& icdata,
intptr_t deopt_id,
const InstructionSource& source,
- LocationSummary* locs,
- intptr_t try_index,
- intptr_t slow_path_argument_count = 0) {
+ LocationSummary* locs) {
const String& name = String::Handle(icdata.target_name());
const Array& arguments_descriptor =
Array::Handle(icdata.arguments_descriptor());
EmitMegamorphicInstanceCall(name, arguments_descriptor, deopt_id, source,
- locs, try_index);
+ locs);
}
- // Pass a value for try-index where block is not available (e.g. slow path).
void EmitMegamorphicInstanceCall(const String& function_name,
const Array& arguments_descriptor,
intptr_t deopt_id,
const InstructionSource& source,
- LocationSummary* locs,
- intptr_t try_index,
- intptr_t slow_path_argument_count = 0);
+ LocationSummary* locs);
void EmitInstanceCallAOT(
const ICData& ic_data,
@@ -818,8 +813,7 @@
void EmitEdgeCounter(intptr_t edge_id);
- void RecordCatchEntryMoves(Environment* env,
- intptr_t try_index = kInvalidTryIndex);
+ void RecordCatchEntryMoves(Environment* env);
void EmitCallToStub(const Code& stub);
void EmitTailCallToStub(const Code& stub);
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc b/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc
index 746b275..35dcb71 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc
@@ -566,9 +566,7 @@
const Array& arguments_descriptor,
intptr_t deopt_id,
const InstructionSource& source,
- LocationSummary* locs,
- intptr_t try_index,
- intptr_t slow_path_argument_count) {
+ LocationSummary* locs) {
ASSERT(CanCallDart());
ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0));
const ArgumentsDescriptor args_desc(arguments_descriptor);
@@ -603,26 +601,20 @@
CODE_REG, Code::entry_point_offset(Code::EntryKind::kMonomorphic)));
}
- RecordSafepoint(locs, slow_path_argument_count);
- const intptr_t deopt_id_after = DeoptId::ToDeoptAfter(deopt_id);
- if (FLAG_precompiled_mode) {
- // Megamorphic calls may occur in slow path stubs.
- // If valid use try_index argument.
- if (try_index == kInvalidTryIndex) {
- try_index = CurrentTryIndex();
+ RecordSafepoint(locs);
+ AddCurrentDescriptor(UntaggedPcDescriptors::kOther, DeoptId::kNone, source);
+ if (!FLAG_precompiled_mode) {
+ const intptr_t deopt_id_after = DeoptId::ToDeoptAfter(deopt_id);
+ if (is_optimizing()) {
+ AddDeoptIndexAtCall(deopt_id_after, pending_deoptimization_env_);
+ } else {
+ // Add deoptimization continuation point after the call and before the
+ // arguments are removed.
+ AddCurrentDescriptor(UntaggedPcDescriptors::kDeopt, deopt_id_after,
+ source);
}
- AddDescriptor(UntaggedPcDescriptors::kOther, assembler()->CodeSize(),
- DeoptId::kNone, source, try_index);
- } else if (is_optimizing()) {
- AddCurrentDescriptor(UntaggedPcDescriptors::kOther, DeoptId::kNone, source);
- AddDeoptIndexAtCall(deopt_id_after, pending_deoptimization_env_);
- } else {
- AddCurrentDescriptor(UntaggedPcDescriptors::kOther, DeoptId::kNone, source);
- // Add deoptimization continuation point after the call and before the
- // arguments are removed.
- AddCurrentDescriptor(UntaggedPcDescriptors::kDeopt, deopt_id_after, source);
}
- RecordCatchEntryMoves(pending_deoptimization_env_, try_index);
+ RecordCatchEntryMoves(pending_deoptimization_env_);
__ Drop(args_desc.SizeWithTypeArgs());
}
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc b/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc
index 4cc8af9..b3e65ad 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc
@@ -557,9 +557,7 @@
const Array& arguments_descriptor,
intptr_t deopt_id,
const InstructionSource& source,
- LocationSummary* locs,
- intptr_t try_index,
- intptr_t slow_path_argument_count) {
+ LocationSummary* locs) {
ASSERT(CanCallDart());
ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0));
const ArgumentsDescriptor args_desc(arguments_descriptor);
@@ -590,26 +588,20 @@
}
CLOBBERS_LR(__ blr(LR));
- RecordSafepoint(locs, slow_path_argument_count);
- const intptr_t deopt_id_after = DeoptId::ToDeoptAfter(deopt_id);
- if (FLAG_precompiled_mode) {
- // Megamorphic calls may occur in slow path stubs.
- // If valid use try_index argument.
- if (try_index == kInvalidTryIndex) {
- try_index = CurrentTryIndex();
+ RecordSafepoint(locs);
+ AddCurrentDescriptor(UntaggedPcDescriptors::kOther, DeoptId::kNone, source);
+ if (!FLAG_precompiled_mode) {
+ const intptr_t deopt_id_after = DeoptId::ToDeoptAfter(deopt_id);
+ if (is_optimizing()) {
+ AddDeoptIndexAtCall(deopt_id_after, pending_deoptimization_env_);
+ } else {
+ // Add deoptimization continuation point after the call and before the
+ // arguments are removed.
+ AddCurrentDescriptor(UntaggedPcDescriptors::kDeopt, deopt_id_after,
+ source);
}
- AddDescriptor(UntaggedPcDescriptors::kOther, assembler()->CodeSize(),
- DeoptId::kNone, source, try_index);
- } else if (is_optimizing()) {
- AddCurrentDescriptor(UntaggedPcDescriptors::kOther, DeoptId::kNone, source);
- AddDeoptIndexAtCall(deopt_id_after, pending_deoptimization_env_);
- } else {
- AddCurrentDescriptor(UntaggedPcDescriptors::kOther, DeoptId::kNone, source);
- // Add deoptimization continuation point after the call and before the
- // arguments are removed.
- AddCurrentDescriptor(UntaggedPcDescriptors::kDeopt, deopt_id_after, source);
}
- RecordCatchEntryMoves(pending_deoptimization_env_, try_index);
+ RecordCatchEntryMoves(pending_deoptimization_env_);
__ Drop(args_desc.SizeWithTypeArgs());
}
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc b/runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc
index 5201548..0b232dd 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc
@@ -596,9 +596,7 @@
const Array& arguments_descriptor,
intptr_t deopt_id,
const InstructionSource& source,
- LocationSummary* locs,
- intptr_t try_index,
- intptr_t slow_path_argument_count) {
+ LocationSummary* locs) {
ASSERT(CanCallDart());
ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0));
const ArgumentsDescriptor args_desc(arguments_descriptor);
@@ -615,7 +613,7 @@
CODE_REG, Code::entry_point_offset(Code::EntryKind::kMonomorphic)));
AddCurrentDescriptor(UntaggedPcDescriptors::kOther, DeoptId::kNone, source);
- RecordSafepoint(locs, slow_path_argument_count);
+ RecordSafepoint(locs);
const intptr_t deopt_id_after = DeoptId::ToDeoptAfter(deopt_id);
// Precompilation not implemented on ia32 platform.
ASSERT(!FLAG_precompiled_mode);
@@ -626,7 +624,7 @@
// arguments are removed.
AddCurrentDescriptor(UntaggedPcDescriptors::kDeopt, deopt_id_after, source);
}
- RecordCatchEntryMoves(pending_deoptimization_env_, try_index);
+ RecordCatchEntryMoves(pending_deoptimization_env_);
__ Drop(args_desc.SizeWithTypeArgs());
}
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc b/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc
index 0dcad25..81c4cac 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc
@@ -566,9 +566,7 @@
const Array& arguments_descriptor,
intptr_t deopt_id,
const InstructionSource& source,
- LocationSummary* locs,
- intptr_t try_index,
- intptr_t slow_path_argument_count) {
+ LocationSummary* locs) {
ASSERT(CanCallDart());
ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0));
const ArgumentsDescriptor args_desc(arguments_descriptor);
@@ -600,26 +598,20 @@
CODE_REG, Code::entry_point_offset(Code::EntryKind::kMonomorphic)));
}
- RecordSafepoint(locs, slow_path_argument_count);
- const intptr_t deopt_id_after = DeoptId::ToDeoptAfter(deopt_id);
- if (FLAG_precompiled_mode) {
- // Megamorphic calls may occur in slow path stubs.
- // If valid use try_index argument.
- if (try_index == kInvalidTryIndex) {
- try_index = CurrentTryIndex();
+ RecordSafepoint(locs);
+ AddCurrentDescriptor(UntaggedPcDescriptors::kOther, DeoptId::kNone, source);
+ if (!FLAG_precompiled_mode) {
+ const intptr_t deopt_id_after = DeoptId::ToDeoptAfter(deopt_id);
+ if (is_optimizing()) {
+ AddDeoptIndexAtCall(deopt_id_after, pending_deoptimization_env_);
+ } else {
+ // Add deoptimization continuation point after the call and before the
+ // arguments are removed.
+ AddCurrentDescriptor(UntaggedPcDescriptors::kDeopt, deopt_id_after,
+ source);
}
- AddDescriptor(UntaggedPcDescriptors::kOther, assembler()->CodeSize(),
- DeoptId::kNone, source, try_index);
- } else if (is_optimizing()) {
- AddCurrentDescriptor(UntaggedPcDescriptors::kOther, DeoptId::kNone, source);
- AddDeoptIndexAtCall(deopt_id_after, pending_deoptimization_env_);
- } else {
- AddCurrentDescriptor(UntaggedPcDescriptors::kOther, DeoptId::kNone, source);
- // Add deoptimization continuation point after the call and before the
- // arguments are removed.
- AddCurrentDescriptor(UntaggedPcDescriptors::kDeopt, deopt_id_after, source);
}
- RecordCatchEntryMoves(pending_deoptimization_env_, try_index);
+ RecordCatchEntryMoves(pending_deoptimization_env_);
__ Drop(args_desc.SizeWithTypeArgs(), RCX);
}
diff --git a/runtime/vm/compiler/backend/il_arm.cc b/runtime/vm/compiler/backend/il_arm.cc
index b211af2..30015fa 100644
--- a/runtime/vm/compiler/backend/il_arm.cc
+++ b/runtime/vm/compiler/backend/il_arm.cc
@@ -3665,10 +3665,9 @@
__ Call(compiler::Address(THR, entry_point_offset));
compiler->RecordSafepoint(instruction()->locs(), kNumSlowPathArgs);
compiler->RecordCatchEntryMoves(env);
- compiler->AddDescriptor(
- UntaggedPcDescriptors::kOther, compiler->assembler()->CodeSize(),
- instruction()->deopt_id(), instruction()->source(),
- compiler->CurrentTryIndex());
+ compiler->AddCurrentDescriptor(UntaggedPcDescriptors::kOther,
+ instruction()->deopt_id(),
+ instruction()->source());
} else {
__ CallRuntime(kStackOverflowRuntimeEntry, kNumSlowPathArgs);
compiler->EmitCallsiteMetadata(
diff --git a/runtime/vm/compiler/backend/il_arm64.cc b/runtime/vm/compiler/backend/il_arm64.cc
index 3550f0c..7432fad 100644
--- a/runtime/vm/compiler/backend/il_arm64.cc
+++ b/runtime/vm/compiler/backend/il_arm64.cc
@@ -3222,10 +3222,9 @@
}
compiler->RecordSafepoint(locs, kNumSlowPathArgs);
compiler->RecordCatchEntryMoves(env);
- compiler->AddDescriptor(
- UntaggedPcDescriptors::kOther, compiler->assembler()->CodeSize(),
- instruction()->deopt_id(), instruction()->source(),
- compiler->CurrentTryIndex());
+ compiler->AddCurrentDescriptor(UntaggedPcDescriptors::kOther,
+ instruction()->deopt_id(),
+ instruction()->source());
} else {
__ CallRuntime(kStackOverflowRuntimeEntry, kNumSlowPathArgs);
compiler->EmitCallsiteMetadata(
diff --git a/runtime/vm/compiler/backend/il_x64.cc b/runtime/vm/compiler/backend/il_x64.cc
index e780e03..5537222 100644
--- a/runtime/vm/compiler/backend/il_x64.cc
+++ b/runtime/vm/compiler/backend/il_x64.cc
@@ -3308,10 +3308,9 @@
__ call(compiler::Address(THR, entry_point_offset));
compiler->RecordSafepoint(instruction()->locs(), kNumSlowPathArgs);
compiler->RecordCatchEntryMoves(env);
- compiler->AddDescriptor(
- UntaggedPcDescriptors::kOther, compiler->assembler()->CodeSize(),
- instruction()->deopt_id(), instruction()->source(),
- compiler->CurrentTryIndex());
+ compiler->AddCurrentDescriptor(UntaggedPcDescriptors::kOther,
+ instruction()->deopt_id(),
+ instruction()->source());
} else {
__ CallRuntime(kStackOverflowRuntimeEntry, kNumSlowPathArgs);
compiler->EmitCallsiteMetadata(
diff --git a/tools/VERSION b/tools/VERSION
index a787f08..51b89ce 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 15
PATCH 0
-PRERELEASE 110
+PRERELEASE 111
PRERELEASE_PATCH 0
\ No newline at end of file