Packages

c

com.avsystem.commons.annotation

explicitGenerics

class explicitGenerics extends Annotation with StaticAnnotation

When applied on generic method, requires that all the type parameters are given explicitly (cannot be inferred by the compiler). This is meant primarily for methods whose generics cannot be inferred from method arguments. Requiring that the programmer specifies them explicitly is a protection against the compiler inferring Nothing or Null.

@explicitGenerics
def readJson[T: GenCodec](json: String): T = ...

// raise error, because otherwise we have a hidden bug - the compiler infers `Nothing` in place of `T`
val x: MyType = readJson("{}")
// ok
val x = readJson[MyType]("{}")
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. explicitGenerics
  2. StaticAnnotation
  3. Annotation
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new explicitGenerics()