Compatibility

A trait defining an isCompatible method.

class Object
trait Matchable
class Any
class Typer
class ReTyper
class Typer
class Checker
object NoViewsAllowed.type

Value members

Abstract methods

def viewExists(tp: Type, pt: Type)(using Context): Boolean

Is there an implicit conversion from tp to pt?

Is there an implicit conversion from tp to pt?

Concrete methods

def constrainResult(mt: Type, pt: Type)(using Context): Boolean

Check that the result type of the current method fits the given expected result type.

Check that the result type of the current method fits the given expected result type.

def constrainResult(meth: Symbol, mt: Type, pt: Type)(using Context): Boolean

Constrain result with special case if meth is an inlineable method in an inlineable context. In that case, we should always succeed and not constrain type parameters in the expected type, because the actual return type can be a subtype of the currently known return type. However, we should constrain parameters of the declared return type. This distinction is achieved by replacing expected type parameters with wildcards.

Constrain result with special case if meth is an inlineable method in an inlineable context. In that case, we should always succeed and not constrain type parameters in the expected type, because the actual return type can be a subtype of the currently known return type. However, we should constrain parameters of the declared return type. This distinction is achieved by replacing expected type parameters with wildcards.

def isCompatible(tp: Type, pt: Type)(using Context): Boolean

A type tp is compatible with a type pt if one of the following holds:

A type tp is compatible with a type pt if one of the following holds:

  1. tp is a subtype of pt
  2. pt is by name parameter type, and tp is compatible with its underlying type
  3. there is an implicit conversion from tp to pt.
  4. tp is a numeric subtype of pt (this case applies even if implicit conversions are disabled) If pt is a by-name type, we compare against the underlying type instead.

Like normalize and then isCompatible, but using a subtype comparison with necessary eithers that does not unnecessarily truncate the constraint space, returning false instead.

Like normalize and then isCompatible, but using a subtype comparison with necessary eithers that does not unnecessarily truncate the constraint space, returning false instead.

def normalizedCompatible(tp: Type, pt: Type, keepConstraint: Boolean)(using Context): Boolean

Test compatibility after normalization. If keepConstraint is false, the current constraint set will not be modified by this call.

Test compatibility after normalization. If keepConstraint is false, the current constraint set will not be modified by this call.