Sha256: 993dae09ddf3f8cc720225c2bc24aa6c502a2e233de266eeb28786cc96114aff

Contents?: true

Size: 1.8 KB

Versions: 5

Compression:

Stored size: 1.8 KB

Contents

module RBS
  class Validator
    attr_reader env: Environment

    attr_reader resolver: TypeNameResolver

    attr_reader definition_builder: DefinitionBuilder

    attr_reader type_alias_dependency: TypeAliasDependency

    attr_reader type_alias_regularity: TypeAliasRegularity

    def initialize: (env: Environment, resolver: TypeNameResolver) -> void

    # Validates the presence of type names and type application arity match.
    #
    def validate_type: (Types::t, context: TypeNameResolver::context) -> void

    # Validates type alias definition:
    #
    # - There is no circular definition between aliases
    # - The type alias is _regular_
    # - The generics type parameter variance annotation is consistent with respect to their usage
    # - There is no circular dependencies between the generics type parameter bounds
    #
    def validate_type_alias: (entry: Environment::SingleEntry[TypeName, AST::Declarations::Alias]) -> void

    # Validates the type parameters in generic methods.
    #
    def validate_method_definition: (AST::Members::MethodDefinition, type_name: TypeName) -> void

    # Validates the type parameters if there is no circular dependencies between the bounds.
    #
    # ```rbs
    # [X, Y]                      # OK
    # [X, Y < _Foo[X]]            # OK
    # [X < _Foo[Y], Y]            # OK
    # [X < _Foo[Y], Y < _Foo[X]]  # Error
    # ```
    #
    def validate_type_params: (Array[AST::TypeParam] params, type_name: TypeName, ?method_name: Symbol?, location: Location[untyped, untyped]?) -> void

    private

    # Resolves relative type names to absolute type names in given context.
    # Yields the type when the type name resolution using `#resolver` fails.
    #
    def absolute_type: (Types::t, context: TypeNameResolver::context) { (Types::t) -> TypeName } -> Types::t
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rbs-2.2.0 sig/validator.rbs
rbs-2.1.0 sig/validator.rbs
rbs-2.0.0 sig/validator.rbs
rbs-2.0.0.pre2 sig/validator.rbs
rbs-2.0.0.pre1 sig/validator.rbs