From 6b1f5947f6cd7667f26f48528693a01ce1f9ee4d Mon Sep 17 00:00:00 2001 From: devmil Date: Fri, 4 Oct 2024 16:13:53 +0200 Subject: [PATCH 1/4] Version 0.19.0 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index f75e89a..6b3ec29 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: dart_apitool description: A tool to analyze the public API of a package, create a model of it and diff it against another version to check semver. repository: https://github.com/bmw-tech/dart_apitool -version: 0.19.0-dev +version: 0.19.0 environment: sdk: ">=3.0.0 <4.0.0" From b18821e5cc08d9cbf407d40d28318b45845a62ab Mon Sep 17 00:00:00 2001 From: devmil Date: Fri, 4 Oct 2024 16:13:56 +0200 Subject: [PATCH 2/4] Version 0.19.1-dev --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 6b3ec29..630b954 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: dart_apitool description: A tool to analyze the public API of a package, create a model of it and diff it against another version to check semver. repository: https://github.com/bmw-tech/dart_apitool -version: 0.19.0 +version: 0.19.1-dev environment: sdk: ">=3.0.0 <4.0.0" From f930e4d5bd5fd537d669f691681baebb566e8a5e Mon Sep 17 00:00:00 2001 From: Michael Lamers Date: Wed, 9 Oct 2024 22:06:19 +0200 Subject: [PATCH 3/4] Interpret any change in return type to be breaking --- lib/src/diff/package_api_differ.dart | 12 +----------- .../diff/test_package_dynamic_handling_test.dart | 4 ++-- .../diff/test_package_widening_types_test.dart | 14 ++++++++++++++ .../lib/src/class_a.dart | 4 ++++ .../lib/src/class_a.dart | 4 ++++ 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/lib/src/diff/package_api_differ.dart b/lib/src/diff/package_api_differ.dart index 36e99ed..3b4bc67 100644 --- a/lib/src/diff/package_api_differ.dart +++ b/lib/src/diff/package_api_differ.dart @@ -382,17 +382,7 @@ class PackageApiDiffer { newExecutable, 'Return type changed. ${oldExecutable.returnTypeName} -> ${newExecutable.returnTypeName}', changes, - isCompatibleChange: typeHierarchy.isCompatibleReplacement( - oldTypeIdentifier: TypeIdentifier.fromNameAndLibraryPath( - typeName: oldExecutable.returnTypeName, - libraryPath: oldExecutable.returnTypeFullLibraryName, - ), - newTypeIdentifier: TypeIdentifier.fromNameAndLibraryPath( - typeName: newExecutable.returnTypeName, - libraryPath: newExecutable.returnTypeFullLibraryName, - ), - isTypePassedIn: false, - ), + isCompatibleChange: false, changeCode: ApiChangeCode.ce09, isExperimental: isExperimental, ); diff --git a/test/integration_tests/diff/test_package_dynamic_handling_test.dart b/test/integration_tests/diff/test_package_dynamic_handling_test.dart index d2a6db7..704cf1c 100644 --- a/test/integration_tests/diff/test_package_dynamic_handling_test.dart +++ b/test/integration_tests/diff/test_package_dynamic_handling_test.dart @@ -87,14 +87,14 @@ void main() { ); }); - test('is no breaking change for function return types', () { + test('is a breaking change for function return types', () { final functionChange = diffResult.apiChanges .where((ac) => ac.affectedDeclaration?.name.contains('function') ?? false) .single; expect( functionChange.isBreaking, - isFalse, + isTrue, ); }); diff --git a/test/integration_tests/diff/test_package_widening_types_test.dart b/test/integration_tests/diff/test_package_widening_types_test.dart index 70226e9..fe9fe39 100644 --- a/test/integration_tests/diff/test_package_widening_types_test.dart +++ b/test/integration_tests/diff/test_package_widening_types_test.dart @@ -57,6 +57,13 @@ void main() { isFalse, ); }); + + test('detects return type change and is breaking', () { + final localReturnTypeParamChange = diffResult.apiChanges + .where((ac) => ac.affectedDeclaration?.name == 'returnSomeInstance') + .single; + expect(localReturnTypeParamChange.isBreaking, isTrue); + }); }); group('narrowing types', () { late PackageApiDiffResult diffResult; @@ -89,6 +96,13 @@ void main() { isTrue, ); }); + + test('detects return type change and is breaking', () { + final localReturnTypeParamChange = diffResult.apiChanges + .where((ac) => ac.affectedDeclaration?.name == 'returnSomeInstance') + .single; + expect(localReturnTypeParamChange.isBreaking, isTrue); + }); }); }); } diff --git a/test/test_packages/widening_types_diff/package_a_with_narrow_types/lib/src/class_a.dart b/test/test_packages/widening_types_diff/package_a_with_narrow_types/lib/src/class_a.dart index 391379a..5a31518 100644 --- a/test/test_packages/widening_types_diff/package_a_with_narrow_types/lib/src/class_a.dart +++ b/test/test_packages/widening_types_diff/package_a_with_narrow_types/lib/src/class_a.dart @@ -6,6 +6,10 @@ class ClassA { void methodUsingLocalType(SomeSubType localTypeParam) { print(param); } + + SomeSubType returnSomeInstance() { + return SomeSubType(); + } } class SomeSuperType {} diff --git a/test/test_packages/widening_types_diff/package_a_with_wider_types/lib/src/class_a.dart b/test/test_packages/widening_types_diff/package_a_with_wider_types/lib/src/class_a.dart index 00456f6..679456b 100644 --- a/test/test_packages/widening_types_diff/package_a_with_wider_types/lib/src/class_a.dart +++ b/test/test_packages/widening_types_diff/package_a_with_wider_types/lib/src/class_a.dart @@ -6,6 +6,10 @@ class ClassA { void methodUsingLocalType(SomeSuperType localTypeParam) { print(param); } + + SomeSuperType returnSomeInstance() { + return SomeSubType(); + } } class SomeSuperType {} From 9e448062710b00420ff508014350778c76574b38 Mon Sep 17 00:00:00 2001 From: Michael Lamers Date: Wed, 9 Oct 2024 22:07:50 +0200 Subject: [PATCH 4/4] adapt CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d163669..11a4733 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Version 0.19.1 +- fixes widening return types not being detected as a breaking change + ## Version 0.19.0 - introduces `force-use-flutter` option for all commands to force dart_apitool to use the `flutter` command. - extend type usage tracking and fix situations in which types that are used in @visibleForTesting contexts were detected as not exported