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
- Alphabetic
- By Inheritance
- ModelFactoryImplicitSupport
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- Protected
Type Members
- class ImplicitConversionImpl extends ImplicitConversion
- 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
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- 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
- 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()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val DEBUG: Boolean
- val ERROR: Boolean
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def debug(msg: => String): Unit
- Annotations
- @inline()
- 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
- 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
- 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
- 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
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def error(msg: => String): Unit
- Annotations
- @inline()
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- 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()
- final def getClass(): java.lang.Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def implicitShouldDocument(aSym: Global.Symbol): Boolean
implicitShouldDocument decides whether a member inherited by implicit conversion should be documented
- def isDistinguishableFrom(t1: Global.Type, t2: Global.Type): Boolean
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def makeBoundedConstraints(tparams: List[Global.Symbol], constrs: List[Global.TypeConstraint], inTpl: (ModelFactoryImplicitSupport.this)#DocTemplateImpl): List[Constraint]
- def makeImplicitConstraints(types: List[Global.Type], sym: Global.Symbol, context: (analyzer)#Context, inTpl: (ModelFactoryImplicitSupport.this)#DocTemplateImpl): List[Constraint]
- 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
- 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.
- 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 :)
- def makeSubstitutionConstraints(subst: Global.TreeTypeSubstituter, inTpl: (ModelFactoryImplicitSupport.this)#DocTemplateImpl): List[Constraint]
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- 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]
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- 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
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- 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
- object wildcardToNothing extends Global.TypeMap
wildcardToNothing transforms wildcard types back to Nothing
Deprecated Value Members
- 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.
The Scala compiler and reflection APIs.