Enable 'getter-setter-error' flag in 3.9

TEST=existing

Change-Id: Ic4a5735adda7cf8ef1565b9356ca277d9b62b064
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430720
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
This commit is contained in:
Chloe Stefantsova
2025-05-26 08:08:31 -07:00
committed by Commit Queue
parent 4ff0b6426e
commit 6fa858cfe8
22 changed files with 164 additions and 335 deletions
@@ -96,10 +96,10 @@ enum ExperimentalFlag {
getterSetterError(
name: 'getter-setter-error',
isEnabledByDefault: false,
isEnabledByDefault: true,
isExpired: false,
experimentEnabledVersion: defaultLanguageVersion,
experimentReleasedVersion: defaultLanguageVersion),
experimentEnabledVersion: const Version(3, 9),
experimentReleasedVersion: const Version(3, 9)),
inferenceUpdate1(
name: 'inference-update-1',
@@ -326,7 +326,7 @@ class ExperimentalFeatures {
documentation:
'Stop reporting errors about mismatching types in a getter/setter pair.',
experimentalReleaseVersion: null,
releaseVersion: null,
releaseVersion: Version.parse('3.9.0'),
channels: ["stable", "beta", "dev", "main"],
);
@@ -663,7 +663,7 @@ class IsEnabledByDefault {
static const bool generic_metadata = true;
/// Default state of the experiment "getter-setter-error"
static const bool getter_setter_error = false;
static const bool getter_setter_error = true;
/// Default state of the experiment "inference-update-1"
static const bool inference_update_1 = true;
@@ -406,6 +406,7 @@ analysisOptions
enhanced-enums
extension-methods
generic-metadata
getter-setter-error
inference-update-1
inference-update-2
inference-update-3
@@ -486,6 +487,7 @@ analysisOptions
enhanced-enums
extension-methods
generic-metadata
getter-setter-error
inference-update-1
inference-update-2
inference-update-3
@@ -4,6 +4,7 @@
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer_testing/experiments/experiments.dart';
import 'package:collection/collection.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -29,36 +30,26 @@ class GetterNotSubtypeSetterTypesTest_withGetterSetterErrorFeature
class GetterNotSubtypeSetterTypesTest_withoutGetterSetterErrorFeature
extends _GetterNotSubtypeSetterTypesTest {
@override
List<String> get experiments => [];
List<String> get experiments => [...experimentsForTests];
}
class _GetterNotSubtypeSetterTypesTest extends PubPackageResolutionTest {
test_class_instance() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
class C {
num get foo => 0;
set foo(int v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 20, 3),
]),
);
''');
}
test_class_instance_dynamicGetter() async {
await assertErrorsInCode(
r'''
await assertNoErrorsInCode(r'''
class C {
get foo => 0;
set foo(String v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 16, 3),
]),
);
''');
}
test_class_instance_dynamicSetter() async {
@@ -71,22 +62,16 @@ class C {
}
test_class_instance_field() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
class C {
final num foo = 0;
set foo(int v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 22, 3),
]),
);
''');
}
test_class_instance_interfaces() async {
await assertErrorsInCode(
r'''
await assertNoErrorsInCode(r'''
class A {
int get foo => 0;
}
@@ -96,11 +81,7 @@ class B {
}
abstract class X implements A, B {}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 84, 1),
]),
);
''');
}
test_class_instance_private_getter() async {
@@ -170,17 +151,12 @@ class B extends A {
}
test_class_instance_sameClass() async {
await assertErrorsInCode(
r'''
await assertNoErrorsInCode(r'''
class C {
int get foo => 0;
set foo(String _) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 20, 3),
]),
);
''');
}
test_class_instance_sameTypes() async {
@@ -229,8 +205,7 @@ class C {
}
test_class_instance_superGetter() async {
await assertErrorsInCode(
r'''
await assertNoErrorsInCode(r'''
class A {
int get foo => 0;
}
@@ -238,16 +213,11 @@ class A {
class B extends A {
set foo(String _) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 59, 3),
]),
);
''');
}
test_class_instance_superSetter() async {
await assertErrorsInCode(
r'''
await assertNoErrorsInCode(r'''
class A {
set foo(String _) {}
}
@@ -255,39 +225,25 @@ class A {
class B extends A {
int get foo => 0;
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 66, 3),
]),
);
''');
}
test_class_static() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
class C {
static num get foo => 0;
static set foo(int v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 27, 3),
]),
);
''');
}
test_class_static_field() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
class C {
static final num foo = 0;
static set foo(int v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 29, 3),
]),
);
''');
}
test_class_static_sameTypes() async {
@@ -300,8 +256,7 @@ class C {
}
test_enum_instance_mixinGetter_mixinSetter() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
mixin M1 {
num get foo => 0;
}
@@ -313,16 +268,11 @@ mixin M2 {
enum E with M1, M2 {
v
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 73, 1),
]),
);
''');
}
test_enum_instance_mixinGetter_thisSetter() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
mixin M {
num get foo => 0;
}
@@ -331,159 +281,104 @@ enum E with M {
v;
set foo(int v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 60, 3),
]),
);
''');
}
test_enum_instance_superGetter_thisSetter_index() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
enum E {
v;
set index(String _) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 20, 5),
]),
);
''');
}
test_enum_instance_thisField_thisSetter() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
enum E {
v;
final num foo = 0;
set foo(int v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 26, 3),
]),
);
''');
}
test_enum_instance_thisGetter_thisSetter() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
enum E {
v;
num get foo => 0;
set foo(int v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 24, 3),
]),
);
''');
}
test_enum_static() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
enum E {
v;
static num get foo => 0;
static set foo(int v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 31, 3),
]),
);
''');
}
test_enum_static_field() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
enum E {
foo;
static set foo(int v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 11, 3),
]),
);
''');
}
test_enum_static_generatedGetter_thisSetter_index() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
enum E {
v;
static set values(int _) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 5, 1),
]),
);
''');
}
test_extension_instance() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
extension E on Object {
int get foo => 0;
set foo(String v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 34, 3),
]),
);
''');
}
test_extension_static() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
extension E on Object {
static int get foo => 0;
static set foo(String v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 41, 3),
]),
);
''');
}
test_extension_static_field() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
extension E on Object {
static final int foo = 0;
static set foo(String v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 43, 3),
]),
);
''');
}
test_extensionType_instance() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
extension type A(int it) {
int get foo => 0;
void set foo(String _) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 37, 3),
]),
);
''');
}
test_extensionType_instance_fromImplements() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
extension type A(int it) {
void set foo(String _) {}
}
@@ -491,76 +386,47 @@ extension type A(int it) {
extension type B(int it) implements A {
int get foo => 0;
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 108, 3),
]),
);
''');
}
test_extensionType_instance_representationField() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
extension type A(int it) {
void set it(String _) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 38, 2),
]),
);
''');
}
test_extensionType_static() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
extension type A(int it) {
static int get foo => 0;
static set foo(String v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 44, 3),
]),
);
''');
}
test_extensionType_static_field() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
extension type A(int it) {
static final int foo = 0;
static set foo(String v) {}
}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 46, 3),
]),
);
''');
}
test_topLevel() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
int get foo => 0;
set foo(String v) {}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 8, 3),
]),
);
''');
}
test_topLevel_dynamicGetter() async {
await assertErrorsInCode(
r'''
await assertNoErrorsInCode(r'''
get foo => 0;
set foo(int v) {}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 4, 3),
]),
);
''');
}
test_topLevel_dynamicSetter() async {
@@ -578,15 +444,10 @@ set foo(int v) {}
}
test_topLevel_variable() async {
await assertErrorsInCode(
'''
await assertNoErrorsInCode('''
final int foo = 0;
set foo(String v) {}
''',
_filterGetterSetterTypeErrors([
error(CompileTimeErrorCode.GETTER_NOT_SUBTYPE_SETTER_TYPES, 10, 3),
]),
);
''');
}
List<ExpectedError> _filterGetterSetterTypeErrors(
@@ -18,6 +18,5 @@ List<String> experimentsForTests = [
Feature.augmentations.enableString,
Feature.dot_shorthands.enableString,
Feature.enhanced_parts.enableString,
Feature.getter_setter_error.enableString,
Feature.macros.enableString,
];
@@ -157,11 +157,11 @@ class ExperimentalFlag {
static const ExperimentalFlag getterSetterError = const ExperimentalFlag(
name: 'getter-setter-error',
isEnabledByDefault: false,
isEnabledByDefault: true,
isExpired: false,
enabledVersion: defaultLanguageVersion,
experimentEnabledVersion: defaultLanguageVersion,
experimentReleasedVersion: defaultLanguageVersion);
enabledVersion: const Version(3, 9),
experimentEnabledVersion: const Version(3, 9),
experimentReleasedVersion: const Version(3, 9));
static const ExperimentalFlag inferenceUpdate1 = const ExperimentalFlag(
name: 'inference-update-1',
+14
View File
@@ -569,12 +569,26 @@ InvalidContinueTarget/example: Fail
InvalidExtensionTypeSuperExtensionType/analyzerCode: Fail
InvalidExtensionTypeSuperInterface/analyzerCode: Fail
InvalidGetterSetterType/analyzerCode: Fail
InvalidGetterSetterType/part_wrapped_script: Fail
InvalidGetterSetterType/script: Fail
InvalidGetterSetterTypeBothInheritedField/analyzerCode: Fail
InvalidGetterSetterTypeBothInheritedField/part_wrapped_script: Fail
InvalidGetterSetterTypeBothInheritedField/script: Fail
InvalidGetterSetterTypeBothInheritedGetter/analyzerCode: Fail
InvalidGetterSetterTypeBothInheritedGetter/part_wrapped_script: Fail
InvalidGetterSetterTypeBothInheritedGetter/script: Fail
InvalidGetterSetterTypeFieldInherited/analyzerCode: Fail
InvalidGetterSetterTypeFieldInherited/part_wrapped_script: Fail
InvalidGetterSetterTypeFieldInherited/script: Fail
InvalidGetterSetterTypeGetterInherited/analyzerCode: Fail
InvalidGetterSetterTypeGetterInherited/part_wrapped_script: Fail
InvalidGetterSetterTypeGetterInherited/script: Fail
InvalidGetterSetterTypeSetterInheritedField/analyzerCode: Fail
InvalidGetterSetterTypeSetterInheritedField/part_wrapped_script: Fail
InvalidGetterSetterTypeSetterInheritedField/script: Fail
InvalidGetterSetterTypeSetterInheritedGetter/analyzerCode: Fail
InvalidGetterSetterTypeSetterInheritedGetter/part_wrapped_script: Fail
InvalidGetterSetterTypeSetterInheritedGetter/script: Fail
InvalidInitializer/example: Fail
InvalidMacroApplicationTarget/analyzerCode: Fail
InvalidMacroApplicationTarget/example: Fail
@@ -36,14 +36,14 @@ library from "org-dartlang-test:///main.dart" as main {
method noSuchMethod(dart.core::Invocation msg) → dynamic {
dart.core::print("noSouchMethod!");
}
synthetic no-such-method-forwarder get field() → dart.core::bool
return this.{main::Foo2::noSuchMethod}(new dart.core::_InvocationMirror::_withType(#C7, 1, #C2, #C3, dart.core::Map::unmodifiable<dart.core::Symbol, dynamic>(#C4))){(dart.core::Invocation) → dynamic} as{TypeError,ForDynamic} dart.core::bool;
synthetic no-such-method-forwarder set field(dart.core::bool value) → void
return this.{main::Foo2::noSuchMethod}(new dart.core::_InvocationMirror::_withType(#C8, 2, #C2, dart.core::List::unmodifiable<dynamic>(dart.core::_GrowableList::_literal1<dynamic>(value)), dart.core::Map::unmodifiable<dart.core::Symbol, dynamic>(#C4))){(dart.core::Invocation) → dynamic};
synthetic no-such-method-forwarder method method() → void
return this.{main::Foo2::noSuchMethod}(new dart.core::_InvocationMirror::_withType(#C1, 0, #C2, #C3, dart.core::Map::unmodifiable<dart.core::Symbol, dynamic>(#C4))){(dart.core::Invocation) → dynamic};
synthetic no-such-method-forwarder get getter() → dart.core::bool
return this.{main::Foo2::noSuchMethod}(new dart.core::_InvocationMirror::_withType(#C5, 1, #C2, #C3, dart.core::Map::unmodifiable<dart.core::Symbol, dynamic>(#C4))){(dart.core::Invocation) → dynamic} as{TypeError,ForDynamic} dart.core::bool;
synthetic no-such-method-forwarder get field() → dart.core::bool
return this.{main::Foo2::noSuchMethod}(new dart.core::_InvocationMirror::_withType(#C7, 1, #C2, #C3, dart.core::Map::unmodifiable<dart.core::Symbol, dynamic>(#C4))){(dart.core::Invocation) → dynamic} as{TypeError,ForDynamic} dart.core::bool;
synthetic no-such-method-forwarder set field(dart.core::bool value) → void
return this.{main::Foo2::noSuchMethod}(new dart.core::_InvocationMirror::_withType(#C8, 2, #C2, dart.core::List::unmodifiable<dynamic>(dart.core::_GrowableList::_literal1<dynamic>(value)), dart.core::Map::unmodifiable<dart.core::Symbol, dynamic>(#C4))){(dart.core::Invocation) → dynamic};
synthetic no-such-method-forwarder set setter(dart.core::bool b) → void
return this.{main::Foo2::noSuchMethod}(new dart.core::_InvocationMirror::_withType(#C6, 2, #C2, dart.core::List::unmodifiable<dynamic>(dart.core::_GrowableList::_literal1<dynamic>(b)), dart.core::Map::unmodifiable<dart.core::Symbol, dynamic>(#C4))){(dart.core::Invocation) → dynamic};
}
@@ -36,14 +36,14 @@ library from "org-dartlang-test:///main.dart" as main {
method noSuchMethod(dart.core::Invocation msg) → dynamic {
dart.core::print("noSouchMethod!!");
}
synthetic no-such-method-forwarder get field() → dart.core::bool
return this.{main::Foo2::noSuchMethod}(new dart.core::_InvocationMirror::_withType(#C7, 1, #C2, #C3, dart.core::Map::unmodifiable<dart.core::Symbol, dynamic>(#C4))){(dart.core::Invocation) → dynamic} as{TypeError,ForDynamic} dart.core::bool;
synthetic no-such-method-forwarder set field(dart.core::bool value) → void
return this.{main::Foo2::noSuchMethod}(new dart.core::_InvocationMirror::_withType(#C8, 2, #C2, dart.core::List::unmodifiable<dynamic>(dart.core::_GrowableList::_literal1<dynamic>(value)), dart.core::Map::unmodifiable<dart.core::Symbol, dynamic>(#C4))){(dart.core::Invocation) → dynamic};
synthetic no-such-method-forwarder method method() → void
return this.{main::Foo2::noSuchMethod}(new dart.core::_InvocationMirror::_withType(#C1, 0, #C2, #C3, dart.core::Map::unmodifiable<dart.core::Symbol, dynamic>(#C4))){(dart.core::Invocation) → dynamic};
synthetic no-such-method-forwarder get getter() → dart.core::bool
return this.{main::Foo2::noSuchMethod}(new dart.core::_InvocationMirror::_withType(#C5, 1, #C2, #C3, dart.core::Map::unmodifiable<dart.core::Symbol, dynamic>(#C4))){(dart.core::Invocation) → dynamic} as{TypeError,ForDynamic} dart.core::bool;
synthetic no-such-method-forwarder get field() → dart.core::bool
return this.{main::Foo2::noSuchMethod}(new dart.core::_InvocationMirror::_withType(#C7, 1, #C2, #C3, dart.core::Map::unmodifiable<dart.core::Symbol, dynamic>(#C4))){(dart.core::Invocation) → dynamic} as{TypeError,ForDynamic} dart.core::bool;
synthetic no-such-method-forwarder set field(dart.core::bool value) → void
return this.{main::Foo2::noSuchMethod}(new dart.core::_InvocationMirror::_withType(#C8, 2, #C2, dart.core::List::unmodifiable<dynamic>(dart.core::_GrowableList::_literal1<dynamic>(value)), dart.core::Map::unmodifiable<dart.core::Symbol, dynamic>(#C4))){(dart.core::Invocation) → dynamic};
synthetic no-such-method-forwarder set setter(dart.core::bool b) → void
return this.{main::Foo2::noSuchMethod}(new dart.core::_InvocationMirror::_withType(#C6, 2, #C2, dart.core::List::unmodifiable<dynamic>(dart.core::_GrowableList::_literal1<dynamic>(b)), dart.core::Map::unmodifiable<dart.core::Symbol, dynamic>(#C4))){(dart.core::Invocation) → dynamic};
}
@@ -17,26 +17,6 @@ library from "org-dartlang-test:///main.dart" as main {
const synthetic constructor •() → main::_WithListMixin&Object&ListMixin
: super dart.core::Object::•()
;
get /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ first() → dart.core::int {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
return this.{dart.core::List::[]}(0){(dart.core::int) → dart.core::int};
}
set /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ first(covariant-by-class dart.core::int value) → void {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
this.{dart.core::List::[]=}(0, value){(dart.core::int, dart.core::int) → void};
}
get /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ last() → dart.core::int {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
return this.{dart.core::List::[]}(this.{dart.core::List::length}{dart.core::int}.{dart.core::num::-}(1){(dart.core::num) → dart.core::int}){(dart.core::int) → dart.core::int};
}
set /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ last(covariant-by-class dart.core::int value) → void {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
this.{dart.core::List::[]=}(this.{dart.core::List::length}{dart.core::int}.{dart.core::num::-}(1){(dart.core::num) → dart.core::int}, value){(dart.core::int, dart.core::int) → void};
}
@#C3
get /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ iterator() → dart.core::Iterator<dart.core::int>
return new dart._internal::ListIterator::•<dart.core::int>(this);
@@ -58,6 +38,26 @@ library from "org-dartlang-test:///main.dart" as main {
return this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0;
get /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ isNotEmpty() → dart.core::bool
return !this.{dart.collection::ListBase::isEmpty}{dart.core::bool};
get /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ first() → dart.core::int {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
return this.{dart.core::List::[]}(0){(dart.core::int) → dart.core::int};
}
set /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ first(covariant-by-class dart.core::int value) → void {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
this.{dart.core::List::[]=}(0, value){(dart.core::int, dart.core::int) → void};
}
get /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ last() → dart.core::int {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
return this.{dart.core::List::[]}(this.{dart.core::List::length}{dart.core::int}.{dart.core::num::-}(1){(dart.core::num) → dart.core::int}){(dart.core::int) → dart.core::int};
}
set /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ last(covariant-by-class dart.core::int value) → void {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
this.{dart.core::List::[]=}(this.{dart.core::List::length}{dart.core::int}.{dart.core::num::-}(1){(dart.core::num) → dart.core::int}, value){(dart.core::int, dart.core::int) → void};
}
get /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ single() → dart.core::int {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
@@ -17,26 +17,6 @@ library from "org-dartlang-test:///main.dart" as main {
const synthetic constructor •() → main::_WithListMixin&Object&ListMixin
: super dart.core::Object::•()
;
get /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ first() → dart.core::int {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
return this.{dart.core::List::[]}(0){(dart.core::int) → dart.core::int};
}
set /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ first(covariant-by-class dart.core::int value) → void {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
this.{dart.core::List::[]=}(0, value){(dart.core::int, dart.core::int) → void};
}
get /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ last() → dart.core::int {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
return this.{dart.core::List::[]}(this.{dart.core::List::length}{dart.core::int}.{dart.core::num::-}(1){(dart.core::num) → dart.core::int}){(dart.core::int) → dart.core::int};
}
set /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ last(covariant-by-class dart.core::int value) → void {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
this.{dart.core::List::[]=}(this.{dart.core::List::length}{dart.core::int}.{dart.core::num::-}(1){(dart.core::num) → dart.core::int}, value){(dart.core::int, dart.core::int) → void};
}
@#C3
get /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ iterator() → dart.core::Iterator<dart.core::int>
return new dart._internal::ListIterator::•<dart.core::int>(this);
@@ -58,6 +38,26 @@ library from "org-dartlang-test:///main.dart" as main {
return this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0;
get /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ isNotEmpty() → dart.core::bool
return !this.{dart.collection::ListBase::isEmpty}{dart.core::bool};
get /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ first() → dart.core::int {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
return this.{dart.core::List::[]}(0){(dart.core::int) → dart.core::int};
}
set /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ first(covariant-by-class dart.core::int value) → void {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
this.{dart.core::List::[]=}(0, value){(dart.core::int, dart.core::int) → void};
}
get /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ last() → dart.core::int {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
return this.{dart.core::List::[]}(this.{dart.core::List::length}{dart.core::int}.{dart.core::num::-}(1){(dart.core::num) → dart.core::int}){(dart.core::int) → dart.core::int};
}
set /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ last(covariant-by-class dart.core::int value) → void {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
this.{dart.core::List::[]=}(this.{dart.core::List::length}{dart.core::int}.{dart.core::num::-}(1){(dart.core::num) → dart.core::int}, value){(dart.core::int, dart.core::int) → void};
}
get /* from org-dartlang-sdk:///sdk/lib/collection/list.dart */ single() → dart.core::int {
if(this.{dart.core::List::length}{dart.core::int} =={dart.core::num::==}{(dart.core::Object) → dart.core::bool} 0)
throw dart._internal::IterableElementError::noElement();
+4 -2
View File
@@ -16,8 +16,8 @@ namespace dart {
bool GetExperimentalFeatureDefault(ExperimentalFeature feature) {
constexpr bool kFeatureValues[] = {
true, true, true, true, true, true, true, true, true,
true, true, true, true, true, true, true, true, true,
true, true, true, true, true, true, true, true, true, true,
true, true, true, true, true, true, true, true, true, true,
true, true, true, true, true, true, true, true, true,
};
ASSERT(static_cast<size_t>(feature) < ARRAY_SIZE(kFeatureValues));
@@ -26,6 +26,8 @@ bool GetExperimentalFeatureDefault(ExperimentalFeature feature) {
const char* GetExperimentalFeatureName(ExperimentalFeature feature) {
constexpr const char* kFeatureNames[] = {
"native-assets",
"getter-setter-error",
"sound-flow-analysis",
"null-aware-elements",
"inference-using-bounds",
+2
View File
@@ -12,6 +12,8 @@
namespace dart {
enum class ExperimentalFeature {
native_assets,
getter_setter_error,
sound_flow_analysis,
null_aware_elements,
inference_using_bounds,
@@ -78,6 +78,8 @@ enum ConflictStaticSetterInstanceMembers {
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
// [cfe] This static member conflicts with an instance member.
int foo() => 37;
// ^
// [cfe] The declaration conflicts with setter 'foo'.
}
enum ConflictStaticInstanceProperty2 {
@@ -86,6 +88,7 @@ enum ConflictStaticInstanceProperty2 {
static void set foo(int _) {}
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
// [cfe] Static property 'foo' conflicts with instance property of the same name.
// [cfe] This static member conflicts with an instance member.
}
@@ -98,6 +101,8 @@ enum ConflictStaticInstanceProperty {
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
// [cfe] This static member conflicts with an instance member.
void set foo(int _) {}
// ^
// [cfe] Instance property 'foo' conflicts with static property of the same name.
}
@@ -172,14 +177,14 @@ enum ConflictEnumValueInheritedToString {
toString;
//^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_STATIC_AND_INSTANCE
// [cfe] 'toString' is already declared in this scope.
// [cfe] Can't declare a member that conflicts with an inherited one.
}
enum ConflictEnumValueImplicitValues {
values;
//^^^^^^
// [analyzer] COMPILE_TIME_ERROR.VALUES_DECLARATION_IN_ENUM
// [cfe] 'values' is already declared in this scope.
// [cfe] An enum can't declare a member named 'values'.
}
enum ConflictEnumValueInheritedFoo with MethodFoo {
@@ -192,9 +197,6 @@ enum ConflictEnumValueInheritedFoo with MethodFoo {
enum ConflictClassGetterSetterTypeInstance {
e1;
num get foo => 42;
// ^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'num' of the getter 'ConflictClassGetterSetterTypeInstance.foo' is not a subtype of the type 'int' of the setter 'ConflictClassGetterSetterTypeInstance.foo'.
// Type of setter parameter must be subtype of type of getter.
void set foo(int _) {}
@@ -203,9 +205,6 @@ enum ConflictClassGetterSetterTypeInstance {
enum ConflictClassGetterSetterTypeStatic {
e1;
static num get foo => 42;
// ^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'num' of the getter 'ConflictClassGetterSetterTypeStatic.foo' is not a subtype of the type 'int' of the setter 'ConflictClassGetterSetterTypeStatic.foo'.
// Type of setter parameter must be subtype of type of getter.
static void set foo(int _) {}
@@ -219,9 +218,6 @@ enum NoConflictClassEnumValueStaticSetter {
enum ConflictClassEnumValueStaticSetterType {
e1;
//^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'ConflictClassEnumValueStaticSetterType' of the getter 'ConflictClassEnumValueStaticSetterType.e1' is not a subtype of the type 'int' of the setter 'ConflictClassEnumValueStaticSetterType.e1'.
// Type of setter parameter must be subtype of type of getter.
static void set e1(int _) {}
@@ -332,22 +328,18 @@ enum DeclareSetterOptional {
enum ConflictConstructorNameStatic {
e1.foo();
const ConflictConstructorNameStatic.foo();
// ^
// [cfe] Conflicts with member 'foo'.
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_CONSTRUCTOR_AND_STATIC_MEMBER
static int get foo => 42;
// ^
// [cfe] Conflicts with constructor 'ConflictConstructorNameStatic.foo'.
// [cfe] The member conflicts with constructor 'ConflictConstructorNameStatic.foo'.
}
enum ConflictConstructorNameStaticEnumValue {
e1.e1();
//^
// [cfe] Conflicts with constructor 'ConflictConstructorNameStaticEnumValue.e1'.
const ConflictConstructorNameStaticEnumValue.e1();
// ^
// [cfe] Conflicts with member 'e1'.
// [cfe] The constructor conflicts with member 'e1'.
// ^^
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_CONSTRUCTOR_AND_STATIC_MEMBER
}
@@ -397,8 +389,7 @@ enum ConflictClassEnumValue {
ConflictClassEnumValue;
//^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.ENUM_CONSTANT_SAME_NAME_AS_ENCLOSING
// [cfe] Name of enum constant 'ConflictClassEnumValue' can't be the same as the enum's own name.
// ^
// [cfe] A class member can't have the same name as the enclosing class.
// [cfe] Couldn't find constructor 'ConflictClassEnumValue'.
}
@@ -652,8 +643,6 @@ enum NSMImplementsNeverIndex implements NeverIndexGetter {
// Cannot have cyclic references between constants.
enum CyclicReference {
// ^
// [cfe] Constant evaluation error:
e1(e2),
//^^
// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_COMPILE_TIME_CONSTANT
@@ -7,14 +7,8 @@
// of the setter.
extension E1 on int {
static int get property => 1;
// ^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'int' of the getter 'property' is not a subtype of the type 'String' of the setter 'property'.
static void set property(String value) {}
int get property2 => 1;
// ^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'int' of the getter 'property2' is not a subtype of the type 'String' of the setter 'property2'.
void set property2(String x) {}
}
-1
View File
@@ -11,7 +11,6 @@ class C {
get a {
//^
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] 'a' is already declared in this scope.
return 1;
}
-6
View File
@@ -23,9 +23,6 @@ class C {}
class T1 {
late A getterField;
A get field {
// ^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'A' of the getter 'T1.field' is not a subtype of the type 'B' of the setter 'T1.field'.
return getterField;
}
@@ -38,9 +35,6 @@ class T2 {
late A getterField;
late C setterField;
A get field {
// ^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'A' of the getter 'T2.field' is not a subtype of the type 'C' of the setter 'T2.field'.
return getterField;
}
@@ -7,9 +7,6 @@
int bar = 499;
int get foo => bar;
// ^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'int' of the getter 'foo' is not a subtype of the type 'String' of the setter 'foo'.
void set foo(String str) {
bar = str.length;
@@ -41,7 +41,7 @@ class A {
void set field12(int _) {} //# 52: ok
num field13 = 0; //# 53: compile-time error
set field14(num _) {} //# 54: compile-time error
num field15 = 0; //# 55: compile-time error
num field15 = 0; //# 55: ok
}
class B extends A {
@@ -16,7 +16,7 @@ class A {
void set setter4(num x) {} //# 004: compile-time error
void set setter5(num x) {} //# 005: ok
void set setter6(num x) {} //# 006: compile-time error
void set setter7(num x) {} //# 007: compile-time error
void set setter7(num x) {} //# 007: ok
}
class B extends A {
@@ -34,27 +34,15 @@ Never set wrongReturnType3(_) => throw 1;
// [cfe] The return type of the setter must be 'void' or absent.
int get nonSubtypes1 => 1;
// ^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'int' of the getter 'nonSubtypes1' is not a subtype of the type 'String' of the setter 'nonSubtypes1'.
set nonSubtypes1(String _) {}
int? get nonSubtypes2 => 1;
// ^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'int?' of the getter 'nonSubtypes2' is not a subtype of the type 'int' of the setter 'nonSubtypes2'.
set nonSubtypes2(int _) {}
FutureOr<int> get nonSubtypes3 => 1;
// ^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'FutureOr<int>' of the getter 'nonSubtypes3' is not a subtype of the type 'int' of the setter 'nonSubtypes3'.
set nonSubtypes3(int _) {}
dynamic get nonSubtypes4 => 1;
// ^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'dynamic' of the getter 'nonSubtypes4' is not a subtype of the type 'int' of the setter 'nonSubtypes4'.
set nonSubtypes4(int _) {}
class C {
@@ -89,51 +77,27 @@ class C {
// [cfe] The return type of the setter must be 'void' or absent.
static int get staticNonSubtypes1 => 1;
// ^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'int' of the getter 'C.staticNonSubtypes1' is not a subtype of the type 'String' of the setter 'C.staticNonSubtypes1'.
static set staticNonSubtypes1(String _) {}
static int? get staticNonSubtypes2 => 1;
// ^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'int?' of the getter 'C.staticNonSubtypes2' is not a subtype of the type 'int' of the setter 'C.staticNonSubtypes2'.
static set staticNonSubtypes2(int _) {}
static FutureOr<int> get staticNonSubtypes3 => 1;
// ^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'FutureOr<int>' of the getter 'C.staticNonSubtypes3' is not a subtype of the type 'int' of the setter 'C.staticNonSubtypes3'.
static set staticNonSubtypes3(int _) {}
static dynamic get staticNonSubtypes4 => 1;
// ^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'dynamic' of the getter 'C.staticNonSubtypes4' is not a subtype of the type 'int' of the setter 'C.staticNonSubtypes4'.
static set staticNonSubtypes4(int _) {}
int get nonSubtypes1 => 1;
// ^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'int' of the getter 'C.nonSubtypes1' is not a subtype of the type 'String' of the setter 'C.nonSubtypes1'.
set nonSubtypes1(String _) {}
int? get nonSubtypes2 => 1;
// ^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'int?' of the getter 'C.nonSubtypes2' is not a subtype of the type 'int' of the setter 'C.nonSubtypes2'.
set nonSubtypes2(int _) {}
FutureOr<int> get nonSubtypes3 => 1;
// ^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'FutureOr<int>' of the getter 'C.nonSubtypes3' is not a subtype of the type 'int' of the setter 'C.nonSubtypes3'.
set nonSubtypes3(int _) {}
dynamic get nonSubtypes4 => 1;
// ^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.GETTER_NOT_SUBTYPE_SETTER_TYPES
// [cfe] The type 'dynamic' of the getter 'C.nonSubtypes4' is not a subtype of the type 'int' of the setter 'C.nonSubtypes4'.
set nonSubtypes4(int _) {}
}
+15 -3
View File
@@ -149,9 +149,6 @@ features:
dot-shorthands:
help: "Shorter dot syntax for static accesses."
getter-setter-error:
help: "Stop reporting errors about mismatching types in a getter/setter pair."
# Experiment flag only used for testing.
test-experiment:
help: >-
@@ -165,6 +162,21 @@ features:
# Shipped flags should be marked retired the following stable release.
#
getter-setter-error:
enabledIn: '3.9.0'
validation: |
class A {
String get foo => 'feature enabled';
void set foo(int value) {}
}
main() {
A a = new A();
a.foo = 0;
print(a.foo);
}
help: "Stop reporting errors about mismatching types in a getter/setter pair."
sound-flow-analysis:
enabledIn: '3.9.0'
validation: |