All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemStatus.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0-RC
Show newest version
/*
 * Copyright 2010-2015 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jetbrains.kotlin.resolve.calls.inference

import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind

interface ConstraintSystemStatus {
    /**
     * Returns `true` if constraint system has a solution (has no contradiction and has enough information to infer each registered type variable).
     */
    fun isSuccessful(): Boolean

    /**
     * Return `true` if constraint system has no contradiction (it can be not successful because of the lack of information for a type variable).
     */
    fun hasContradiction(): Boolean

    /**
     * Returns `true` if type constraints for some type variable are contradicting.
     *
     * For example, for `fun  foo(r: R, t: java.util.List) {}` in invocation `foo(1, arrayList("s"))`
     * type variable `R` has two conflicting constraints:
     * - "R is a supertype of Int"
     * - "List is a supertype of List" which leads to "R is equal to String"
     */
    fun hasConflictingConstraints(): Boolean

    /**
     * Returns `true` if contradiction of type constraints comes from declared bounds for type parameters.
     *
     * For example, for `fun  foo(r: R) {}` in invocation `foo(null)`
     * upper bounds `Any` for type parameter `R` is violated.
     *
     * It's the special case of 'hasConflictingConstraints' case.
     */
    fun hasViolatedUpperBound(): Boolean

    /**
     * Returns `true` if there is no information for some registered type variable.
     *
     * For example, for `fun  newList()` in invocation `val nl = newList()`
     * there is no information to infer type variable `E`.
     */
    fun hasUnknownParameters(): Boolean

    /**
     * Returns `true` if some constraint cannot be processed because of type constructor mismatch.
     *
     * For example, for `fun  foo(t: List) {}` in invocation `foo(hashSetOf("s"))`
     * there is type constructor mismatch: "HashSet cannot be a subtype of List".
     */
    fun hasParameterConstraintError(): Boolean

    /**
     * Returns `true` if there is type constructor mismatch only in constraintPosition or
     * constraint system is successful without constraints from this position.
     */
    fun hasOnlyErrorsDerivedFrom(kind: ConstraintPositionKind): Boolean

    /**
     * Returns `true` if there is an error in constraining types.
     * Is used not to generate type inference error if there was one in argument types.
     */
    fun hasErrorInConstrainingTypes(): Boolean

    /**
     * Returns `true` if a user type contains the type projection that cannot be captured.
     *
     * For example, for `fun  foo(t: Array>) {}`
     * in invocation `foo(array)` where `array` has type `Array>`.
     */
    fun hasCannotCaptureTypesError(): Boolean

    /**
     * Returns `true` if there's an error in constraint system incorporation.
     */
    fun hasTypeInferenceIncorporationError(): Boolean

    fun hasTypeParameterWithUnsatisfiedOnlyInputTypesError(): Boolean

    val constraintErrors: List
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy