org.jetbrains.jet.lang.resolve.calls.inference
Interface ConstraintSystem

All Known Implementing Classes:
ConstraintSystemImpl

public interface ConstraintSystem


Method Summary
 void addSubtypeConstraint(JetType constrainingType, JetType subjectType, ConstraintPosition constraintPosition)
          Adds a constraint that the constraining type is a subtype of the subject type.

Asserts that only subject type may contain registered type variables.

 void addSupertypeConstraint(JetType constrainingType, JetType subjectType, ConstraintPosition constraintPosition)
          Adds a constraint that the constraining type is a supertype of the subject type.
 ConstraintSystem copy()
           
 TypeSubstitutor getCurrentSubstitutor()
          Returns a current result of solving the constraint system (mapping from the type variable to the resulting type projection).
 TypeSubstitutor getResultingSubstitutor()
          Returns a result of solving the constraint system (mapping from the type variable to the resulting type projection).
 ConstraintSystemStatus getStatus()
           
 TypeBounds getTypeBounds(TypeParameterDescriptor typeVariable)
          Returns the resulting type constraints of solving the constraint system for specific type variable.
 java.util.Set<TypeParameterDescriptor> getTypeVariables()
          Returns a set of all registered type variables.
 void registerTypeVariables(java.util.Map<TypeParameterDescriptor,Variance> typeVariables)
          Registers variables in a constraint system.
 

Method Detail

registerTypeVariables

void registerTypeVariables(@NotNull
                           java.util.Map<TypeParameterDescriptor,Variance> typeVariables)
Registers variables in a constraint system.


getTypeVariables

@NotNull
java.util.Set<TypeParameterDescriptor> getTypeVariables()
Returns a set of all registered type variables.


addSubtypeConstraint

void addSubtypeConstraint(@Nullable
                          JetType constrainingType,
                          @NotNull
                          JetType subjectType,
                          @NotNull
                          ConstraintPosition constraintPosition)
Adds a constraint that the constraining type is a subtype of the subject type.

Asserts that only subject type may contain registered type variables.

For example, for "fun <T> id(t: T) {}" to infer T in invocation "id(1)" should be generated a constraint "Int is a subtype of T" where T is a subject type, and Int is a constraining type.


addSupertypeConstraint

void addSupertypeConstraint(@Nullable
                            JetType constrainingType,
                            @NotNull
                            JetType subjectType,
                            @NotNull
                            ConstraintPosition constraintPosition)
Adds a constraint that the constraining type is a supertype of the subject type.

Asserts that only subject type may contain registered type variables.

For example, for "fun <T> create() : T" to infer T in invocation "val i: Int = create()" should be generated a constraint "Int is a supertype of T" where T is a subject type, and Int is a constraining type.


getStatus

@NotNull
ConstraintSystemStatus getStatus()

getTypeBounds

@NotNull
TypeBounds getTypeBounds(@NotNull
                                 TypeParameterDescriptor typeVariable)
Returns the resulting type constraints of solving the constraint system for specific type variable.

Returns null if the type variable was not registered.


getResultingSubstitutor

@NotNull
TypeSubstitutor getResultingSubstitutor()
Returns a result of solving the constraint system (mapping from the type variable to the resulting type projection).

In the resulting substitution should be concerned:

- type constraints

- variance of the type variable // not implemented yet

- type parameter bounds (that can bind type variables with each other). // not implemented yet If the addition of the 'expected type' constraint made the system fail, this constraint is not included in the resulting substitution.


getCurrentSubstitutor

@NotNull
TypeSubstitutor getCurrentSubstitutor()
Returns a current result of solving the constraint system (mapping from the type variable to the resulting type projection). If there is no information for type parameter, returns type projection for DONT_CARE type.


copy

ConstraintSystem copy()