Skip to content

Commit

Permalink
Merge pull request #46 from passsy/feature/remove_non_compiling_apis
Browse files Browse the repository at this point in the history
Remove non compiling APIs due to a dart-lang bug
  • Loading branch information
passsy authored Dec 30, 2018
2 parents 01c9df3 + 3543e07 commit b7b7c07
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 53 deletions.
12 changes: 6 additions & 6 deletions lib/src/extension/iterable_extension_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ abstract class KIterableExtensionsMixin<T>
return associateWithTo(linkedMapOf<T, V>(), valueSelector);
}

@override
// TODO add @override again
M associateWithTo<V, M extends KMutableMap<T, V>>(
M destination, V Function(T) valueSelector) {
assert(() {
Expand Down Expand Up @@ -285,7 +285,7 @@ abstract class KIterableExtensionsMixin<T>
return list;
}

@override
// TODO add @override again
C filterIndexedTo<C extends KMutableCollection<T>>(
C destination, bool Function(int index, T) predicate) {
assert(() {
Expand Down Expand Up @@ -328,7 +328,7 @@ abstract class KIterableExtensionsMixin<T>
return list;
}

@override
// TODO add @override again
C filterNotNullTo<C extends KMutableCollection<T>>(C destination) {
for (final element in iter) {
if (element != null) {
Expand All @@ -338,7 +338,7 @@ abstract class KIterableExtensionsMixin<T>
return destination;
}

@override
// TODO add @override again
C filterNotTo<C extends KMutableCollection<T>>(
C destination, bool Function(T) predicate) {
assert(() {
Expand All @@ -354,7 +354,7 @@ abstract class KIterableExtensionsMixin<T>
return destination;
}

@override
// TODO add @override again
C filterTo<C extends KMutableCollection<T>>(
C destination, bool Function(T) predicate) {
assert(() {
Expand Down Expand Up @@ -518,7 +518,7 @@ abstract class KIterableExtensionsMixin<T>
return groups;
}

@override
// TODO add @override again
M groupByTo<K, M extends KMutableMap<K, KMutableList<T>>>(
M destination, K Function(T) keySelector) {
assert(() {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/extension/map_extensions_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class KMapExtensionsMixin<K, V>
return mapped;
}

@override
// TODO add @override again
M mapKeysTo<R, M extends KMutableMap<R, V>>(
M destination, R Function(KMapEntry<K, V> entry) transform) {
return entries.associateByTo(destination, transform, (it) => it.value);
Expand All @@ -46,7 +46,7 @@ abstract class KMapExtensionsMixin<K, V>
return mapped;
}

@override
// TODO add @override again
M mapValuesTo<R, M extends KMutableMap<K, R>>(
M destination, R Function(KMapEntry<K, V> entry) transform) {
return entries.associateByTo(destination, (it) => it.key, transform);
Expand Down
28 changes: 17 additions & 11 deletions lib/src/k_iterable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ abstract class KIterableExtension<T> {
*
* If any two elements are equal, the last one overwrites the former value in the map.
*/
M associateWithTo<V, M extends KMutableMap<T, V>>(
M destination, V Function(T) valueSelector);
// TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed
// M associateWithTo<V, M extends KMutableMap<T, V>>(
// M destination, V Function(T) valueSelector);

/**
* Returns an average value produced by [selector] function applied to each element in the collection.
Expand Down Expand Up @@ -204,8 +205,9 @@ abstract class KIterableExtension<T> {
* @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 extends KMutableCollection<T>>(
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 extends KMutableCollection<T>>(
// C destination, bool Function(int index, T) predicate);

/**
* Returns a list containing all elements that are instances of specified type parameter R.
Expand All @@ -225,19 +227,22 @@ abstract class KIterableExtension<T> {
/**
* Appends all elements that are not `null` to the given [destination].
*/
C filterNotNullTo<C extends KMutableCollection<T>>(C destination);
// TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed
// C filterNotNullTo<C extends KMutableCollection<T>>(C destination);

/**
* Appends all elements not matching the given [predicate] to the given [destination].
*/
C filterNotTo<C extends KMutableCollection<T>>(
C destination, bool Function(T) predicate);
// TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed
// C filterNotTo<C extends KMutableCollection<T>>(
// C destination, bool Function(T) predicate);

/**
* Appends all elements matching the given [predicate] to the given [destination].
*/
C filterTo<C extends KMutableCollection<T>>(
C destination, bool Function(T) predicate);
// TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed
// C filterTo<C extends KMutableCollection<T>>(
// C destination, bool Function(T) predicate);

/**
* Returns the first element matching the given [predicate], or `null` if no such element was found.
Expand Down Expand Up @@ -327,8 +332,9 @@ abstract class KIterableExtension<T> {
*
* @return The [destination] map.
*/
M groupByTo<K, M extends KMutableMap<K, KMutableList<T>>>(
M destination, K Function(T) keySelector);
// TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed
// M groupByTo<K, M extends KMutableMap<K, KMutableList<T>>>(
// M destination, K Function(T) keySelector);

/**
* Groups values returned by the [valueTransform] function applied to each element of the original collection
Expand Down
10 changes: 6 additions & 4 deletions lib/src/k_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ abstract class KMapExtension<K, V> {
* 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<R, M extends KMutableMap<R, V>>(
M destination, R Function(KMapEntry<K, V> entry) transform);
// TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed
// M mapKeysTo<R, M extends KMutableMap<R, V>>(
// M destination, R Function(KMapEntry<K, V> entry) transform);

/**
* Returns a new map with entries having the keys of this map and the values obtained by applying the [transform]
Expand All @@ -154,8 +155,9 @@ abstract class KMapExtension<K, V> {
* 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<R, M extends KMutableMap<K, R>>(
M destination, R Function(KMapEntry<K, V> entry) transform);
// TODO add after https://github.com/dart-lang/sdk/issues/35518 has been fixed
// M mapValuesTo<R, M extends KMutableMap<K, R>>(
// M destination, R Function(KMapEntry<K, V> entry) transform);

/**
* Returns a map containing all entries of the original map except the entry with the given [key].
Expand Down
30 changes: 0 additions & 30 deletions test/collection/iterable_extensions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -503,15 +503,6 @@ void testIterable(KIterable<T> Function<T>() emptyIterable,
});
});

group("filterTo", () {
test("filterTo doesn't allow null as destination", () {
final list = emptyIterable<String>();
var e =
catchException<ArgumentError>(() => list.filterTo(null, (_) => true));
expect(e.message, allOf(contains("null"), contains("destination")));
});
});

group("filterNot", () {
test("filterNot", () {
final iterable = iterableOf(["paul", "peter", "john", "lisa"]);
Expand All @@ -524,13 +515,6 @@ void testIterable(KIterable<T> Function<T>() emptyIterable,
var e = catchException<ArgumentError>(() => list.filterNot(null));
expect(e.message, allOf(contains("null"), contains("predicate")));
});

test("filterNotTo doesn't allow null as destination", () {
final list = emptyIterable<String>();
var e = catchException<ArgumentError>(
() => list.filterNotTo(null, (_) => true));
expect(e.message, allOf(contains("null"), contains("destination")));
});
});

group("filterNotNull", () {
Expand Down Expand Up @@ -798,13 +782,6 @@ void testIterable(KIterable<T> Function<T>() 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<ArgumentError>(
() => 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<ArgumentError>(
Expand All @@ -819,13 +796,6 @@ void testIterable(KIterable<T> Function<T>() 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<ArgumentError>(
() => 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<ArgumentError>(
Expand Down

0 comments on commit b7b7c07

Please sign in to comment.