Implicits

object Implicits

Implicit resolution

Companion
class
class Object
trait Matchable
class Any

Type members

Classlikes

class AmbiguousImplicits(val alt1: SearchSuccess, val alt2: SearchSuccess, val expectedType: Type, val argument: Tree) extends SearchFailureType

An ambiguous implicits failure

An ambiguous implicits failure

case class Candidate(implicitRef: ImplicitRef, kind: Kind, level: Int) extends RefAndLevel

An eligible implicit candidate, consisting of an implicit reference and a nesting level

An eligible implicit candidate, consisting of an implicit reference and a nesting level

Companion
object
object Candidate
Companion
class
class ContextualImplicits(val refs: List[ImplicitRef], val outerImplicits: ContextualImplicits, isImport: Boolean)(initctx: Context) extends ImplicitRefs

The implicit references coming from the context.

The implicit references coming from the context.

Value Params
outerCtx

the next outer context that makes visible further implicits

refs

the implicit references made visible by the current context. Note: The name of the reference might be different from the name of its symbol. In the case of a renaming import a => b, the name of the reference is the renamed name, b, whereas the name of the symbol is the original name, a.

class DivergingImplicit(ref: TermRef, val expectedType: Type, val argument: Tree) extends SearchFailureType
class FailedExtension(extApp: Tree, val expectedType: Type, val whyFailed: Message) extends SearchFailureType

A search failure type for attempted ill-typed extension method calls

A search failure type for attempted ill-typed extension method calls

abstract class ImplicitRefs(initctx: Context)

A common base class of contextual implicits and of-type implicits which represents a set of references to implicit definitions.

A common base class of contextual implicits and of-type implicits which represents a set of references to implicit definitions.

class MismatchedImplicit(ref: TermRef, val expectedType: Type, val argument: Tree) extends SearchFailureType
class NestedFailure(_msg: Message, val expectedType: Type) extends SearchFailureType

A search failure type for aborted searches of extension methods, typically because of a cyclic reference or similar.

A search failure type for aborted searches of extension methods, typically because of a cyclic reference or similar.

class NoMatchingImplicits(val expectedType: Type, val argument: Tree, constraint: Constraint) extends SearchFailureType
Companion
object
class OfTypeImplicits(tp: Type, val companionRefs: TermRefSet)(initctx: Context) extends ImplicitRefs

The implicit references coming from the implicit scope of a type.

The implicit references coming from the implicit scope of a type.

Value Params
companionRefs

the companion objects in the implicit scope.

tp

the type determining the implicit scope

sealed trait RefAndLevel

Both search candidates and successes are references with a specific nesting level.

Both search candidates and successes are references with a specific nesting level.

class RenamedImplicitRef(val underlyingRef: TermRef, val alias: TermName) extends ImplicitRef

An implicit definition implicitRef that is visible under a different name, alias. Gets generated if an implicit ref is imported via a renaming import.

An implicit definition implicitRef that is visible under a different name, alias. Gets generated if an implicit ref is imported via a renaming import.

case class SearchFailure(tree: Tree) extends SearchResult

A failed search

A failed search

Companion
object
Companion
class
abstract class SearchFailureType extends ErrorType
sealed abstract class SearchResult extends Showable

The result of an implicit search

The result of an implicit search

case class SearchSuccess(tree: Tree, ref: TermRef, level: Int, isExtension: Boolean)(tstate: TyperState, gstate: GadtConstraint) extends SearchResult with RefAndLevel with Showable

A successful search

A successful search

Value Params
isExtension

Whether the result is an extension method application

level

The level where the reference was found

ref

The implicit reference that succeeded

tree

The typed tree that needs to be inserted

tstate

The typer state to be committed if this alternative is chosen

Value members

Concrete methods

def hasExtMethod(tp: Type, expected: Type)(using Context): Boolean

If expected is a selection prototype, does tp have an extension method with the selecting name? False otherwise.

If expected is a selection prototype, does tp have an extension method with the selecting name? False otherwise.