Class CompositeTypeInferenceRule

This inference rule uses multiple internal inference rules for doing the type inference. If one of the child rules returns a type, this type is the result of the composite rule. Otherwise, all problems of all child rules are returned.

Hierarchy (View Summary)

Implements

Constructors

Properties

inferenceRules: Map<string, TypeInferenceRule[]> = ...
languageNodeInference: LanguageNodeInferenceCaching
services: TypirServices

Methods

  • Registers an inference rule. When inferring the type for a language node, all registered inference rules are checked until the first match.

    Parameters

    • rule: TypeInferenceRule

      a new inference rule

    • OptionalboundToType: Type

      an optional type, if the new inference rule is dedicated for exactly this type. If the given type is removed from the type system, this rule will be automatically removed as well.

    Returns void

  • 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

    Returns Type | InferenceProblem

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