Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

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

@nicoonoclaste

Description

@nicoonoclaste

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]
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions