Version 2.14.0-258.0.dev
Merge commit '87a4f54b9182a53834e1412eccec089fb11aad38' into 'dev'
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 011a5e1..07cfa16 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -201,6 +201,7 @@
_first(_implementationsOfGetter(getterName).where(
(PropertyAccessorElement getter) =>
!getter.isAbstract &&
+ !getter.isStatic &&
getter.isAccessibleIn(library) &&
getter.enclosingElement != this));
@@ -220,6 +221,7 @@
_first(_implementationsOfMethod(methodName).where(
(MethodElement method) =>
!method.isAbstract &&
+ !method.isStatic &&
method.isAccessibleIn(library) &&
method.enclosingElement != this));
@@ -229,6 +231,7 @@
_first(_implementationsOfSetter(setterName).where(
(PropertyAccessorElement setter) =>
!setter.isAbstract &&
+ !setter.isStatic &&
setter.isAccessibleIn(library) &&
setter.enclosingElement != this));
diff --git a/pkg/analyzer/test/src/dart/element/class_element_test.dart b/pkg/analyzer/test/src/dart/element/class_element_test.dart
index 0e14887..dbe96a2 100644
--- a/pkg/analyzer/test/src/dart/element/class_element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/class_element_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/src/error/codes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../resolution/context_collection_resolution.dart';
@@ -15,6 +16,918 @@
@reflectiveTest
class ClassElementTest extends PubPackageResolutionTest {
+ test_lookUpInheritedConcreteGetter_declared() async {
+ await assertNoErrorsInCode('''
+class A {
+ int get foo => 0;
+}
+''');
+ var A = findElement.class_('A');
+ assertElementNull(
+ A._lookUpInheritedConcreteGetter('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_declared_hasExtends() async {
+ await assertNoErrorsInCode('''
+class A {
+ int get foo => 0;
+}
+
+class B extends A {
+ int get foo => 0;
+}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteGetter('foo'),
+ declaration: findElement.getter('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_declared_hasExtends_private_otherLibrary() async {
+ newFile('$testPackageLibPath/a.dart', content: r'''
+class A {
+ int get _foo => 0;
+}
+''');
+ await assertNoErrorsInCode('''
+import 'a.dart';
+
+class B extends A {
+ // ignore:unused_element
+ int get _foo => 0;
+}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteGetter('_foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_declared_hasExtends_private_sameLibrary() async {
+ await assertNoErrorsInCode('''
+class A {
+ // ignore:unused_element
+ int get _foo => 0;
+}
+
+class B extends A {
+ // ignore:unused_element
+ int get _foo => 0;
+}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteGetter('_foo'),
+ declaration: findElement.getter('_foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_declared_hasExtends_static() async {
+ await assertNoErrorsInCode('''
+class A {
+ static int get foo => 0;
+}
+
+class B extends A {
+ int get foo => 0;
+}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteGetter('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_hasExtends() async {
+ await assertNoErrorsInCode('''
+class A {
+ int get foo => 0;
+}
+
+class B extends A {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteGetter('foo'),
+ declaration: findElement.getter('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_hasExtends_abstract() async {
+ await assertNoErrorsInCode('''
+abstract class A {
+ int get foo;
+}
+
+abstract class B extends A {}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteGetter('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_hasExtends_hasWith() async {
+ await assertNoErrorsInCode('''
+class A {
+ int get foo => 0;
+}
+
+mixin M {
+ int get foo => 0;
+}
+
+class B extends A with M {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteGetter('foo'),
+ declaration: findElement.getter('foo', of: 'M'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_hasExtends_hasWith2() async {
+ await assertNoErrorsInCode('''
+class A {
+ int get foo => 0;
+}
+
+mixin M1 {
+ int get foo => 0;
+}
+
+mixin M2 {
+ int get foo => 0;
+}
+
+class B extends A with M1, M2 {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteGetter('foo'),
+ declaration: findElement.getter('foo', of: 'M2'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_hasExtends_hasWith3() async {
+ await assertNoErrorsInCode('''
+class A {
+ int get foo => 0;
+}
+
+mixin M1 {
+ int get foo => 0;
+}
+
+mixin M2 {}
+
+class B extends A with M1, M2 {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteGetter('foo'),
+ declaration: findElement.getter('foo', of: 'M1'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_hasExtends_hasWith4() async {
+ await assertNoErrorsInCode('''
+class A {
+ int get foo => 0;
+}
+
+mixin M {}
+
+class B extends A with M {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteGetter('foo'),
+ declaration: findElement.getter('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_hasExtends_hasWith5() async {
+ await assertNoErrorsInCode('''
+class A {}
+
+mixin M1 {
+ int get foo => 0;
+}
+
+mixin M2 {
+ int get foo;
+}
+
+class B extends A with M1, M2 {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteGetter('foo'),
+ declaration: findElement.getter('foo', of: 'M1'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_hasExtends_hasWith_static() async {
+ await assertNoErrorsInCode('''
+class A {
+ int get foo => 0;
+}
+
+mixin M {
+ static int get foo => 0;
+}
+
+class B extends A with M {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteGetter('foo'),
+ declaration: findElement.getter('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_hasExtends_static() async {
+ await assertNoErrorsInCode('''
+class A {
+ static int get foo => 0;
+}
+
+class B extends A {}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteGetter('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_hasExtends_withImplements() async {
+ await assertNoErrorsInCode('''
+class A {
+ int get foo => 0;
+}
+
+class B {
+ int get foo => 0;
+}
+
+class C extends A implements B {}
+''');
+ var C = findElement.class_('C');
+ assertElement2(
+ C._lookUpInheritedConcreteGetter('foo'),
+ declaration: findElement.getter('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_hasImplements() async {
+ await assertNoErrorsInCode('''
+class A {
+ int get foo => 0;
+}
+
+abstract class B implements A {}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteGetter('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_recursive() async {
+ await assertErrorsInCode('''
+class A extends B {}
+class B extends A {}
+''', [
+ error(CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 6, 1),
+ error(CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 27, 1),
+ ]);
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteGetter('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteGetter_undeclared() async {
+ await assertNoErrorsInCode('''
+class A {}
+''');
+ var A = findElement.class_('A');
+ assertElementNull(
+ A._lookUpInheritedConcreteGetter('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_declared() async {
+ await assertNoErrorsInCode('''
+class A {
+ void foo() {}
+}
+''');
+ var A = findElement.class_('A');
+ assertElementNull(
+ A._lookUpInheritedConcreteMethod('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_declared_hasExtends() async {
+ await assertNoErrorsInCode('''
+class A {
+ void foo() {}
+}
+
+class B extends A {
+ void foo() {}
+}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteMethod('foo'),
+ declaration: findElement.method('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_declared_hasExtends_private_otherLibrary() async {
+ newFile('$testPackageLibPath/a.dart', content: r'''
+class A {
+ void _foo() {}
+}
+''');
+ await assertNoErrorsInCode('''
+import 'a.dart';
+
+class B extends A {
+ // ignore:unused_element
+ void _foo() {}
+}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteMethod('_foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_declared_hasExtends_private_sameLibrary() async {
+ await assertNoErrorsInCode('''
+class A {
+ // ignore:unused_element
+ void _foo() {}
+}
+
+class B extends A {
+ // ignore:unused_element
+ void _foo() {}
+}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteMethod('_foo'),
+ declaration: findElement.method('_foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_declared_hasExtends_static() async {
+ await assertNoErrorsInCode('''
+class A {
+ static void foo() {}
+}
+
+class B extends A {
+ void foo() {}
+}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteMethod('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_hasExtends() async {
+ await assertNoErrorsInCode('''
+class A {
+ void foo() {}
+}
+
+class B extends A {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteMethod('foo'),
+ declaration: findElement.method('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_hasExtends_abstract() async {
+ await assertNoErrorsInCode('''
+abstract class A {
+ void foo();
+}
+
+abstract class B extends A {}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteMethod('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_hasExtends_hasWith() async {
+ await assertNoErrorsInCode('''
+class A {
+ void foo() {}
+}
+
+mixin M {
+ void foo() {}
+}
+
+class B extends A with M {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteMethod('foo'),
+ declaration: findElement.method('foo', of: 'M'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_hasExtends_hasWith2() async {
+ await assertNoErrorsInCode('''
+class A {
+ void foo() {}
+}
+
+mixin M1 {
+ void foo() {}
+}
+
+mixin M2 {
+ void foo() {}
+}
+
+class B extends A with M1, M2 {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteMethod('foo'),
+ declaration: findElement.method('foo', of: 'M2'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_hasExtends_hasWith3() async {
+ await assertNoErrorsInCode('''
+class A {
+ void foo() {}
+}
+
+mixin M1 {
+ void foo() {}
+}
+
+mixin M2 {}
+
+class B extends A with M1, M2 {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteMethod('foo'),
+ declaration: findElement.method('foo', of: 'M1'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_hasExtends_hasWith4() async {
+ await assertNoErrorsInCode('''
+class A {
+ void foo() {}
+}
+
+mixin M {}
+
+class B extends A with M {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteMethod('foo'),
+ declaration: findElement.method('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_hasExtends_hasWith5() async {
+ await assertNoErrorsInCode('''
+class A {}
+
+mixin M1 {
+ void foo() {}
+}
+
+mixin M2 {
+ void foo();
+}
+
+class B extends A with M1, M2 {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteMethod('foo'),
+ declaration: findElement.method('foo', of: 'M1'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_hasExtends_hasWith_static() async {
+ await assertNoErrorsInCode('''
+class A {
+ void foo() {}
+}
+
+mixin M {
+ static void foo() {}
+}
+
+class B extends A with M {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteMethod('foo'),
+ declaration: findElement.method('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_hasExtends_static() async {
+ await assertNoErrorsInCode('''
+class A {
+ static void foo() {}
+}
+
+class B extends A {}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteMethod('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_hasExtends_withImplements() async {
+ await assertNoErrorsInCode('''
+class A {
+ void foo() {}
+}
+
+class B {
+ void foo() {}
+}
+
+class C extends A implements B {}
+''');
+ var C = findElement.class_('C');
+ assertElement2(
+ C._lookUpInheritedConcreteMethod('foo'),
+ declaration: findElement.method('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_hasImplements() async {
+ await assertNoErrorsInCode('''
+class A {
+ void foo() {}
+}
+
+abstract class B implements A {}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteMethod('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_recursive() async {
+ await assertErrorsInCode('''
+class A extends B {}
+class B extends A {}
+''', [
+ error(CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 6, 1),
+ error(CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 27, 1),
+ ]);
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteMethod('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteMethod_undeclared() async {
+ await assertNoErrorsInCode('''
+class A {}
+''');
+ var A = findElement.class_('A');
+ assertElementNull(
+ A._lookUpInheritedConcreteMethod('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_declared() async {
+ await assertNoErrorsInCode('''
+class A {
+ set foo(int _) {}
+}
+''');
+ var A = findElement.class_('A');
+ assertElementNull(
+ A._lookUpInheritedConcreteSetter('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_declared_hasExtends() async {
+ await assertNoErrorsInCode('''
+class A {
+ set foo(int _) {}
+}
+
+class B extends A {
+ set foo(int _) {}
+}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteSetter('foo'),
+ declaration: findElement.setter('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_declared_hasExtends_private_otherLibrary() async {
+ newFile('$testPackageLibPath/a.dart', content: r'''
+class A {
+ set _foo(int _) {}
+}
+''');
+ await assertNoErrorsInCode('''
+import 'a.dart';
+
+class B extends A {
+ // ignore:unused_element
+ set _foo(int _) {}
+}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteSetter('_foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_declared_hasExtends_private_sameLibrary() async {
+ await assertNoErrorsInCode('''
+class A {
+ // ignore:unused_element
+ set _foo(int _) {}
+}
+
+class B extends A {
+ // ignore:unused_element
+ set _foo(int _) {}
+}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteSetter('_foo'),
+ declaration: findElement.setter('_foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_declared_hasExtends_static() async {
+ await assertNoErrorsInCode('''
+class A {
+ static set foo(int _) {}
+}
+
+class B extends A {
+ set foo(int _) {}
+}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteSetter('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_hasExtends() async {
+ await assertNoErrorsInCode('''
+class A {
+ set foo(int _) {}
+}
+
+class B extends A {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteSetter('foo'),
+ declaration: findElement.setter('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_hasExtends_abstract() async {
+ await assertNoErrorsInCode('''
+abstract class A {
+ set foo(int _);
+}
+
+abstract class B extends A {}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteSetter('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_hasExtends_hasWith() async {
+ await assertNoErrorsInCode('''
+class A {
+ set foo(int _) {}
+}
+
+mixin M {
+ set foo(int _) {}
+}
+
+class B extends A with M {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteSetter('foo'),
+ declaration: findElement.setter('foo', of: 'M'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_hasExtends_hasWith2() async {
+ await assertNoErrorsInCode('''
+class A {
+ set foo(int _) {}
+}
+
+mixin M1 {
+ set foo(int _) {}
+}
+
+mixin M2 {
+ set foo(int _) {}
+}
+
+class B extends A with M1, M2 {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteSetter('foo'),
+ declaration: findElement.setter('foo', of: 'M2'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_hasExtends_hasWith3() async {
+ await assertNoErrorsInCode('''
+class A {
+ set foo(int _) {}
+}
+
+mixin M1 {
+ set foo(int _) {}
+}
+
+mixin M2 {}
+
+class B extends A with M1, M2 {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteSetter('foo'),
+ declaration: findElement.setter('foo', of: 'M1'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_hasExtends_hasWith4() async {
+ await assertNoErrorsInCode('''
+class A {
+ set foo(int _) {}
+}
+
+mixin M {}
+
+class B extends A with M {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteSetter('foo'),
+ declaration: findElement.setter('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_hasExtends_hasWith5() async {
+ await assertNoErrorsInCode('''
+class A {}
+
+mixin M1 {
+ set foo(int _) {}
+}
+
+mixin M2 {
+ set foo(int _);
+}
+
+class B extends A with M1, M2 {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteSetter('foo'),
+ declaration: findElement.setter('foo', of: 'M1'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_hasExtends_hasWith_static() async {
+ await assertNoErrorsInCode('''
+class A {
+ set foo(int _) {}
+}
+
+mixin M {
+ static set foo(int _) {}
+}
+
+class B extends A with M {}
+''');
+ var B = findElement.class_('B');
+ assertElement2(
+ B._lookUpInheritedConcreteSetter('foo'),
+ declaration: findElement.setter('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_hasExtends_static() async {
+ await assertNoErrorsInCode('''
+class A {
+ static set foo(int _) {}
+}
+
+class B extends A {}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteSetter('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_hasExtends_withImplements() async {
+ await assertNoErrorsInCode('''
+class A {
+ set foo(int _) {}
+}
+
+class B {
+ set foo(int _) {}
+}
+
+class C extends A implements B {}
+''');
+ var C = findElement.class_('C');
+ assertElement2(
+ C._lookUpInheritedConcreteSetter('foo'),
+ declaration: findElement.setter('foo', of: 'A'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_hasImplements() async {
+ await assertNoErrorsInCode('''
+class A {
+ set foo(int _) {}
+}
+
+abstract class B implements A {}
+''');
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteSetter('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_recursive() async {
+ await assertErrorsInCode('''
+class A extends B {}
+class B extends A {}
+''', [
+ error(CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 6, 1),
+ error(CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 27, 1),
+ ]);
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedConcreteSetter('foo'),
+ );
+ }
+
+ test_lookUpInheritedConcreteSetter_undeclared() async {
+ await assertNoErrorsInCode('''
+class A {}
+''');
+ var A = findElement.class_('A');
+ assertElementNull(
+ A._lookUpInheritedConcreteSetter('foo'),
+ );
+ }
+
test_lookUpInheritedMethod_declared() async {
await assertNoErrorsInCode('''
class A {
@@ -260,6 +1173,20 @@
);
}
+ test_lookUpInheritedMethod_recursive() async {
+ await assertErrorsInCode('''
+class A extends B {}
+class B extends A {}
+''', [
+ error(CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 6, 1),
+ error(CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, 27, 1),
+ ]);
+ var B = findElement.class_('B');
+ assertElementNull(
+ B._lookUpInheritedMethod('foo'),
+ );
+ }
+
test_lookUpInheritedMethod_undeclared() async {
await assertNoErrorsInCode('''
class A {}
@@ -275,4 +1202,16 @@
MethodElement? _lookUpInheritedMethod(String name) {
return lookUpInheritedMethod(name, library);
}
+
+ PropertyAccessorElement? _lookUpInheritedConcreteGetter(String name) {
+ return lookUpInheritedConcreteGetter(name, library);
+ }
+
+ MethodElement? _lookUpInheritedConcreteMethod(String name) {
+ return lookUpInheritedConcreteMethod(name, library);
+ }
+
+ PropertyAccessorElement? _lookUpInheritedConcreteSetter(String name) {
+ return lookUpInheritedConcreteSetter(name, library);
+ }
}
diff --git a/pkg/analyzer/test/src/dart/element/element_test.dart b/pkg/analyzer/test/src/dart/element/element_test.dart
index 43c2249..ad6cf9b 100644
--- a/pkg/analyzer/test/src/dart/element/element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/element_test.dart
@@ -385,276 +385,6 @@
expect(classA.lookUpGetter("g", library), isNull);
}
- void test_lookUpInheritedConcreteGetter_declared() {
- // class A {
- // get g {}
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- String getterName = "g";
- PropertyAccessorElement getter =
- ElementFactory.getterElement(getterName, false, intNone);
- classA.accessors = <PropertyAccessorElement>[getter];
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA];
- expect(classA.lookUpInheritedConcreteGetter(getterName, library), isNull);
- }
-
- void test_lookUpInheritedConcreteGetter_inherited() {
- // class A {
- // get g {}
- // }
- // class B extends A {
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- String getterName = "g";
- PropertyAccessorElement inheritedGetter =
- ElementFactory.getterElement(getterName, false, intNone);
- classA.accessors = <PropertyAccessorElement>[inheritedGetter];
- ClassElementImpl classB =
- ElementFactory.classElement("B", interfaceTypeStar(classA));
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA, classB];
- expect(classB.lookUpInheritedConcreteGetter(getterName, library),
- same(inheritedGetter));
- }
-
- void test_lookUpInheritedConcreteGetter_undeclared() {
- // class A {
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA];
- expect(classA.lookUpInheritedConcreteGetter("g", library), isNull);
- }
-
- void test_lookUpInheritedConcreteGetter_undeclared_recursive() {
- // class A extends B {
- // }
- // class B extends A {
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- ClassElementImpl classB =
- ElementFactory.classElement("B", interfaceTypeStar(classA));
- classA.supertype = interfaceTypeStar(classB);
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA, classB];
- expect(classA.lookUpInheritedConcreteGetter("g", library), isNull);
- }
-
- void test_lookUpInheritedConcreteMethod_declared() {
- // class A {
- // m() {}
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- String methodName = "m";
- MethodElement method = ElementFactory.methodElement(methodName, intNone);
- classA.methods = <MethodElement>[method];
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA];
- expect(classA.lookUpInheritedConcreteMethod(methodName, library), isNull);
- }
-
- void test_lookUpInheritedConcreteMethod_declaredAbstractAndInherited() {
- // class A {
- // m() {}
- // }
- // class B extends A {
- // m();
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- String methodName = "m";
- MethodElement inheritedMethod =
- ElementFactory.methodElement(methodName, intNone);
- classA.methods = <MethodElement>[inheritedMethod];
- ClassElementImpl classB =
- ElementFactory.classElement("B", interfaceTypeStar(classA));
- MethodElementImpl method =
- ElementFactory.methodElement(methodName, intNone);
- method.isAbstract = true;
- classB.methods = <MethodElement>[method];
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA, classB];
- expect(classB.lookUpInheritedConcreteMethod(methodName, library),
- same(inheritedMethod));
- }
-
- void test_lookUpInheritedConcreteMethod_declaredAndInherited() {
- // class A {
- // m() {}
- // }
- // class B extends A {
- // m() {}
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- String methodName = "m";
- MethodElement inheritedMethod =
- ElementFactory.methodElement(methodName, intNone);
- classA.methods = <MethodElement>[inheritedMethod];
- ClassElementImpl classB =
- ElementFactory.classElement("B", interfaceTypeStar(classA));
- MethodElement method = ElementFactory.methodElement(methodName, intNone);
- classB.methods = <MethodElement>[method];
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA, classB];
- expect(classB.lookUpInheritedConcreteMethod(methodName, library),
- same(inheritedMethod));
- }
-
- void test_lookUpInheritedConcreteMethod_declaredAndInheritedAbstract() {
- // abstract class A {
- // m();
- // }
- // class B extends A {
- // m() {}
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- classA.isAbstract = true;
- String methodName = "m";
- MethodElementImpl inheritedMethod =
- ElementFactory.methodElement(methodName, intNone);
- inheritedMethod.isAbstract = true;
- classA.methods = <MethodElement>[inheritedMethod];
- ClassElementImpl classB =
- ElementFactory.classElement("B", interfaceTypeStar(classA));
- MethodElement method = ElementFactory.methodElement(methodName, intNone);
- classB.methods = <MethodElement>[method];
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA, classB];
- expect(classB.lookUpInheritedConcreteMethod(methodName, library), isNull);
- }
-
- void
- test_lookUpInheritedConcreteMethod_declaredAndInheritedWithAbstractBetween() {
- // class A {
- // m() {}
- // }
- // class B extends A {
- // m();
- // }
- // class C extends B {
- // m() {}
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- String methodName = "m";
- MethodElement inheritedMethod =
- ElementFactory.methodElement(methodName, intNone);
- classA.methods = <MethodElement>[inheritedMethod];
- ClassElementImpl classB =
- ElementFactory.classElement("B", interfaceTypeStar(classA));
- MethodElementImpl abstractMethod =
- ElementFactory.methodElement(methodName, intNone);
- abstractMethod.isAbstract = true;
- classB.methods = <MethodElement>[abstractMethod];
- ClassElementImpl classC =
- ElementFactory.classElement("C", interfaceTypeStar(classB));
- MethodElementImpl method =
- ElementFactory.methodElement(methodName, intNone);
- classC.methods = <MethodElement>[method];
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA, classB, classC];
- expect(classC.lookUpInheritedConcreteMethod(methodName, library),
- same(inheritedMethod));
- }
-
- void test_lookUpInheritedConcreteMethod_inherited() {
- // class A {
- // m() {}
- // }
- // class B extends A {
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- String methodName = "m";
- MethodElement inheritedMethod =
- ElementFactory.methodElement(methodName, intNone);
- classA.methods = <MethodElement>[inheritedMethod];
- ClassElementImpl classB =
- ElementFactory.classElement("B", interfaceTypeStar(classA));
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA, classB];
- expect(classB.lookUpInheritedConcreteMethod(methodName, library),
- same(inheritedMethod));
- }
-
- void test_lookUpInheritedConcreteMethod_undeclared() {
- // class A {
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA];
- expect(classA.lookUpInheritedConcreteMethod("m", library), isNull);
- }
-
- void test_lookUpInheritedConcreteSetter_declared() {
- // class A {
- // set g(x) {}
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- String setterName = "s";
- PropertyAccessorElement setter =
- ElementFactory.setterElement(setterName, false, intNone);
- classA.accessors = <PropertyAccessorElement>[setter];
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA];
- expect(classA.lookUpInheritedConcreteSetter(setterName, library), isNull);
- }
-
- void test_lookUpInheritedConcreteSetter_inherited() {
- // class A {
- // set g(x) {}
- // }
- // class B extends A {
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- String setterName = "s";
- PropertyAccessorElement setter =
- ElementFactory.setterElement(setterName, false, intNone);
- classA.accessors = <PropertyAccessorElement>[setter];
- ClassElementImpl classB =
- ElementFactory.classElement("B", interfaceTypeStar(classA));
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA, classB];
- expect(classB.lookUpInheritedConcreteSetter(setterName, library),
- same(setter));
- }
-
- void test_lookUpInheritedConcreteSetter_undeclared() {
- // class A {
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA];
- expect(classA.lookUpInheritedConcreteSetter("s", library), isNull);
- }
-
- void test_lookUpInheritedConcreteSetter_undeclared_recursive() {
- // class A extends B {
- // }
- // class B extends A {
- // }
- LibraryElementImpl library = _newLibrary();
- var classA = class_(name: 'A');
- ClassElementImpl classB =
- ElementFactory.classElement("B", interfaceTypeStar(classA));
- classA.supertype = interfaceTypeStar(classB);
- (library.definingCompilationUnit as CompilationUnitElementImpl).classes =
- <ClassElement>[classA, classB];
- expect(classA.lookUpInheritedConcreteSetter("s", library), isNull);
- }
-
void test_lookUpMethod_declared() {
LibraryElementImpl library = _newLibrary();
var classA = class_(name: 'A');
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
index 52f5eea..c4fcf53 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
@@ -1079,7 +1079,14 @@
allMethods.forEach((Method method) {
emitInstanceMethod(method)
.forEach((js.Expression name, js.Expression code) {
- final property = js.Property(name, code);
+ js.Property property;
+ if (_options.features.legacyJavaScript.isEnabled) {
+ property = js.Property(name, code);
+ } else {
+ property = code is js.Fun
+ ? js.MethodDefinition(name, code)
+ : js.Property(name, code);
+ }
registerEntityAst(method.element, property);
properties.add(property);
});
diff --git a/pkg/vm_service/test/user_tag_changed_test.dart b/pkg/vm_service/test/user_tag_changed_test.dart
index e2b63fa..7e5fab9 100644
--- a/pkg/vm_service/test/user_tag_changed_test.dart
+++ b/pkg/vm_service/test/user_tag_changed_test.dart
@@ -37,12 +37,14 @@
var event = await stream.next;
expect(event.kind, EventKind.kUserTagChanged);
+ expect(event.isolate, isNotNull);
expect(event.updatedTag, 'Foo');
expect(event.previousTag, 'Default');
expect(await stream.hasNext, true);
event = await stream.next;
expect(event.kind, EventKind.kUserTagChanged);
+ expect(event.isolate, isNotNull);
expect(event.updatedTag, 'Default');
expect(event.previousTag, 'Foo');
},
diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc
index 5e8c466..42df295 100644
--- a/runtime/vm/clustered_snapshot.cc
+++ b/runtime/vm/clustered_snapshot.cc
@@ -1437,7 +1437,7 @@
field.set_guarded_list_length_unsafe(Field::kNoFixedLength);
field.set_guarded_list_length_in_object_offset_unsafe(
Field::kUnknownLengthOffset);
- field.set_static_type_exactness_state(
+ field.set_static_type_exactness_state_unsafe(
StaticTypeExactnessState::NotTracking());
}
} else {
@@ -5565,6 +5565,7 @@
*code ^= d->ReadRef();
StubCode::EntryAtPut(i, code);
}
+ StubCode::InitializationDone();
}
}
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index ef519e7..99c2957 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -10635,7 +10635,7 @@
result.set_initializer_changed_after_initialization(false);
NOT_IN_PRECOMPILED(result.set_kernel_offset(0));
result.set_has_pragma(false);
- result.set_static_type_exactness_state(
+ result.set_static_type_exactness_state_unsafe(
StaticTypeExactnessState::NotTracking());
auto isolate_group = IsolateGroup::Current();
@@ -25729,7 +25729,7 @@
#if !defined(PRODUCT)
// Notify VM service clients that the current UserTag has changed.
if (Service::profiler_stream.enabled()) {
- ServiceEvent event(ServiceEvent::kUserTagChanged);
+ ServiceEvent event(isolate, ServiceEvent::kUserTagChanged);
String& name = String::Handle(old.label());
event.set_previous_tag(name.ToCString());
name ^= label();
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 786fcb6..f2e14f4 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -4145,11 +4145,20 @@
StaticTypeExactnessState static_type_exactness_state() const {
return StaticTypeExactnessState::Decode(
- untag()->static_type_exactness_state_);
+ LoadNonPointer<int8_t, std::memory_order_relaxed>(
+ &untag()->static_type_exactness_state_));
}
void set_static_type_exactness_state(StaticTypeExactnessState state) const {
- StoreNonPointer(&untag()->static_type_exactness_state_, state.Encode());
+ DEBUG_ASSERT(
+ IsolateGroup::Current()->program_lock()->IsCurrentThreadWriter());
+ set_static_type_exactness_state_unsafe(state);
+ }
+
+ void set_static_type_exactness_state_unsafe(
+ StaticTypeExactnessState state) const {
+ StoreNonPointer<int8_t, int8_t, std::memory_order_relaxed>(
+ &untag()->static_type_exactness_state_, state.Encode());
}
static intptr_t static_type_exactness_state_offset() {
diff --git a/runtime/vm/stub_code.cc b/runtime/vm/stub_code.cc
index 78a3355..91474a0 100644
--- a/runtime/vm/stub_code.cc
+++ b/runtime/vm/stub_code.cc
@@ -35,6 +35,7 @@
VM_STUB_CODE_LIST(STUB_CODE_DECLARE)
#undef STUB_CODE_DECLARE
};
+AcqRelAtomic<bool> StubCode::initialized_ = {false};
#if defined(DART_PRECOMPILED_RUNTIME)
void StubCode::Init() {
@@ -61,6 +62,8 @@
entries_[i].code->set_object_pool(object_pool.ptr());
}
+ InitializationDone();
+
#if defined(DART_PRECOMPILER)
{
// Set Function owner for UnknownDartCode stub so it pretends to
@@ -111,16 +114,13 @@
#endif // defined(DART_PRECOMPILED_RUNTIME)
void StubCode::Cleanup() {
+ initialized_.store(false, std::memory_order_release);
+
for (size_t i = 0; i < ARRAY_SIZE(entries_); i++) {
entries_[i].code = nullptr;
}
}
-bool StubCode::HasBeenInitialized() {
- // Use AsynchronousGapMarker as canary.
- return entries_[kAsynchronousGapMarkerIndex].code != nullptr;
-}
-
bool StubCode::InInvocationStub(uword pc) {
ASSERT(HasBeenInitialized());
uword entry = StubCode::InvokeDartCode().EntryPoint();
diff --git a/runtime/vm/stub_code.h b/runtime/vm/stub_code.h
index 6dcedc5..ae39cae 100644
--- a/runtime/vm/stub_code.h
+++ b/runtime/vm/stub_code.h
@@ -42,7 +42,12 @@
static void Cleanup();
// Returns true if stub code has been initialized.
- static bool HasBeenInitialized();
+ static bool HasBeenInitialized() {
+ return initialized_.load(std::memory_order_acquire);
+ }
+ static void InitializationDone() {
+ initialized_.store(true, std::memory_order_release);
+ }
// Check if specified pc is in the dart invocation stub used for
// transitioning into dart code.
@@ -120,6 +125,7 @@
#endif
};
static StubCodeEntry entries_[kNumStubEntries];
+ static AcqRelAtomic<bool> initialized_;
};
} // namespace dart
diff --git a/sdk/lib/developer/profiler.dart b/sdk/lib/developer/profiler.dart
index dea6b45..f238ae8 100644
--- a/sdk/lib/developer/profiler.dart
+++ b/sdk/lib/developer/profiler.dart
@@ -129,7 +129,6 @@
}
@pragma("vm:entry-point", !const bool.fromEnvironment("dart.vm.product"))
- // ignore: unused_element, called from native code
static String? _printMetric(String id) {
var metric = _metrics[id];
if (metric == null) {
@@ -139,7 +138,6 @@
}
@pragma("vm:entry-point", !const bool.fromEnvironment("dart.vm.product"))
- // ignore: unused_element, called from native code
static String _printMetrics() {
var metrics = [];
for (var metric in _metrics.values) {
diff --git a/tools/VERSION b/tools/VERSION
index a155f73..12c0b50 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 14
PATCH 0
-PRERELEASE 257
+PRERELEASE 258
PRERELEASE_PATCH 0
\ No newline at end of file