Version 2.17.0-165.0.dev
Merge commit 'ed48a944d0321f28725d8548cc1f177146c81c63' into 'dev'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d06a699..70414c2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -60,6 +60,9 @@
- Add a optional `keyLog` parameter to `SecureSocket.connect` and
`SecureSocket.startConnect`.
+- Deprecate `SecureSocket.renegotiate` and `RawSecureSocket.renegotiate`,
+ which were no-ops.
+
### Tools
#### Dart command line
diff --git a/pkg/analysis_server/lib/src/services/refactoring/inline_method.dart b/pkg/analysis_server/lib/src/services/refactoring/inline_method.dart
index 1f66fe6..8a99365 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/inline_method.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/inline_method.dart
@@ -161,9 +161,10 @@
{
var enclosingClassElement = getEnclosingClassElement(node);
if (enclosingClassElement != null) {
- var elements = <ClassElement>{};
- elements.add(enclosingClassElement);
- elements.addAll(getSuperClasses(enclosingClassElement));
+ var elements = [
+ ...enclosingClassElement.allSupertypes.map((e) => e.element),
+ enclosingClassElement,
+ ];
for (var classElement in elements) {
var classMembers = getChildren(classElement);
for (var classMemberElement in classMembers) {
diff --git a/pkg/analysis_server/lib/src/services/refactoring/rename_class_member.dart b/pkg/analysis_server/lib/src/services/refactoring/rename_class_member.dart
index 91654f8..4d55c6c 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/rename_class_member.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/rename_class_member.dart
@@ -160,9 +160,9 @@
Future<void> _checkHierarchy({
required bool isRename,
- required Set<ClassElement> superClasses,
required Set<ClassElement> subClasses,
}) async {
+ var superClasses = elementClass.allSupertypes.map((e) => e.element).toSet();
// check shadowing in the hierarchy
var declarations = await searchEngine.searchMemberDeclarations(name);
for (var declaration in declarations) {
@@ -212,19 +212,18 @@
Future<RefactoringStatus> validate() async {
_checkClassAlreadyDeclares();
// do chained computations
- var superClasses = getSuperClasses(elementClass);
var subClasses = await searchEngine.searchAllSubtypes(elementClass);
// check shadowing of class names
if (elementClass.name == name) {
result.addError(
- format("Created {0} has the same name as the declaring class '{1}'.",
- elementKind.displayName, name),
- newLocation_fromElement(elementClass));
+ 'Created ${elementKind.displayName} has the same name as the '
+ "declaring ${elementClass.kind.displayName} '$name'.",
+ newLocation_fromElement(elementClass),
+ );
}
// check shadowing in the hierarchy
await _checkHierarchy(
isRename: false,
- superClasses: superClasses,
subClasses: subClasses,
);
// done
@@ -272,7 +271,6 @@
Future<RefactoringStatus> validate() async {
_checkClassAlreadyDeclares();
// do chained computations
- var superClasses = getSuperClasses(elementClass);
await _prepareReferences();
var subClasses = await searchEngine.searchAllSubtypes(elementClass);
// check shadowing of class names
@@ -280,11 +278,8 @@
var enclosingElement = element.enclosingElement;
if (enclosingElement is ClassElement && enclosingElement.name == name) {
result.addError(
- format(
- "Renamed {0} has the same name as the declaring class '{1}'.",
- elementKind.displayName,
- name,
- ),
+ 'Renamed ${elementKind.displayName} has the same name as the '
+ "declaring ${enclosingElement.kind.displayName} '$name'.",
newLocation_fromElement(element),
);
}
@@ -306,7 +301,6 @@
// check shadowing in the hierarchy
await _checkHierarchy(
isRename: true,
- superClasses: superClasses,
subClasses: subClasses,
);
// visibility
diff --git a/pkg/analysis_server/lib/src/services/search/hierarchy.dart b/pkg/analysis_server/lib/src/services/search/hierarchy.dart
index 05d4116..eda9ad4 100644
--- a/pkg/analysis_server/lib/src/services/search/hierarchy.dart
+++ b/pkg/analysis_server/lib/src/services/search/hierarchy.dart
@@ -95,8 +95,10 @@
// method, field, etc
if (enclosingElement is ClassElement) {
var name = member.displayName;
- var searchClasses = getSuperClasses(enclosingElement);
- searchClasses.add(enclosingElement);
+ var searchClasses = [
+ ...enclosingElement.allSupertypes.map((e) => e.element),
+ enclosingElement,
+ ];
for (var superClass in searchClasses) {
// ignore if super- class does not declare member
if (getClassMembers(superClass, name).isEmpty) {
@@ -152,49 +154,17 @@
///
/// Excludes: constructors and synthetic elements.
List<Element> getMembers(ClassElement clazz) {
+ var classElements = [
+ ...clazz.allSupertypes.map((e) => e.element),
+ clazz,
+ ];
var members = <Element>[];
- members.addAll(getClassMembers(clazz));
- var superClasses = getSuperClasses(clazz);
- for (var superClass in superClasses) {
+ for (var superClass in classElements) {
members.addAll(getClassMembers(superClass));
}
return members;
}
-/// Returns a [Set] with all direct and indirect superclasses of [seed].
-Set<ClassElement> getSuperClasses(ClassElement seed) {
- Set<ClassElement> result = HashSet<ClassElement>();
- // prepare queue
- var queue = <ClassElement>[];
- queue.add(seed);
- // process queue
- while (queue.isNotEmpty) {
- var current = queue.removeLast();
- // add if not checked already
- if (!result.add(current)) {
- continue;
- }
- // append supertype
- {
- var superType = current.supertype;
- if (superType != null) {
- queue.add(superType.element);
- }
- }
- // append superclass constraints
- for (var interface in current.superclassConstraints) {
- queue.add(interface.element);
- }
- // append interfaces
- for (var interface in current.interfaces) {
- queue.add(interface.element);
- }
- }
- // we don't need "seed" itself
- result.remove(seed);
- return result;
-}
-
/// If the given [element] is a synthetic [PropertyAccessorElement] returns
/// its variable, otherwise returns [element].
Element getSyntheticAccessorVariable(Element element) {
diff --git a/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart b/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
index 27a8207..6d0c321 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
@@ -11,12 +11,13 @@
void main() {
defineReflectiveSuite(() {
- defineReflectiveTests(RenameClassMemberTest);
+ defineReflectiveTests(RenameClassMemberClassTest);
+ defineReflectiveTests(RenameClassMemberEnumTest);
});
}
@reflectiveTest
-class RenameClassMemberTest extends RenameRefactoringTest {
+class RenameClassMemberClassTest extends RenameRefactoringTest {
Future<void> test_checkFinalConditions_classNameConflict_sameClass() async {
await indexTestUnit('''
class NewName {
@@ -1047,3 +1048,573 @@
''');
}
}
+
+@reflectiveTest
+class RenameClassMemberEnumTest extends RenameRefactoringTest {
+ Future<void> test_checkFinalConditions_classNameConflict_sameClass() async {
+ await indexTestUnit('''
+enum NewName {
+ v;
+ void test() {}
+}
+''');
+ createRenameRefactoringAtString('test() {}');
+ // check status
+ refactoring.newName = 'NewName';
+ var status = await refactoring.checkFinalConditions();
+ assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
+ expectedMessage:
+ "Renamed method has the same name as the declaring enum 'NewName'.",
+ expectedContextSearch: 'test() {}');
+ }
+
+ Future<void> test_checkFinalConditions_classNameConflict_superClass() async {
+ await indexTestUnit('''
+class NewName {
+ void test() {} // 1
+}
+enum E implements NewName {
+ v;
+ void test() {} // 2
+}
+''');
+ createRenameRefactoringAtString('test() {} // 2');
+ // check status
+ refactoring.newName = 'NewName';
+ var status = await refactoring.checkFinalConditions();
+ assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
+ expectedMessage:
+ "Renamed method has the same name as the declaring class 'NewName'.",
+ expectedContextSearch: 'test() {} // 1');
+ }
+
+ Future<void> test_checkFinalConditions_hasMember_MethodElement() async {
+ await indexTestUnit('''
+enum E {
+ v;
+ test() {}
+ newName() {} // existing
+}
+''');
+ createRenameRefactoringAtString('test() {}');
+ // check status
+ refactoring.newName = 'newName';
+ var status = await refactoring.checkFinalConditions();
+ assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
+ expectedMessage:
+ "Class 'E' already declares method with name 'newName'.",
+ expectedContextSearch: 'newName() {} // existing');
+ }
+
+ Future<void> test_checkFinalConditions_OK_dropSuffix() async {
+ await indexTestUnit(r'''
+abstract class A {
+ void testOld();
+}
+enum E implements A {
+ v;
+ void testOld() {}
+}
+''');
+ createRenameRefactoringAtString('testOld() {}');
+ // check status
+ refactoring.newName = 'test';
+ var status = await refactoring.checkFinalConditions();
+ assertRefactoringStatusOK(status);
+ }
+
+ Future<void> test_checkFinalConditions_publicToPrivate_used() async {
+ await indexTestUnit('''
+enum E {
+ v;
+ void test() {}
+}
+''');
+ await indexUnit('$testPackageLibPath/lib.dart', '''
+import 'test.dart';
+
+void f(E e) {
+ e.test();
+}
+''');
+ createRenameRefactoringAtString('test()');
+ // check status
+ refactoring.newName = '_newName';
+ var status = await refactoring.checkFinalConditions();
+ assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
+ expectedMessage:
+ "Renamed method will be invisible in '${convertPath("lib/lib.dart")}'.");
+ }
+
+ Future<void>
+ test_checkFinalConditions_shadowed_byLocalFunction_inSameClass() async {
+ await indexTestUnit('''
+enum E {
+ v;
+ void test() {}
+ void f() {
+ newName() {}
+ test(); // marker
+ }
+}
+''');
+ createRenameRefactoringAtString('test() {}');
+ // check status
+ refactoring.newName = 'newName';
+ var status = await refactoring.checkFinalConditions();
+ assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
+ expectedMessage:
+ "Usage of renamed method will be shadowed by function 'newName'.",
+ expectedContextSearch: 'test(); // marker');
+ }
+
+ Future<void>
+ test_checkFinalConditions_shadowed_byLocalVariable_inSameClass() async {
+ await indexTestUnit('''
+enum E {
+ v;
+ void test() {}
+ void f() {
+ var newName;
+ test(); // marker
+ }
+}
+''');
+ createRenameRefactoringAtString('test() {}');
+ // check status
+ refactoring.newName = 'newName';
+ var status = await refactoring.checkFinalConditions();
+ assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
+ expectedMessage:
+ "Usage of renamed method will be shadowed by local variable 'newName'.",
+ expectedContextSearch: 'test(); // marker');
+ }
+
+ Future<void>
+ test_checkFinalConditions_shadowed_byLocalVariable_OK_qualifiedReference() async {
+ await indexTestUnit('''
+enum E {
+ v;
+ void test() {}
+ void f() {
+ var newName;
+ this.test(); // marker
+ }
+}
+''');
+ createRenameRefactoringAtString('test() {}');
+ // check status
+ refactoring.newName = 'newName';
+ var status = await refactoring.checkFinalConditions();
+ assertRefactoringStatusOK(status);
+ }
+
+ Future<void>
+ test_checkFinalConditions_shadowed_byLocalVariable_OK_renamedNotUsed() async {
+ await indexTestUnit('''
+enum E {
+ v;
+ void test() {}
+ void f() {
+ var newName;
+ }
+}
+''');
+ createRenameRefactoringAtString('test() {}');
+ // check status
+ refactoring.newName = 'newName';
+ var status = await refactoring.checkFinalConditions();
+ assertRefactoringStatusOK(status);
+ }
+
+ Future<void>
+ test_checkFinalConditions_shadowed_byParameter_inSameClass() async {
+ await indexTestUnit('''
+enum E {
+ v;
+ void test() {}
+ void f(newName) {
+ test(); // marker
+ }
+}
+''');
+ createRenameRefactoringAtString('test() {}');
+ // check status
+ refactoring.newName = 'newName';
+ var status = await refactoring.checkFinalConditions();
+ assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
+ expectedMessage:
+ "Usage of renamed method will be shadowed by parameter 'newName'.",
+ expectedContextSearch: 'test(); // marker');
+ }
+
+ Future<void> test_checkFinalConditions_shadowsSuper_MethodElement() async {
+ await indexTestUnit('''
+mixin M {
+ void newName() {}
+}
+enum E with M {
+ v;
+ void test() {}
+ void f() {
+ newName();
+ }
+}
+''');
+ createRenameRefactoringAtString('test() {}');
+ // check status
+ refactoring.newName = 'newName';
+ var status = await refactoring.checkFinalConditions();
+ assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
+ expectedMessage: "Renamed method will shadow method 'M.newName'.",
+ expectedContextSearch: 'newName() {}');
+ }
+
+ Future<void>
+ test_checkFinalConditions_shadowsSuper_MethodElement_otherLib() async {
+ var libCode = r'''
+mixin M {
+ void newName() {}
+}
+''';
+ await indexUnit('$testPackageLibPath/lib.dart', libCode);
+ await indexTestUnit('''
+import 'lib.dart';
+enum E with M {
+ v;
+ void test() {}
+ void f() {
+ newName();
+ }
+}
+''');
+ createRenameRefactoringAtString('test() {}');
+ // check status
+ refactoring.newName = 'newName';
+ var status = await refactoring.checkFinalConditions();
+ assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
+ expectedMessage: "Renamed method will shadow method 'M.newName'.",
+ expectedContextRange:
+ SourceRange(libCode.indexOf('newName() {}'), 'newName'.length));
+ }
+
+ Future<void> test_checkInitialConditions_operator() async {
+ await indexTestUnit('''
+enum E {
+ v;
+ operator -() => this;
+}
+''');
+ createRenameRefactoringAtString('-()');
+ // check status
+ refactoring.newName = 'newName';
+ var status = await refactoring.checkInitialConditions();
+ assertRefactoringStatus(status, RefactoringProblemSeverity.FATAL);
+ }
+
+ Future<void> test_checkNewName_FieldElement() async {
+ await indexTestUnit('''
+enum E {
+ v;
+ final int test = 0;
+}
+''');
+ createRenameRefactoringAtString('test = 0;');
+ // OK
+ refactoring.newName = 'newName';
+ assertRefactoringStatusOK(refactoring.checkNewName());
+ }
+
+ Future<void> test_checkNewName_MethodElement() async {
+ await indexTestUnit('''
+enum E {
+ v;
+ void test() {}
+}
+''');
+ createRenameRefactoringAtString('test() {}');
+ // empty
+ refactoring.newName = '';
+ assertRefactoringStatus(
+ refactoring.checkNewName(), RefactoringProblemSeverity.FATAL,
+ expectedMessage: 'Method name must not be empty.');
+ // same
+ refactoring.newName = 'test';
+ assertRefactoringStatus(
+ refactoring.checkNewName(), RefactoringProblemSeverity.FATAL,
+ expectedMessage:
+ 'The new name must be different than the current name.');
+ // OK
+ refactoring.newName = 'newName';
+ assertRefactoringStatusOK(refactoring.checkNewName());
+ }
+
+ Future<void> test_createChange_FieldElement() async {
+ verifyNoTestUnitErrors = false;
+ await indexTestUnit('''
+enum E {
+ v;
+ final int test = 0;
+ void f() {
+ test;
+ test = 1;
+ test += 2;
+ }
+}
+void f(E e) {
+ e.test;
+ e.test = 1;
+ e.test += 2;
+}
+''');
+ // configure refactoring
+ createRenameRefactoringAtString('test = 0;');
+ expect(refactoring.refactoringName, 'Rename Field');
+ expect(refactoring.elementKindName, 'field');
+ expect(refactoring.oldName, 'test');
+ refactoring.newName = 'newName';
+ // validate change
+ return assertSuccessfulRefactoring('''
+enum E {
+ v;
+ final int newName = 0;
+ void f() {
+ newName;
+ newName = 1;
+ newName += 2;
+ }
+}
+void f(E e) {
+ e.newName;
+ e.newName = 1;
+ e.newName += 2;
+}
+''');
+ }
+
+ Future<void>
+ test_createChange_FieldElement_constructorFieldInitializer() async {
+ await indexTestUnit('''
+enum E {
+ v;
+ final int test;
+ const E() : test = 5;
+}
+''');
+ // configure refactoring
+ createRenameRefactoringAtString('test;');
+ expect(refactoring.refactoringName, 'Rename Field');
+ expect(refactoring.oldName, 'test');
+ refactoring.newName = 'newName';
+ // validate change
+ return assertSuccessfulRefactoring('''
+enum E {
+ v;
+ final int newName;
+ const E() : newName = 5;
+}
+''');
+ }
+
+ Future<void> test_createChange_FieldElement_fieldFormalParameter() async {
+ await indexTestUnit('''
+enum E {
+ v(0);
+ final int test;
+ const E(this.test);
+}
+''');
+ // configure refactoring
+ createRenameRefactoringAtString('test;');
+ expect(refactoring.refactoringName, 'Rename Field');
+ expect(refactoring.oldName, 'test');
+ refactoring.newName = 'newName';
+ // validate change
+ return assertSuccessfulRefactoring('''
+enum E {
+ v(0);
+ final int newName;
+ const E(this.newName);
+}
+''');
+ }
+
+ Future<void> test_createChange_MethodElement() async {
+ await indexTestUnit('''
+enum E {
+ v;
+ void test() {}
+ void foo() {
+ test();
+ test;
+ }
+}
+
+void f(E e) {
+ e.test();
+ e.test;
+}
+''');
+ // configure refactoring
+ createRenameRefactoringAtString('test() {}');
+ expect(refactoring.refactoringName, 'Rename Method');
+ expect(refactoring.elementKindName, 'method');
+ expect(refactoring.oldName, 'test');
+ refactoring.newName = 'newName';
+ // validate change
+ return assertSuccessfulRefactoring('''
+enum E {
+ v;
+ void newName() {}
+ void foo() {
+ newName();
+ newName;
+ }
+}
+
+void f(E e) {
+ e.newName();
+ e.newName;
+}
+''');
+ }
+
+ Future<void> test_createChange_MethodElement_fromInterface() async {
+ await indexTestUnit('''
+class A {
+ void test() {} // A
+}
+
+enum E implements A {
+ v;
+ void test() {}
+ void foo() {
+ test();
+ }
+}
+''');
+ // configure refactoring
+ createRenameRefactoringAtString('test() {} // A');
+ expect(refactoring.refactoringName, 'Rename Method');
+ expect(refactoring.elementKindName, 'method');
+ expect(refactoring.oldName, 'test');
+ refactoring.newName = 'newName';
+ // validate change
+ return assertSuccessfulRefactoring('''
+class A {
+ void newName() {} // A
+}
+
+enum E implements A {
+ v;
+ void newName() {}
+ void foo() {
+ newName();
+ }
+}
+''');
+ }
+
+ Future<void> test_createChange_MethodElement_fromMixin() async {
+ await indexTestUnit('''
+mixin M {
+ void test() {} // M
+}
+
+enum E with M {
+ v;
+ void test() {}
+ void foo() {
+ test();
+ }
+}
+''');
+ // configure refactoring
+ createRenameRefactoringAtString('test() {} // M');
+ expect(refactoring.refactoringName, 'Rename Method');
+ expect(refactoring.elementKindName, 'method');
+ expect(refactoring.oldName, 'test');
+ refactoring.newName = 'newName';
+ // validate change
+ return assertSuccessfulRefactoring('''
+mixin M {
+ void newName() {} // M
+}
+
+enum E with M {
+ v;
+ void newName() {}
+ void foo() {
+ newName();
+ }
+}
+''');
+ }
+
+ Future<void> test_createChange_PropertyAccessorElement() async {
+ await indexTestUnit('''
+enum E {
+ v;
+ int get test => 0;
+ set test(int _) {}
+ void f() {
+ test;
+ test = 0;
+ }
+}
+void f(E e) {
+ e.test;
+ e.test = 1;
+ e.test += 2;
+}
+''');
+ // configure refactoring
+ createRenameRefactoringAtString('test => 0;');
+ expect(refactoring.refactoringName, 'Rename Field');
+ expect(refactoring.oldName, 'test');
+ refactoring.newName = 'newName';
+ // validate change
+ return assertSuccessfulRefactoring('''
+enum E {
+ v;
+ int get newName => 0;
+ set newName(int _) {}
+ void f() {
+ newName;
+ newName = 0;
+ }
+}
+void f(E e) {
+ e.newName;
+ e.newName = 1;
+ e.newName += 2;
+}
+''');
+ }
+
+ Future<void> test_createChange_TypeParameterElement() async {
+ await indexTestUnit('''
+enum E<Test> {
+ v;
+ final Test? field = null;
+ final List<Test> items = const [];
+ Test method(Test a) => a;
+}
+''');
+ // configure refactoring
+ createRenameRefactoringAtString('Test> {');
+ expect(refactoring.refactoringName, 'Rename Type Parameter');
+ expect(refactoring.elementKindName, 'type parameter');
+ expect(refactoring.oldName, 'Test');
+ refactoring.newName = 'NewName';
+ // validate change
+ return assertSuccessfulRefactoring('''
+enum E<NewName> {
+ v;
+ final NewName? field = null;
+ final List<NewName> items = const [];
+ NewName method(NewName a) => a;
+}
+''');
+ }
+}
diff --git a/pkg/analysis_server/test/services/search/hierarchy_test.dart b/pkg/analysis_server/test/services/search/hierarchy_test.dart
index 9ac31f4..17454ea 100644
--- a/pkg/analysis_server/test/services/search/hierarchy_test.dart
+++ b/pkg/analysis_server/test/services/search/hierarchy_test.dart
@@ -391,99 +391,6 @@
}
}
- Future<void> test_getSuperClasses() async {
- await _indexTestUnit('''
-class A {}
-class B extends A {}
-class C extends B {}
-class D extends B implements A {}
-class M {}
-class E extends A with M {}
-class F implements A {}
-''');
- var classA = findElement.class_('A');
- var classB = findElement.class_('B');
- var classC = findElement.class_('C');
- var classD = findElement.class_('D');
- var classE = findElement.class_('E');
- var classF = findElement.class_('F');
- var objectElement = classA.supertype!.element;
- // Object
- {
- var supers = getSuperClasses(objectElement);
- expect(supers, isEmpty);
- }
- // A
- {
- var supers = getSuperClasses(classA);
- expect(supers, unorderedEquals([objectElement]));
- }
- // B
- {
- var supers = getSuperClasses(classB);
- expect(supers, unorderedEquals([objectElement, classA]));
- }
- // C
- {
- var supers = getSuperClasses(classC);
- expect(supers, unorderedEquals([objectElement, classA, classB]));
- }
- // D
- {
- var supers = getSuperClasses(classD);
- expect(supers, unorderedEquals([objectElement, classA, classB]));
- }
- // E
- {
- var supers = getSuperClasses(classE);
- expect(supers, unorderedEquals([objectElement, classA]));
- }
- // F
- {
- var supers = getSuperClasses(classF);
- expect(supers, unorderedEquals([objectElement, classA]));
- }
- }
-
- Future<void> test_getSuperClasses_superclassConstraints() async {
- await _indexTestUnit('''
-class A {}
-class B extends A {}
-class C {}
-
-mixin M1 on A {}
-mixin M2 on B {}
-mixin M3 on M1 {}
-mixin M4 on M2 {}
-mixin M5 on A, C {}
-''');
- var a = findElement.class_('A');
- var b = findElement.class_('B');
- var c = findElement.class_('C');
- var m1 = findElement.mixin('M1');
- var m2 = findElement.mixin('M2');
- var m3 = findElement.mixin('M3');
- var m4 = findElement.mixin('M4');
- var m5 = findElement.mixin('M5');
- var object = a.supertype!.element;
-
- _assertSuperClasses(object, []);
- _assertSuperClasses(a, [object]);
- _assertSuperClasses(b, [object, a]);
- _assertSuperClasses(c, [object]);
-
- _assertSuperClasses(m1, [object, a]);
- _assertSuperClasses(m2, [object, a, b]);
- _assertSuperClasses(m3, [object, a, m1]);
- _assertSuperClasses(m4, [object, a, b, m2]);
- _assertSuperClasses(m5, [object, a, c]);
- }
-
- void _assertSuperClasses(ClassElement element, List<ClassElement> expected) {
- var supers = getSuperClasses(element);
- expect(supers, unorderedEquals(expected));
- }
-
Future<void> _indexTestUnit(String code) async {
await resolveTestCode(code);
}
diff --git a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
index 3397ab6..6608327 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
@@ -1507,15 +1507,18 @@
// Prepare information about existing imports.
LibraryDirective? libraryDirective;
var importDirectives = <ImportDirective>[];
- PartDirective? partDirective;
+ ExportDirective? firstExportDirective;
+ PartDirective? firstPartDirective;
var unit = resolvedUnit.unit;
for (var directive in unit.directives) {
if (directive is LibraryDirective) {
libraryDirective = directive;
} else if (directive is ImportDirective) {
importDirectives.add(directive);
+ } else if (directive is ExportDirective) {
+ firstExportDirective ??= directive;
} else if (directive is PartDirective) {
- partDirective = directive;
+ firstPartDirective ??= directive;
}
}
@@ -1634,7 +1637,7 @@
builder.writeln();
}
} else {
- if (isLastExistingDart || isLastExistingPackage) {
+ if (!isDart && (isLastExistingDart || isLastExistingPackage)) {
builder.writeln();
}
}
@@ -1662,9 +1665,22 @@
return;
}
- // Insert imports: before a part directive.
- if (partDirective != null) {
- addInsertion(partDirective.offset, (EditBuilder builder) {
+ // Insert imports: before any export directives.
+ if (firstExportDirective != null) {
+ addInsertion(firstExportDirective.offset, (EditBuilder builder) {
+ for (var i = 0; i < importList.length; i++) {
+ var import = importList[i];
+ writeImport(builder, import);
+ builder.writeln();
+ }
+ builder.writeln();
+ });
+ return;
+ }
+
+ // Insert imports: before any part directives.
+ if (firstPartDirective != null) {
+ addInsertion(firstPartDirective.offset, (EditBuilder builder) {
for (var i = 0; i < importList.length; i++) {
var import = importList[i];
writeImport(builder, import);
diff --git a/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart b/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
index bd2700d..ae38afa 100644
--- a/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
+++ b/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
@@ -1997,6 +1997,23 @@
@reflectiveTest
class ImportLibraryTest extends AbstractContextTest
with DartChangeBuilderMixin {
+ Future<void> test_dart_afterDart_last() async {
+ await _assertImportLibrary(
+ initialCode: '''
+import 'dart:aaa';
+
+class A {}
+''',
+ uriList: ['dart:bbb'],
+ expectedCode: '''
+import 'dart:aaa';
+import 'dart:bbb';
+
+class A {}
+''',
+ );
+ }
+
Future<void> test_dart_beforeDart() async {
await _assertImportLibrary(
initialCode: '''
@@ -2025,6 +2042,20 @@
);
}
+ Future<void> test_dart_beforeExport() async {
+ await _assertImportLibrary(
+ initialCode: '''
+export 'dart:aaa';
+''',
+ uriList: ['dart:bbb'],
+ expectedCode: '''
+import 'dart:bbb';
+
+export 'dart:aaa';
+''',
+ );
+ }
+
Future<void> test_dart_beforePackage() async {
await _assertImportLibrary(
initialCode: '''
@@ -2180,6 +2211,7 @@
await _assertImportLibrary(
initialCode: '''
part 'a.dart';
+part 'b.dart';
''',
uriList: ['dart:aaa', 'dart:bbb'],
expectedCode: '''
@@ -2187,6 +2219,7 @@
import 'dart:bbb';
part 'a.dart';
+part 'b.dart';
''',
);
}
diff --git a/pkg/dartdev/test/commands/create_integration_test.dart b/pkg/dartdev/test/commands/create_integration_test.dart
index 19f93d8..05d0bf0 100644
--- a/pkg/dartdev/test/commands/create_integration_test.dart
+++ b/pkg/dartdev/test/commands/create_integration_test.dart
@@ -97,7 +97,10 @@
p.pubCacheBinPath,
Platform.isWindows ? '${command.first}.bat' : command.first,
),
- command.sublist(1),
+ [
+ ...command.sublist(1),
+ 'web:0', // Allow for binding to a random available port.
+ ],
workingDirectory: workingDir,
environment: {
'PUB_CACHE': p.pubCachePath,
diff --git a/runtime/bin/io_natives.cc b/runtime/bin/io_natives.cc
index ba4c459..6eddb5a 100644
--- a/runtime/bin/io_natives.cc
+++ b/runtime/bin/io_natives.cc
@@ -131,7 +131,6 @@
V(SecureSocket_RegisterBadCertificateCallback, 2) \
V(SecureSocket_RegisterKeyLogPort, 2) \
V(SecureSocket_RegisterHandshakeCompleteCallback, 2) \
- V(SecureSocket_Renegotiate, 4) \
V(SecurityContext_Allocate, 1) \
V(SecurityContext_UsePrivateKeyBytes, 3) \
V(SecurityContext_SetAlpnProtocols, 3) \
diff --git a/runtime/bin/secure_socket_filter.cc b/runtime/bin/secure_socket_filter.cc
index 43e3a9d..9e1492e 100644
--- a/runtime/bin/secure_socket_filter.cc
+++ b/runtime/bin/secure_socket_filter.cc
@@ -175,17 +175,6 @@
GetFilter(args)->GetSelectedProtocol(args);
}
-void FUNCTION_NAME(SecureSocket_Renegotiate)(Dart_NativeArguments args) {
- bool use_session_cache =
- DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 1));
- bool request_client_certificate =
- DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 2));
- bool require_client_certificate =
- DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3));
- GetFilter(args)->Renegotiate(use_session_cache, request_client_certificate,
- require_client_certificate);
-}
-
void FUNCTION_NAME(SecureSocket_RegisterHandshakeCompleteCallback)(
Dart_NativeArguments args) {
Dart_Handle handshake_complete =
@@ -662,17 +651,6 @@
}
}
-void SSLFilter::Renegotiate(bool use_session_cache,
- bool request_client_certificate,
- bool require_client_certificate) {
- // The SSL_REQUIRE_CERTIFICATE option only takes effect if the
- // SSL_REQUEST_CERTIFICATE option is also set, so set it.
- request_client_certificate =
- request_client_certificate || require_client_certificate;
- // TODO(24070, 24069): Implement setting the client certificate parameters,
- // and triggering rehandshake.
-}
-
void SSLFilter::FreeResources() {
if (ssl_ != NULL) {
SSL_free(ssl_);
diff --git a/runtime/bin/secure_socket_filter.h b/runtime/bin/secure_socket_filter.h
index 56f7f58..fe3b778 100644
--- a/runtime/bin/secure_socket_filter.h
+++ b/runtime/bin/secure_socket_filter.h
@@ -85,9 +85,6 @@
void MarkAsTrusted(Dart_NativeArguments args);
int Handshake(Dart_Port reply_port);
void GetSelectedProtocol(Dart_NativeArguments args);
- void Renegotiate(bool use_session_cache,
- bool request_client_certificate,
- bool require_client_certificate);
void RegisterHandshakeCompleteCallback(Dart_Handle handshake_complete);
void RegisterBadCertificateCallback(Dart_Handle callback);
void RegisterKeyLogPort(Dart_Port key_log_port);
diff --git a/runtime/bin/secure_socket_unsupported.cc b/runtime/bin/secure_socket_unsupported.cc
index 37c2972..f64203d 100644
--- a/runtime/bin/secure_socket_unsupported.cc
+++ b/runtime/bin/secure_socket_unsupported.cc
@@ -90,11 +90,6 @@
"Secure Sockets unsupported on this platform"));
}
-void FUNCTION_NAME(SecureSocket_Renegotiate)(Dart_NativeArguments args) {
- Dart_ThrowException(DartUtils::NewDartArgumentError(
- "Secure Sockets unsupported on this platform"));
-}
-
void FUNCTION_NAME(SecureSocket_NewServicePort)(Dart_NativeArguments args) {
Dart_ThrowException(DartUtils::NewDartArgumentError(
"Secure Sockets unsupported on this platform"));
diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc
index 57239ec..e1830d1 100644
--- a/runtime/vm/compiler/aot/precompiler.cc
+++ b/runtime/vm/compiler/aot/precompiler.cc
@@ -871,17 +871,6 @@
function.token_pos().ToCString(),
Function::KindToCString(function.kind()));
}
- if (function.SourceSize() >= FLAG_huge_method_cutoff_in_tokens) {
- THR_Print(
- "Warning: %s from %s is too large. Some optimizations have been "
- "disabled, and the compiler might run out of memory. "
- "Consider refactoring this code into smaller components.\n",
- function.QualifiedUserVisibleNameCString(),
- String::Handle(
- Z, Library::Handle(Z, Class::Handle(Z, function.Owner()).library())
- .url())
- .ToCString());
- }
ASSERT(!function.is_abstract());
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index a7966c7..f68063a 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -18569,11 +18569,18 @@
}
}
const Instance& stack = Instance::Handle(stacktrace());
- strtmp = DartLibraryCalls::ToString(stack);
- const char* stack_str =
- "<Received error while converting stack trace to string>";
- if (!strtmp.IsError()) {
- stack_str = strtmp.ToCString();
+ const char* stack_str;
+ if (stack.IsNull()) {
+ stack_str = "null";
+ } else if (stack.IsStackTrace()) {
+ stack_str = StackTrace::Cast(stack).ToCString();
+ } else {
+ strtmp = DartLibraryCalls::ToString(stack);
+ if (!strtmp.IsError()) {
+ stack_str = strtmp.ToCString();
+ } else {
+ stack_str = "<Received error while converting stack trace to string>";
+ }
}
return OS::SCreate(thread->zone(), "Unhandled exception:\n%s\n%s", exc_str,
stack_str);
diff --git a/runtime/vm/service_isolate.cc b/runtime/vm/service_isolate.cc
index f2a1286..b8b855d 100644
--- a/runtime/vm/service_isolate.cc
+++ b/runtime/vm/service_isolate.cc
@@ -49,19 +49,40 @@
#define VM_SERVICE_METHOD_CALL_FROM_NATIVE 5
-static ArrayPtr MakeServiceControlMessage(Dart_Port port_id,
- intptr_t code,
- const String& name) {
- const Array& list = Array::Handle(Array::New(4));
- ASSERT(!list.IsNull());
- const Integer& code_int = Integer::Handle(Integer::New(code));
- const Integer& port_int = Integer::Handle(Integer::New(port_id));
- const SendPort& send_port = SendPort::Handle(SendPort::New(port_id));
- list.SetAt(0, code_int);
- list.SetAt(1, port_int);
- list.SetAt(2, send_port);
- list.SetAt(3, name);
- return list.ptr();
+bool ServiceIsolate::SendServiceControlMessage(Thread* thread,
+ Dart_Port port_id,
+ intptr_t code,
+ const char* name) {
+ Dart_CObject ccode;
+ ccode.type = Dart_CObject_kInt32;
+ ccode.value.as_int32 = code;
+
+ Dart_CObject port_int;
+ port_int.type = Dart_CObject_kInt64;
+ port_int.value.as_int64 = port_id;
+
+ Dart_CObject send_port;
+ send_port.type = Dart_CObject_kSendPort;
+ send_port.value.as_send_port.id = port_id;
+ send_port.value.as_send_port.origin_id = port_id;
+
+ Dart_CObject cname;
+ cname.type = Dart_CObject_kString;
+ cname.value.as_string = const_cast<char*>(name);
+
+ Dart_CObject* values[4];
+ values[0] = &ccode;
+ values[1] = &port_int;
+ values[2] = &send_port;
+ values[3] = &cname;
+
+ Dart_CObject message;
+ message.type = Dart_CObject_kArray;
+ message.value.as_array.length = 4;
+ message.value.as_array.values = values;
+
+ return PortMap::PostMessage(WriteApiMessage(thread->zone(), &message, port_,
+ Message::kNormalPriority));
}
static ArrayPtr MakeServerControlMessage(const SendPort& sp,
@@ -217,21 +238,16 @@
if (Dart::VmIsolateNameEquals(isolate->name())) {
return false;
}
- ASSERT(isolate != NULL);
- HANDLESCOPE(thread);
- const String& name = String::Handle(String::New(isolate->name()));
- ASSERT(!name.IsNull());
- const Array& list = Array::Handle(MakeServiceControlMessage(
- Dart_GetMainPortId(), VM_SERVICE_ISOLATE_STARTUP_MESSAGE_ID, name));
- ASSERT(!list.IsNull());
+
+ Dart_Port main_port = Dart_GetMainPortId();
if (FLAG_trace_service) {
OS::PrintErr(DART_VM_SERVICE_ISOLATE_NAME ": Isolate %s %" Pd64
" registered.\n",
- name.ToCString(), Dart_GetMainPortId());
+ isolate->name(), main_port);
}
- bool result = PortMap::PostMessage(WriteMessage(
- /* can_send_any_object */ false, /* same_group */ false, list, port_,
- Message::kNormalPriority));
+ bool result = SendServiceControlMessage(thread, main_port,
+ VM_SERVICE_ISOLATE_STARTUP_MESSAGE_ID,
+ isolate->name());
isolate->set_is_service_registered(true);
return result;
}
@@ -245,21 +261,17 @@
if (Dart::VmIsolateNameEquals(isolate->name())) {
return false;
}
- ASSERT(isolate != NULL);
- HANDLESCOPE(thread);
- const String& name = String::Handle(String::New(isolate->name()));
- ASSERT(!name.IsNull());
- const Array& list = Array::Handle(MakeServiceControlMessage(
- Dart_GetMainPortId(), VM_SERVICE_ISOLATE_SHUTDOWN_MESSAGE_ID, name));
- ASSERT(!list.IsNull());
+
+ Dart_Port main_port = Dart_GetMainPortId();
if (FLAG_trace_service) {
OS::PrintErr(DART_VM_SERVICE_ISOLATE_NAME ": Isolate %s %" Pd64
" deregistered.\n",
- name.ToCString(), Dart_GetMainPortId());
+ isolate->name(), main_port);
}
- return PortMap::PostMessage(WriteMessage(
- /* can_send_any_object */ false, /* same_group */ false, list, port_,
- Message::kNormalPriority));
+
+ return SendServiceControlMessage(thread, main_port,
+ VM_SERVICE_ISOLATE_SHUTDOWN_MESSAGE_ID,
+ isolate->name());
}
void ServiceIsolate::SendServiceExitMessage() {
diff --git a/runtime/vm/service_isolate.h b/runtime/vm/service_isolate.h
index 0fc018a..4dff100 100644
--- a/runtime/vm/service_isolate.h
+++ b/runtime/vm/service_isolate.h
@@ -45,6 +45,10 @@
static void Run();
static bool SendIsolateStartupMessage();
static bool SendIsolateShutdownMessage();
+ static bool SendServiceControlMessage(Thread* thread,
+ Dart_Port port_id,
+ intptr_t code,
+ const char* name);
static void SendServiceExitMessage();
static void Shutdown();
diff --git a/sdk/lib/_internal/vm/bin/secure_socket_patch.dart b/sdk/lib/_internal/vm/bin/secure_socket_patch.dart
index a2ce0f3..680adcf 100644
--- a/sdk/lib/_internal/vm/bin/secure_socket_patch.dart
+++ b/sdk/lib/_internal/vm/bin/secure_socket_patch.dart
@@ -33,12 +33,7 @@
void renegotiate(
{bool useSessionCache: true,
bool requestClientCertificate: false,
- bool requireClientCertificate: false}) {
- _raw!.renegotiate(
- useSessionCache: useSessionCache,
- requestClientCertificate: requestClientCertificate,
- requireClientCertificate: requireClientCertificate);
- }
+ bool requireClientCertificate: false}) {}
X509Certificate? get peerCertificate {
if (_raw == null) {
@@ -165,10 +160,6 @@
@pragma("vm:external-name", "SecureSocket_GetSelectedProtocol")
external String? selectedProtocol();
- @pragma("vm:external-name", "SecureSocket_Renegotiate")
- external void renegotiate(bool useSessionCache, bool requestClientCertificate,
- bool requireClientCertificate);
-
@pragma("vm:external-name", "SecureSocket_Init")
external void init();
diff --git a/sdk/lib/io/secure_socket.dart b/sdk/lib/io/secure_socket.dart
index de267bb..7dd311c 100644
--- a/sdk/lib/io/secure_socket.dart
+++ b/sdk/lib/io/secure_socket.dart
@@ -208,12 +208,11 @@
/// protocol between client and server.
String? get selectedProtocol;
- /// Renegotiates an existing secure connection.
+ /// Does nothing.
///
- /// Renews the session keys and possibly changes the connection properties.
- ///
- /// This repeats the SSL or TLS handshake, with options that allow clearing
- /// the session cache and requesting a client certificate.
+ /// The original intent was to allow TLS renegotiation of existing secure
+ /// connections.
+ @Deprecated("Not implemented")
void renegotiate(
{bool useSessionCache = true,
bool requestClientCertificate = false,
@@ -421,11 +420,11 @@
supportedProtocols: supportedProtocols);
}
- /// Renegotiate an existing secure connection, renewing the session keys
- /// and possibly changing the connection properties.
+ /// Does nothing.
///
- /// This repeats the SSL or TLS handshake, with options that allow clearing
- /// the session cache and requesting a client certificate.
+ /// The original intent was to allow TLS renegotiation of existing secure
+ /// connections.
+ @Deprecated("Not implemented")
void renegotiate(
{bool useSessionCache = true,
bool requestClientCertificate = false,
@@ -924,6 +923,7 @@
}
}
+ @Deprecated("Not implemented")
void renegotiate(
{bool useSessionCache = true,
bool requestClientCertificate = false,
@@ -932,8 +932,6 @@
throw new HandshakeException(
"Called renegotiate on a non-connected socket");
}
- _secureFilter!.renegotiate(
- useSessionCache, requestClientCertificate, requireClientCertificate);
_status = handshakeStatus;
_filterStatus.writeEmpty = false;
_scheduleFilter();
@@ -1342,8 +1340,6 @@
Future<bool> handshake();
String? selectedProtocol();
void rehandshake();
- void renegotiate(bool useSessionCache, bool requestClientCertificate,
- bool requireClientCertificate);
void init();
X509Certificate? get peerCertificate;
int processBuffer(int bufferIndex);
diff --git a/tests/standalone/io/secure_socket_renegotiate_client.dart b/tests/standalone/io/secure_socket_renegotiate_client.dart
deleted file mode 100644
index 775891b..0000000
--- a/tests/standalone/io/secure_socket_renegotiate_client.dart
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright (c) 2013, 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.
-
-// Client for secure_socket_renegotiate_test, that runs in a subprocess.
-// The test verifies that client certificates work, if the client and server
-// are in separate processes, and that connection renegotiation can request
-// a client certificate to be sent.
-
-import "dart:async";
-import "dart:convert";
-import "dart:io";
-
-const HOST_NAME = "localhost";
-String localFile(path) => Platform.script.resolve(path).toFilePath();
-
-SecurityContext clientContext = new SecurityContext()
- ..setTrustedCertificates(localFile('certificates/trusted_certs.pem'));
-
-class ExpectException implements Exception {
- ExpectException(this.message);
- String toString() => message;
- String message;
-}
-
-void expectEquals(expected, actual) {
- if (actual != expected) {
- throw new ExpectException('Expected $expected, found $actual');
- }
-}
-
-void expect(condition) {
- if (!condition) {
- throw new ExpectException('');
- }
-}
-
-void runClient(int port) {
- SecureSocket.connect(HOST_NAME, port, context: clientContext)
- .then((SecureSocket socket) {
- X509Certificate? certificate = socket.peerCertificate;
- expect(certificate != null);
- expectEquals('CN=localhost', certificate!.subject);
- expectEquals('CN=myauthority', certificate.issuer);
- StreamIterator<String> input = new StreamIterator(
- socket.transform(utf8.decoder).transform(new LineSplitter()));
- socket.writeln('first');
- input.moveNext().then((success) {
- expect(success);
- expectEquals('first reply', input.current);
- socket.renegotiate();
- socket.writeln('renegotiated');
- return input.moveNext();
- }).then((success) {
- expect(success);
- expectEquals('server renegotiated', input.current);
- X509Certificate? certificate = socket.peerCertificate;
- expect(certificate != null);
- expectEquals("CN=localhost", certificate!.subject);
- expectEquals("CN=myauthority", certificate.issuer);
- socket.writeln('second');
- return input.moveNext();
- }).then((success) {
- expect(success != true);
- socket.close();
- });
- });
-}
-
-void main(List<String> args) {
- runClient(int.parse(args[0]));
-}
diff --git a/tests/standalone/io/secure_socket_renegotiate_test.dart b/tests/standalone/io/secure_socket_renegotiate_test.dart
deleted file mode 100644
index 05aa2f1..0000000
--- a/tests/standalone/io/secure_socket_renegotiate_test.dart
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) 2013, 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.
-//
-// OtherResources=certificates/server_chain.pem
-// OtherResources=certificates/server_key.pem
-// OtherResources=secure_socket_renegotiate_client.dart
-
-// This test verifies that client certificates work, if the client and server
-// are in separate processes, and that connection renegotiation works, and
-// can request a client certificate to be sent.
-
-import "dart:async";
-import "dart:convert";
-import "dart:io";
-
-import "package:expect/expect.dart";
-import "package:path/path.dart";
-
-const HOST_NAME = "localhost";
-String localFile(path) => Platform.script.resolve(path).toFilePath();
-
-SecurityContext serverContext = new SecurityContext()
- ..useCertificateChain(localFile('certificates/server_chain.pem'))
- ..usePrivateKey(localFile('certificates/server_key.pem'),
- password: 'dartdart');
-
-Future<SecureServerSocket> runServer() {
- return SecureServerSocket.bind(HOST_NAME, 0, serverContext)
- .then((SecureServerSocket server) {
- server.listen((SecureSocket socket) {
- Expect.isNull(socket.peerCertificate);
-
- StreamIterator<String> input = new StreamIterator(
- utf8.decoder.bind(socket).transform(new LineSplitter()));
- input.moveNext().then((success) {
- Expect.isTrue(success);
- Expect.equals('first', input.current);
- socket.writeln('first reply');
- return input.moveNext();
- }).then((success) {
- Expect.isTrue(success);
- Expect.equals('renegotiated', input.current);
- Expect.isNull(socket.peerCertificate);
- socket.renegotiate(
- requestClientCertificate: true,
- requireClientCertificate: true,
- useSessionCache: false);
- socket.writeln('server renegotiated');
- return input.moveNext();
- }).then((success) {
- Expect.isTrue(success);
- Expect.equals('second', input.current);
- X509Certificate certificate = socket.peerCertificate!;
- Expect.equals("CN=localhost", certificate.subject);
- Expect.equals("CN=myauthority", certificate.issuer);
- server.close();
- socket.close();
- });
- });
- return server;
- });
-}
-
-void main() {
- runServer().then((SecureServerSocket server) {
- var clientScript = Platform.script
- .resolve('secure_socket_renegotiate_client.dart')
- .toFilePath();
- Process.run(
- Platform.executable,
- []
- ..addAll(Platform.executableArguments)
- ..addAll([clientScript, server.port.toString()]))
- .then((ProcessResult result) {
- if (result.exitCode != 0) {
- print("Client failed, stdout:");
- print(result.stdout);
- print(" stderr:");
- print(result.stderr);
- Expect.fail('Client subprocess exit code: ${result.exitCode}');
- }
- });
- });
-}
diff --git a/tests/standalone/standalone_kernel.status b/tests/standalone/standalone_kernel.status
index 609c61b..41bcfb0 100644
--- a/tests/standalone/standalone_kernel.status
+++ b/tests/standalone/standalone_kernel.status
@@ -97,7 +97,6 @@
io/secure_multiple_client_server_test: Skip # Flaky.
io/secure_server_closing_test: Skip # Flaky.
io/secure_server_socket_test: Skip # Flaky.
-io/secure_socket_renegotiate_test: Crash
io/socket_many_connections_test: Skip # Flaky
io/web_socket_error_test: Skip # Flaky
io/web_socket_ping_test: Skip # Flaky.
diff --git a/tests/standalone_2/io/secure_socket_renegotiate_client.dart b/tests/standalone_2/io/secure_socket_renegotiate_client.dart
deleted file mode 100644
index c8ae0bb..0000000
--- a/tests/standalone_2/io/secure_socket_renegotiate_client.dart
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright (c) 2013, 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.9
-
-// Client for secure_socket_renegotiate_test, that runs in a subprocess.
-// The test verifies that client certificates work, if the client and server
-// are in separate processes, and that connection renegotiation can request
-// a client certificate to be sent.
-
-import "dart:async";
-import "dart:convert";
-import "dart:io";
-
-const HOST_NAME = "localhost";
-String localFile(path) => Platform.script.resolve(path).toFilePath();
-
-SecurityContext clientContext = new SecurityContext()
- ..setTrustedCertificates(localFile('certificates/trusted_certs.pem'));
-
-class ExpectException implements Exception {
- ExpectException(this.message);
- String toString() => message;
- String message;
-}
-
-void expectEquals(expected, actual) {
- if (actual != expected) {
- throw new ExpectException('Expected $expected, found $actual');
- }
-}
-
-void expect(condition) {
- if (!condition) {
- throw new ExpectException('');
- }
-}
-
-void runClient(int port) {
- SecureSocket
- .connect(HOST_NAME, port, context: clientContext)
- .then((SecureSocket socket) {
- X509Certificate certificate = socket.peerCertificate;
- expect(certificate != null);
- expectEquals('CN=localhost', certificate.subject);
- expectEquals('CN=myauthority', certificate.issuer);
- StreamIterator<String> input = new StreamIterator(
- socket.transform(utf8.decoder).transform(new LineSplitter()));
- socket.writeln('first');
- input.moveNext().then((success) {
- expect(success);
- expectEquals('first reply', input.current);
- socket.renegotiate();
- socket.writeln('renegotiated');
- return input.moveNext();
- }).then((success) {
- expect(success);
- expectEquals('server renegotiated', input.current);
- X509Certificate certificate = socket.peerCertificate;
- expect(certificate != null);
- expectEquals("CN=localhost", certificate.subject);
- expectEquals("CN=myauthority", certificate.issuer);
- socket.writeln('second');
- return input.moveNext();
- }).then((success) {
- expect(success != true);
- socket.close();
- });
- });
-}
-
-void main(List<String> args) {
- runClient(int.parse(args[0]));
-}
diff --git a/tests/standalone_2/io/secure_socket_renegotiate_test.dart b/tests/standalone_2/io/secure_socket_renegotiate_test.dart
deleted file mode 100644
index 36cb3a2..0000000
--- a/tests/standalone_2/io/secure_socket_renegotiate_test.dart
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright (c) 2013, 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.
-//
-// OtherResources=certificates/server_chain.pem
-// OtherResources=certificates/server_key.pem
-// OtherResources=secure_socket_renegotiate_client.dart
-
-// @dart = 2.9
-
-// This test verifies that client certificates work, if the client and server
-// are in separate processes, and that connection renegotiation works, and
-// can request a client certificate to be sent.
-
-import "dart:async";
-import "dart:convert";
-import "dart:io";
-
-import "package:expect/expect.dart";
-import "package:path/path.dart";
-
-const HOST_NAME = "localhost";
-String localFile(path) => Platform.script.resolve(path).toFilePath();
-
-SecurityContext serverContext = new SecurityContext()
- ..useCertificateChain(localFile('certificates/server_chain.pem'))
- ..usePrivateKey(localFile('certificates/server_key.pem'),
- password: 'dartdart');
-
-Future<SecureServerSocket> runServer() {
- return SecureServerSocket.bind(HOST_NAME, 0, serverContext)
- .then((SecureServerSocket server) {
- server.listen((SecureSocket socket) {
- Expect.isNull(socket.peerCertificate);
-
- StreamIterator<String> input = new StreamIterator(
- utf8.decoder.bind(socket).transform(new LineSplitter()));
- input.moveNext().then((success) {
- Expect.isTrue(success);
- Expect.equals('first', input.current);
- socket.writeln('first reply');
- return input.moveNext();
- }).then((success) {
- Expect.isTrue(success);
- Expect.equals('renegotiated', input.current);
- Expect.isNull(socket.peerCertificate);
- socket.renegotiate(
- requestClientCertificate: true,
- requireClientCertificate: true,
- useSessionCache: false);
- socket.writeln('server renegotiated');
- return input.moveNext();
- }).then((success) {
- Expect.isTrue(success);
- Expect.equals('second', input.current);
- X509Certificate certificate = socket.peerCertificate;
- Expect.isNotNull(certificate);
- Expect.equals("CN=localhost", certificate.subject);
- Expect.equals("CN=myauthority", certificate.issuer);
- server.close();
- socket.close();
- });
- });
- return server;
- });
-}
-
-void main() {
- runServer().then((SecureServerSocket server) {
- var clientScript = Platform.script
- .resolve('secure_socket_renegotiate_client.dart')
- .toFilePath();
- Process.run(
- Platform.executable,
- []
- ..addAll(Platform.executableArguments)
- ..addAll([clientScript, server.port.toString()]))
- .then((ProcessResult result) {
- if (result.exitCode != 0) {
- print("Client failed, stdout:");
- print(result.stdout);
- print(" stderr:");
- print(result.stderr);
- Expect.fail('Client subprocess exit code: ${result.exitCode}');
- }
- });
- });
-}
diff --git a/tests/standalone_2/standalone_2_kernel.status b/tests/standalone_2/standalone_2_kernel.status
index afb2751..90cc6f4 100644
--- a/tests/standalone_2/standalone_2_kernel.status
+++ b/tests/standalone_2/standalone_2_kernel.status
@@ -99,7 +99,6 @@
io/secure_multiple_client_server_test: Skip # Flaky.
io/secure_server_closing_test: Skip # Flaky.
io/secure_server_socket_test: Skip # Flaky.
-io/secure_socket_renegotiate_test: Crash
io/socket_many_connections_test: Skip # Flaky
io/web_socket_error_test: Skip # Flaky
io/web_socket_ping_test: Skip # Flaky.
diff --git a/tools/VERSION b/tools/VERSION
index 25a16b1..0a5488c 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 17
PATCH 0
-PRERELEASE 164
+PRERELEASE 165
PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json
index b35e47a..8280ab9 100644
--- a/tools/bots/test_matrix.json
+++ b/tools/bots/test_matrix.json
@@ -2948,7 +2948,7 @@
"language",
"corelib"
],
- "shards": 6,
+ "shards": 12,
"fileset": "dart2wasm_hostasserts"
}
]