Skip to content

Commit bd17cb3

Browse files
committed
scaladoc for TypeString
1 parent 9e29564 commit bd17cb3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

commons-core/src/main/scala/com/avsystem/commons/misc/TypeString.scala

+15
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ import com.avsystem.commons.serialization.{GenCodec, GenKeyCodec, transparent}
66
/**
77
* Typeclass that contains string representation of a concrete type. This representation should correctly parse
88
* and typecheck when used as a type in Scala source code.
9+
*
10+
* Instances of `TypeString` are implicitly macro-materialized. The macro will fail if the type contains
11+
* references to local symbols, i.e. symbols that only exist in limited scope and cannot be referred to from
12+
* any place in source code. This includes type parameters, this-references to enclosing classes, etc.
13+
*
14+
* For example, the code below will NOT compile:
15+
* {{{
16+
* def listTypeRepr[T]: String = TypeString.of[List[T]]
17+
* }}}
18+
* because `T` is a local symbol that only has meaning inside its own method. However, if you provide external
19+
* `TypeString` instance for `T`, the macro will pick it up and no longer complain:
20+
* {{{
21+
* def listTypeRepr[T: TypeString]: String = TypeString.of[List[T]]
22+
* }}}
23+
* Then, `listTypeRepr[Int]` will produce a string `"List[Int]"`
924
*/
1025
@transparent
1126
case class TypeString[T](value: String) extends AnyVal

0 commit comments

Comments
 (0)