diff --git a/json_serializable/CHANGELOG.md b/json_serializable/CHANGELOG.md index 7c14862e2..689716d13 100644 --- a/json_serializable/CHANGELOG.md +++ b/json_serializable/CHANGELOG.md @@ -1,6 +1,7 @@ ## 6.9.0-wip - Use conditional map syntax to clean up `null` handling in `toJson` functions. +- Require `analyzer: ^6.9.0` - Require Dart 3.5 ## 6.8.0 diff --git a/json_serializable/lib/src/field_helpers.dart b/json_serializable/lib/src/field_helpers.dart index f0b7828e9..c14d0d4b4 100644 --- a/json_serializable/lib/src/field_helpers.dart +++ b/json_serializable/lib/src/field_helpers.dart @@ -37,21 +37,21 @@ class _FieldSet implements Comparable<_FieldSet> { static int _sortByLocation(FieldElement a, FieldElement b) { final checkerA = TypeChecker.fromStatic( - (a.enclosingElement as InterfaceElement).thisType, + (a.enclosingElement3 as InterfaceElement).thisType, ); - if (!checkerA.isExactly(b.enclosingElement)) { + if (!checkerA.isExactly(b.enclosingElement3)) { // in this case, you want to prioritize the enclosingElement that is more // "super". - if (checkerA.isAssignableFrom(b.enclosingElement)) { + if (checkerA.isAssignableFrom(b.enclosingElement3)) { return -1; } final checkerB = TypeChecker.fromStatic( - (b.enclosingElement as InterfaceElement).thisType); + (b.enclosingElement3 as InterfaceElement).thisType); - if (checkerB.isAssignableFrom(a.enclosingElement)) { + if (checkerB.isAssignableFrom(a.enclosingElement3)) { return 1; } } @@ -83,7 +83,7 @@ List createSortedFieldSet(ClassElement element) { for (final v in manager.getInheritedConcreteMap2(element).values) { assert(v is! FieldElement); - if (_dartCoreObjectChecker.isExactly(v.enclosingElement)) { + if (_dartCoreObjectChecker.isExactly(v.enclosingElement3)) { continue; } diff --git a/json_serializable/lib/src/type_helpers/json_converter_helper.dart b/json_serializable/lib/src/type_helpers/json_converter_helper.dart index ce78f19d1..9958368af 100644 --- a/json_serializable/lib/src/type_helpers/json_converter_helper.dart +++ b/json_serializable/lib/src/type_helpers/json_converter_helper.dart @@ -214,7 +214,7 @@ _JsonConvertData? _typeConverterFrom( final annotationElement = match.elementAnnotation?.element; if (annotationElement is PropertyAccessorElement) { - final enclosing = annotationElement.enclosingElement; + final enclosing = annotationElement.enclosingElement3; var accessString = annotationElement.name; diff --git a/json_serializable/lib/src/utils.dart b/json_serializable/lib/src/utils.dart index 782eeb53d..d2f5f3342 100644 --- a/json_serializable/lib/src/utils.dart +++ b/json_serializable/lib/src/utils.dart @@ -263,15 +263,15 @@ extension ExecutableElementExtension on ExecutableElement { } if (this is MethodElement) { - return '${enclosingElement.name}.$name'; + return '${enclosingElement3.name}.$name'; } if (this is ConstructorElement) { // Ignore the default constructor. if (name.isEmpty) { - return '${enclosingElement.name}'; + return '${enclosingElement3.name}'; } - return '${enclosingElement.name}.$name'; + return '${enclosingElement3.name}.$name'; } throw UnsupportedError( diff --git a/json_serializable/pubspec.yaml b/json_serializable/pubspec.yaml index 854f2c7fd..706fdf5d5 100644 --- a/json_serializable/pubspec.yaml +++ b/json_serializable/pubspec.yaml @@ -15,7 +15,7 @@ topics: resolution: workspace dependencies: - analyzer: ^6.5.0 + analyzer: ^6.9.0 async: ^2.10.0 build: ^2.4.1 build_config: ^1.1.0 @@ -36,7 +36,7 @@ dev_dependencies: path: ../shared_test build_runner: ^2.4.6 build_verify: ^3.0.0 - dart_style: ^2.3.2 + dart_style: ^2.3.7 logging: ^1.0.0 source_gen_test: ^1.0.6 test: ^1.24.4 diff --git a/json_serializable/tool/shared.dart b/json_serializable/tool/shared.dart index 6565baf9d..2036623b8 100644 --- a/json_serializable/tool/shared.dart +++ b/json_serializable/tool/shared.dart @@ -8,7 +8,8 @@ import 'package:build/build.dart'; import 'package:dart_style/dart_style.dart'; import 'package:yaml/yaml.dart'; -final formatter = DartFormatter(); +final formatter = + DartFormatter(languageVersion: DartFormatter.latestLanguageVersion); // Until we have verification in pkg:build and friends // https://github.com/dart-lang/build/issues/590