Skip to content

Commit 5fad463

Browse files
committed
Merge: Make all Sets cloneable
Since there is no reason to forbid it (or I have not seen one at the very least), here's a simple `clone` method that should work on any `Set` Pull-Request: #1893 Reviewed-by: Jean Privat <jean@pryen.org> Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
2 parents 67c1af0 + b5fce21 commit 5fad463

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

lib/core/collection/abstract_collection.nit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ end
409409
# assert s.has(b) == true
410410
interface Set[E]
411411
super SimpleCollection[E]
412+
super Cloneable
412413

413414
redef fun has_only(item)
414415
do
@@ -471,6 +472,8 @@ interface Set[E]
471472
return nhs
472473
end
473474

475+
redef fun clone do return union(self)
476+
474477
# Returns a new instance of `Set`.
475478
#
476479
# Depends on the subclass, mainly used for copy services

lib/core/collection/array.nit

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ end
592592
# A set implemented with an Array.
593593
class ArraySet[E]
594594
super Set[E]
595-
super Cloneable
596595

597596
# The stored elements.
598597
private var array: Array[E] is noinit

tests/sav/test_new_native_alt1.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Runtime error: Cast failed. Expected `E`, got `Bool` (../lib/core/collection/array.nit:989)
1+
Runtime error: Cast failed. Expected `E`, got `Bool` (../lib/core/collection/array.nit:988)
22
NativeString
33
0x4e
44
Nit

0 commit comments

Comments
 (0)