
com.avsystem.commons.annotation.explicitGenerics.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-core_2.12 Show documentation
Show all versions of commons-core_2.12 Show documentation
AVSystem commons library for Scala
The newest version!
package com.avsystem.commons
package annotation
/**
* 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]("{}")
* }}}
*/
class explicitGenerics extends StaticAnnotation
© 2015 - 2025 Weber Informatics LLC | Privacy Policy