tox4j / deprecated-tox4j

Deprecated, see http://github.com/TokTok/jvm-toxcore-c
http://github.com/TokTok/jvm-toxcore-c
Other
42 stars 17 forks source link

Linter: Relax `org.scalastyle.scalariform.StructuralTypeChecker` #136

Open nbraud opened 9 years ago

nbraud commented 9 years ago

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]
}
iphydf commented 9 years ago

If the "reflective calls" warning can be turned into an error, we can avoid modifying this linter.

nbraud commented 9 years ago

I thought about it, and it doesn't seem easily doable :-/