Open / data forbidden: ConstraintPosition fix

This commit is contained in:
Svetlana Isakova
2015-10-07 14:33:57 +03:00
parent 7331eec817
commit efb23be367
@@ -47,16 +47,19 @@ public interface ConstraintPosition {
fun isParameter(): Boolean = kind in setOf(VALUE_PARAMETER_POSITION, RECEIVER_POSITION) fun isParameter(): Boolean = kind in setOf(VALUE_PARAMETER_POSITION, RECEIVER_POSITION)
} }
private open data class ConstraintPositionImpl(override val kind: ConstraintPositionKind) : ConstraintPosition { private data class ConstraintPositionImpl(override val kind: ConstraintPositionKind) : ConstraintPosition {
override fun toString() = "$kind" override fun toString() = "$kind"
} }
private data class ConstraintPositionWithIndex(override val kind: ConstraintPositionKind, val index: Int) : ConstraintPosition { private data class ConstraintPositionWithIndex(override val kind: ConstraintPositionKind, val index: Int) : ConstraintPosition {
override fun toString() = "$kind($index)" override fun toString() = "$kind($index)"
} }
class CompoundConstraintPosition( class CompoundConstraintPosition(vararg positions: ConstraintPosition) : ConstraintPosition {
vararg positions: ConstraintPosition
) : ConstraintPositionImpl(ConstraintPositionKind.COMPOUND_CONSTRAINT_POSITION) { override val kind: ConstraintPositionKind
get() = COMPOUND_CONSTRAINT_POSITION
val positions: Collection<ConstraintPosition> = val positions: Collection<ConstraintPosition> =
positions.flatMap { if (it is CompoundConstraintPosition) it.positions else listOf(it) }.toSet() positions.flatMap { if (it is CompoundConstraintPosition) it.positions else listOf(it) }.toSet()