From 0f43a108319006a080360fba685f2d884b4ee1ca Mon Sep 17 00:00:00 2001 From: Pascal Welsch Date: Sun, 30 Dec 2018 20:10:04 +0100 Subject: [PATCH 1/2] Remove non compiling APIs due to a dart-lang bug Bug https://github.com/dart-lang/sdk/issues/35518 prevents calls from external classes to those methods to not pass the generic bound type correctly resulting in a wrong inferred argument bounds violation --- lib/src/k_iterable.dart | 28 ++++++++++------- lib/src/k_map.dart | 10 ++++--- test/collection/iterable_extensions_test.dart | 30 ------------------- 3 files changed, 23 insertions(+), 45 deletions(-) diff --git a/lib/src/k_iterable.dart b/lib/src/k_iterable.dart index 25304cd7..354bed13 100644 --- a/lib/src/k_iterable.dart +++ b/lib/src/k_iterable.dart @@ -102,8 +102,9 @@ abstract class KIterableExtension { * * If any two elements are equal, the last one overwrites the former value in the map. */ - M associateWithTo>( - M destination, V Function(T) valueSelector); + // TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed + // M associateWithTo>( + // M destination, V Function(T) valueSelector); /** * Returns an average value produced by [selector] function applied to each element in the collection. @@ -204,8 +205,9 @@ abstract class KIterableExtension { * @param [predicate] function that takes the index of an element and the element itself * and returns the result of predicate evaluation on the element. */ - C filterIndexedTo>( - C destination, bool Function(int index, T) predicate); + // TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed + // C filterIndexedTo>( + // C destination, bool Function(int index, T) predicate); /** * Returns a list containing all elements that are instances of specified type parameter R. @@ -225,19 +227,22 @@ abstract class KIterableExtension { /** * Appends all elements that are not `null` to the given [destination]. */ - C filterNotNullTo>(C destination); + // TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed + // C filterNotNullTo>(C destination); /** * Appends all elements not matching the given [predicate] to the given [destination]. */ - C filterNotTo>( - C destination, bool Function(T) predicate); + // TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed + // C filterNotTo>( + // C destination, bool Function(T) predicate); /** * Appends all elements matching the given [predicate] to the given [destination]. */ - C filterTo>( - C destination, bool Function(T) predicate); + // TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed + // C filterTo>( + // C destination, bool Function(T) predicate); /** * Returns the first element matching the given [predicate], or `null` if no such element was found. @@ -327,8 +332,9 @@ abstract class KIterableExtension { * * @return The [destination] map. */ - M groupByTo>>( - M destination, K Function(T) keySelector); + // TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed + // M groupByTo>>( + // M destination, K Function(T) keySelector); /** * Groups values returned by the [valueTransform] function applied to each element of the original collection diff --git a/lib/src/k_map.dart b/lib/src/k_map.dart index cbfd9d5f..1f0ad500 100644 --- a/lib/src/k_map.dart +++ b/lib/src/k_map.dart @@ -139,8 +139,9 @@ abstract class KMapExtension { * In case if any two entries are mapped to the equal keys, the value of the latter one will overwrite * the value associated with the former one. */ - M mapKeysTo>( - M destination, R Function(KMapEntry entry) transform); + // TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed + // M mapKeysTo>( + // M destination, R Function(KMapEntry entry) transform); /** * Returns a new map with entries having the keys of this map and the values obtained by applying the [transform] @@ -154,8 +155,9 @@ abstract class KMapExtension { * Populates the given [destination] map with entries having the keys of this map and the values obtained * by applying the [transform] function to each entry in this [Map]. */ - M mapValuesTo>( - M destination, R Function(KMapEntry entry) transform); + // TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed + // M mapValuesTo>( + // M destination, R Function(KMapEntry entry) transform); /** * Returns a map containing all entries of the original map except the entry with the given [key]. diff --git a/test/collection/iterable_extensions_test.dart b/test/collection/iterable_extensions_test.dart index c1afd470..0805a37d 100644 --- a/test/collection/iterable_extensions_test.dart +++ b/test/collection/iterable_extensions_test.dart @@ -503,15 +503,6 @@ void testIterable(KIterable Function() emptyIterable, }); }); - group("filterTo", () { - test("filterTo doesn't allow null as destination", () { - final list = emptyIterable(); - var e = - catchException(() => list.filterTo(null, (_) => true)); - expect(e.message, allOf(contains("null"), contains("destination"))); - }); - }); - group("filterNot", () { test("filterNot", () { final iterable = iterableOf(["paul", "peter", "john", "lisa"]); @@ -524,13 +515,6 @@ void testIterable(KIterable Function() emptyIterable, var e = catchException(() => list.filterNot(null)); expect(e.message, allOf(contains("null"), contains("predicate"))); }); - - test("filterNotTo doesn't allow null as destination", () { - final list = emptyIterable(); - var e = catchException( - () => list.filterNotTo(null, (_) => true)); - expect(e.message, allOf(contains("null"), contains("destination"))); - }); }); group("filterNotNull", () { @@ -798,13 +782,6 @@ void testIterable(KIterable Function() emptyIterable, expect(e.message, allOf(contains("null"), contains("keySelector"))); }); - test("groupByTo doesn't allow null as destination", () { - final iterable = iterableOf([1, 2, 3]); - var e = catchException( - () => iterable.groupByTo(null, (it) => it)); - expect(e.message, allOf(contains("null"), contains("destination"))); - }); - test("groupByTransform doesn't allow null as keySelector", () { final iterable = iterableOf([1, 2, 3]); var e = catchException( @@ -819,13 +796,6 @@ void testIterable(KIterable Function() emptyIterable, expect(e.message, allOf(contains("null"), contains("valueTransform"))); }); - test("groupByTo doesn't allow null as destination", () { - final iterable = iterableOf([1, 2, 3]); - var e = catchException( - () => iterable.groupByTo(null, (it) => it)); - expect(e.message, allOf(contains("null"), contains("destination"))); - }); - test("groupByToTransform doesn't allow null as destination", () { final iterable = iterableOf([1, 2, 3]); var e = catchException( From 3543e07bb6aa9c5292f52816528990a432ae4657 Mon Sep 17 00:00:00 2001 From: Pascal Welsch Date: Sun, 30 Dec 2018 20:38:27 +0100 Subject: [PATCH 2/2] Remove overrides of impls of removed methods --- lib/src/extension/iterable_extension_mixin.dart | 12 ++++++------ lib/src/extension/map_extensions_mixin.dart | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/src/extension/iterable_extension_mixin.dart b/lib/src/extension/iterable_extension_mixin.dart index f8e955c0..0b71bdfa 100644 --- a/lib/src/extension/iterable_extension_mixin.dart +++ b/lib/src/extension/iterable_extension_mixin.dart @@ -89,7 +89,7 @@ abstract class KIterableExtensionsMixin return associateWithTo(linkedMapOf(), valueSelector); } - @override + // TODO add @override again M associateWithTo>( M destination, V Function(T) valueSelector) { assert(() { @@ -285,7 +285,7 @@ abstract class KIterableExtensionsMixin return list; } - @override + // TODO add @override again C filterIndexedTo>( C destination, bool Function(int index, T) predicate) { assert(() { @@ -328,7 +328,7 @@ abstract class KIterableExtensionsMixin return list; } - @override + // TODO add @override again C filterNotNullTo>(C destination) { for (final element in iter) { if (element != null) { @@ -338,7 +338,7 @@ abstract class KIterableExtensionsMixin return destination; } - @override + // TODO add @override again C filterNotTo>( C destination, bool Function(T) predicate) { assert(() { @@ -354,7 +354,7 @@ abstract class KIterableExtensionsMixin return destination; } - @override + // TODO add @override again C filterTo>( C destination, bool Function(T) predicate) { assert(() { @@ -518,7 +518,7 @@ abstract class KIterableExtensionsMixin return groups; } - @override + // TODO add @override again M groupByTo>>( M destination, K Function(T) keySelector) { assert(() { diff --git a/lib/src/extension/map_extensions_mixin.dart b/lib/src/extension/map_extensions_mixin.dart index 60474e92..ca1ded18 100644 --- a/lib/src/extension/map_extensions_mixin.dart +++ b/lib/src/extension/map_extensions_mixin.dart @@ -34,7 +34,7 @@ abstract class KMapExtensionsMixin return mapped; } - @override + // TODO add @override again M mapKeysTo>( M destination, R Function(KMapEntry entry) transform) { return entries.associateByTo(destination, transform, (it) => it.value); @@ -46,7 +46,7 @@ abstract class KMapExtensionsMixin return mapped; } - @override + // TODO add @override again M mapValuesTo>( M destination, R Function(KMapEntry entry) transform) { return entries.associateByTo(destination, (it) => it.key, transform);