Made VirtualFile subtype of Hashable.

This commit is contained in:
Evgeny Gerashchenko
2012-04-08 16:51:46 +04:00
parent 1931d82416
commit dfd3f50c52
+4 -4
View File
@@ -12,7 +12,7 @@ import kotlin.util.*
/** /**
* Abstract virtual file. * Abstract virtual file.
*/ */
public abstract class VirtualFile(public val path : String) { public abstract class VirtualFile(public val path : String) : Hashable {
protected abstract val kind : String protected abstract val kind : String
/** /**
@@ -43,12 +43,12 @@ public abstract class VirtualFile(public val path : String) {
*/ */
public abstract fun openInputStream() : InputStream public abstract fun openInputStream() : InputStream
fun equals(other : Any?) : Boolean { public override fun equals(other : Any?) : Boolean {
return other is VirtualFile && kind == other.kind && path == other.path return other is VirtualFile && kind == other.kind && path == other.path
} }
fun hashCode() : Int { public override fun hashCode() : Int {
// FIXME rewrite without casting when it will be possible // FIXME rewrite without casting when it will be possible (KT-1741)
return (kind as java.lang.String).hashCode() * 31 + (path as java.lang.String).hashCode() return (kind as java.lang.String).hashCode() * 31 + (path as java.lang.String).hashCode()
} }