Skip to content

Commit

Permalink
Merge: Make all Sets cloneable
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
privat committed Dec 15, 2015
2 parents 67c1af0 + b5fce21 commit 5fad463
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/core/collection/abstract_collection.nit
Expand Up @@ -409,6 +409,7 @@ end
# assert s.has(b) == true
interface Set[E]
super SimpleCollection[E]
super Cloneable

redef fun has_only(item)
do
Expand Down Expand Up @@ -471,6 +472,8 @@ interface Set[E]
return nhs
end

redef fun clone do return union(self)

# Returns a new instance of `Set`.
#
# Depends on the subclass, mainly used for copy services
Expand Down
1 change: 0 additions & 1 deletion lib/core/collection/array.nit
Expand Up @@ -592,7 +592,6 @@ end
# A set implemented with an Array.
class ArraySet[E]
super Set[E]
super Cloneable

# The stored elements.
private var array: Array[E] is noinit
Expand Down
2 changes: 1 addition & 1 deletion tests/sav/test_new_native_alt1.res
@@ -1,4 +1,4 @@
Runtime error: Cast failed. Expected `E`, got `Bool` (../lib/core/collection/array.nit:989)
Runtime error: Cast failed. Expected `E`, got `Bool` (../lib/core/collection/array.nit:988)
NativeString
0x4e
Nit

0 comments on commit 5fad463

Please sign in to comment.