org.scalastyle.scalariform.StructuralTypeChecker is employed to enforce no structural types are used.
The rationale for this is that accessing structurally-defined members is much slower than regular member access (it is implemented using runtime reflexion).
Some things, however, require use of structural types (but no structurally-defined members) to properly model in the type system. We should use a more lenient linter which allows those uses of structural types.
Here is an example:
trait FileLike {
type Slice
def slice(offset: Long, size: Int): Option[Slice]
def write(slice: slice)(data: Seq[Byte])
}
abstract class DataStore[FileSlice <: FileLike#Slice] (val slice: Slice) {
type Key
type File = FileLike { type Slice = FileSlice } // Here comes the structural type
def add(file: File)(data: Seq[Byte]): Option[Key]
def delete(file: FIle)(key: Key): Option[Unit]
}
org.scalastyle.scalariform.StructuralTypeChecker
is employed to enforce no structural types are used.The rationale for this is that accessing structurally-defined members is much slower than regular member access (it is implemented using runtime reflexion). Some things, however, require use of structural types (but no structurally-defined members) to properly model in the type system. We should use a more lenient linter which allows those uses of structural types.
Here is an example: