Interface TypeInferenceRuleWithInferringChildren

Inference rule which requires for the type inference of the given parent to take the types of its children into account. Therefore, the types of the children need to be inferred first.

interface TypeInferenceRuleWithInferringChildren {
    inferTypeWithChildrensTypes(
        languageNode: unknown,
        childrenTypes: (undefined | Type)[],
        typir: TypirServices,
    ): Type | InferenceProblem;
    inferTypeWithoutChildren(
        languageNode: unknown,
        typir: TypirServices,
    ): unknown;
}

Implemented by

Methods

  • 2nd step is to finally decide about the inferred type. When the 1st step returned a list of language nodes to resolve their types, this function is called in order to complete this inference rule, otherwise, this step is not called. Advantage of this step is to split it to allow a postponed inferrence of the additional language nodes by Typir. Disadvantage of this step is, that already checked TS types of languageNode cannot be reused.

    Parameters

    • languageNode: unknown

      the language node whose type shall be inferred

    • childrenTypes: (undefined | Type)[]

      the types which are inferred from the language nodes of the 1st step (in the same order!)

    • typir: TypirServices

      the current Typir instance

    Returns Type | InferenceProblem

    the finally inferred type or a problem, why this inference rule is finally not applicable

  • 1st step is to check, whether this inference rule is applicable to the given language node.

    Parameters

    • languageNode: unknown

      the language node whose type shall be inferred

    • typir: TypirServices

      the current Typir instance

    Returns unknown

    Only in the case, that child language nodes are returned, the other function will be called for step 2, otherwise, it is skipped.