t

scala.tools.nsc.doc.model

ModelFactoryImplicitSupport

trait ModelFactoryImplicitSupport extends AnyRef

This trait finds implicit conversions for a class in the default scope and creates scaladoc entries for each of them.

Let's take this as an example:

object Test {
  class A

  class B {
    def foo = 1
  }

  class C extends B {
    def bar = 2
    class implicit
  }

  D def conv(a: A) = new C
}

Overview: - scaladoc-ing the above classes, A will get two more methods: foo and bar, over its default methods - the nested classes (specifically D above), abstract types, type aliases and constructor members are not added to A (see makeMember0 in ModelFactory, last 3 cases) - the members added by implicit conversion are always listed under the implicit conversion, not under the class they actually come from (foo will be listed as coming from the implicit conversion to C instead of B) - see definitionName in MemberImpl

Internals: TODO: Give an overview here

Self Type
ModelFactoryImplicitSupport with ModelFactory with ModelFactoryTypeSupport with CommentFactory with TreeFactory
Source
ModelFactoryImplicitSupport.scala
Linear Supertypes
AnyRef, Any
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ModelFactoryImplicitSupport
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. class ImplicitConversionImpl extends ImplicitConversion
  2. class ImplicitNotFound extends Exception

    This is a flag that indicates whether to eliminate implicits that cannot be satisfied within the current scope.

    This is a flag that indicates whether to eliminate implicits that cannot be satisfied within the current scope. For example, if an implicit conversion requires that there is a Numeric[T] in scope:

    class A[T]
    class B extends A[Int]
    class C extends A[String]
    implicit def enrichA[T: Numeric](a: A[T]): D

    For B, no constraints are generated as Numeric[Int] is already in the default scope. On the other hand, for the conversion from C to D, depending on -implicits-show-all, the conversion can:

    • not be generated at all, since there's no Numeric[String] in scope (if ran without -implicits-show-all)
    • generated with a *weird* constraint, Numeric[String] as the user might add it by hand (if flag is enabled)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from ModelFactoryImplicitSupport toany2stringadd[ModelFactoryImplicitSupport] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (ModelFactoryImplicitSupport, B)
    Implicit
    This member is added by an implicit conversion from ModelFactoryImplicitSupport toArrowAssoc[ModelFactoryImplicitSupport] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. val DEBUG: Boolean
  7. val ERROR: Boolean
  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  10. final def debug(msg: => String): Unit
    Annotations
    @inline()
  11. def ensuring(cond: (ModelFactoryImplicitSupport) => Boolean, msg: => Any): ModelFactoryImplicitSupport
    Implicit
    This member is added by an implicit conversion from ModelFactoryImplicitSupport toEnsuring[ModelFactoryImplicitSupport] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. def ensuring(cond: (ModelFactoryImplicitSupport) => Boolean): ModelFactoryImplicitSupport
    Implicit
    This member is added by an implicit conversion from ModelFactoryImplicitSupport toEnsuring[ModelFactoryImplicitSupport] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. def ensuring(cond: Boolean, msg: => Any): ModelFactoryImplicitSupport
    Implicit
    This member is added by an implicit conversion from ModelFactoryImplicitSupport toEnsuring[ModelFactoryImplicitSupport] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: Boolean): ModelFactoryImplicitSupport
    Implicit
    This member is added by an implicit conversion from ModelFactoryImplicitSupport toEnsuring[ModelFactoryImplicitSupport] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  17. final def error(msg: => String): Unit
    Annotations
    @inline()
  18. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  19. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from ModelFactoryImplicitSupport toStringFormat[ModelFactoryImplicitSupport] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  20. final def getClass(): java.lang.Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  21. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  22. def implicitShouldDocument(aSym: Global.Symbol): Boolean

    implicitShouldDocument decides whether a member inherited by implicit conversion should be documented

  23. def isDistinguishableFrom(t1: Global.Type, t2: Global.Type): Boolean
  24. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  25. def makeBoundedConstraints(tparams: List[Global.Symbol], constrs: List[Global.TypeConstraint], inTpl: (ModelFactoryImplicitSupport.this)#DocTemplateImpl): List[Constraint]
  26. def makeImplicitConstraints(types: List[Global.Type], sym: Global.Symbol, context: (analyzer)#Context, inTpl: (ModelFactoryImplicitSupport.this)#DocTemplateImpl): List[Constraint]
  27. def makeImplicitConversion(sym: Global.Symbol, result: (analyzer)#SearchResult, constrs: List[Global.TypeConstraint], context: (analyzer)#Context, inTpl: (ModelFactoryImplicitSupport.this)#DocTemplateImpl): List[(ModelFactoryImplicitSupport.this)#ImplicitConversionImpl]

    makeImplicitConversion performs the heavier lifting to get the implicit listing: - for each possible conversion function (also called view) * figures out the final result of the view (to what is our class transformed?) * figures out the necessary constraints on the type parameters (such as T <: Int) and the context (such as Numeric[T]) * lists all inherited members

    makeImplicitConversion performs the heavier lifting to get the implicit listing: - for each possible conversion function (also called view) * figures out the final result of the view (to what is our class transformed?) * figures out the necessary constraints on the type parameters (such as T <: Int) and the context (such as Numeric[T]) * lists all inherited members

    What? in details:

    • say we start from a class A[T1, T2, T3, T4]
    • we have an implicit function (view) in scope: def enrichA[T3 <: Long, T4](a: A[Int, Foo[Bar[X]], T3, T4])(implicit ev1: TypeTag[T4], ev2: Numeric[T4]): EnrichedA
    • A is converted to EnrichedA ONLY if a couple of constraints are satisfied: * T1 must be equal to Int * T2 must be equal to Foo[Bar[X]] * T3 must be upper bounded by Long * there must be evidence of Numeric[T4] and a TypeTag[T4] within scope
    • the final type is EnrichedA and A therefore inherits a couple of members from enrichA

    How? some notes:

    • Scala's type inference will want to solve all type parameters down to actual types, but we only want constraints to maintain generality
    • therefore, allViewsFrom wraps type parameters into "untouchable" type variables that only gather constraints, but are never solved down to a type
    • these must be reverted back to the type parameters and the constraints must be extracted and simplified (this is done by the uniteConstraints and boundedTParamsConstraints. Be sure to check them out
    • we also need to transform implicit parameters in the view's signature into constraints, such that Numeric[T4] appears as a constraint
  28. def makeImplicitConversions(sym: Global.Symbol, inTpl: (ModelFactoryImplicitSupport.this)#DocTemplateImpl): List[(ModelFactoryImplicitSupport.this)#ImplicitConversionImpl]

    Make the implicit conversion objects

    Make the implicit conversion objects

    A word about the scope of the implicit conversions: currently we look at a very basic context composed of the default Scala imports (Predef._ for example) and the companion object of the current class, if one exists. In the future we might want to extend this to more complex scopes.

  29. def makeShadowingTable(members: List[(ModelFactoryImplicitSupport.this)#MemberImpl], convs: List[(ModelFactoryImplicitSupport.this)#ImplicitConversionImpl], inTpl: (ModelFactoryImplicitSupport.this)#DocTemplateImpl): Map[MemberEntity, ImplicitMemberShadowing]

    Computes the shadowing table for all the members in the implicit conversions

    Computes the shadowing table for all the members in the implicit conversions

    members

    All template's members, including usecases and full signature members

    convs

    All the conversions the template takes part in

    inTpl

    the usual :)

  30. def makeSubstitutionConstraints(subst: Global.TreeTypeSubstituter, inTpl: (ModelFactoryImplicitSupport.this)#DocTemplateImpl): List[Constraint]
  31. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  32. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  33. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  34. def removeImplicitParameters(viewType: Global.Type): (Global.Type, List[Global.Type])

    removeImplicitParameters transforms implicit parameters from the view result type into constraints and returns the simplified type of the view

    removeImplicitParameters transforms implicit parameters from the view result type into constraints and returns the simplified type of the view

    for the example view: implicit def enrichMyClass[T](a: MyClass[T])(implicit ev: Numeric[T]): EnrichedMyClass[T] the implicit view result type is: (a: MyClass[T])(implicit ev: Numeric[T]): EnrichedMyClass[T] and the simplified type will be: MyClass[T] => EnrichedMyClass[T]

  35. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  36. def toString(): String
    Definition Classes
    AnyRef → Any
  37. def uniteConstraints(constr: Global.TypeConstraint): (List[Global.Type], List[Global.Type])

    uniteConstraints takes a TypeConstraint instance and simplifies the constraints inside

    uniteConstraints takes a TypeConstraint instance and simplifies the constraints inside

    Normally TypeConstraint contains multiple lower and upper bounds, and we want to reduce this to a lower and an upper bound. Here are a couple of catches we need to be aware of:

    • before finding a view (implicit method in scope that maps class A[T1,T2,.. Tn] to something else) the type parameters are transformed into "untouchable" type variables so that type inference does not attempt to fully solve them down to a type but rather constrains them on both sides just enough for the view to be applicable -- now, we want to transform those type variables back to the original type parameters
    • some of the bounds fail type inference and therefore refer to Nothing => when performing unification (lub, glb) they start looking ugly => we (unsoundly) transform Nothing to WildcardType so we fool the unification algorithms into thinking there's nothing there
    • we don't want the wildcard types surviving the unification so we replace them back to Nothings
  38. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  39. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  40. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  41. object typeVarToOriginOrWildcard extends Global.TypeMap

    typeVarsToOriginOrWildcard transforms the "untouchable" type variables into either their origins (the original type parameters) or into wildcard types if nothing matches

  42. object wildcardToNothing extends Global.TypeMap

    wildcardToNothing transforms wildcard types back to Nothing

Deprecated Value Members

  1. def [B](y: B): (ModelFactoryImplicitSupport, B)
    Implicit
    This member is added by an implicit conversion from ModelFactoryImplicitSupport toArrowAssoc[ModelFactoryImplicitSupport] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use -> instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd fromModelFactoryImplicitSupport to any2stringadd[ModelFactoryImplicitSupport]

Inherited by implicit conversion StringFormat fromModelFactoryImplicitSupport to StringFormat[ModelFactoryImplicitSupport]

Inherited by implicit conversion Ensuring fromModelFactoryImplicitSupport to Ensuring[ModelFactoryImplicitSupport]

Inherited by implicit conversion ArrowAssoc fromModelFactoryImplicitSupport to ArrowAssoc[ModelFactoryImplicitSupport]

Ungrouped