Sha256: 4fb60034142cc5d42f4a7689e30a1e090f50883e256fa9901a66d04563ec9174

Contents?: true

Size: 524 Bytes

Versions: 2

Compression:

Stored size: 524 Bytes

Contents

module TypeProf::Core
  class TypeAliasEntity
    def initialize
      @decls = Set[]
      @type = nil
    end

    attr_reader :decls, :type

    def exist?
      !@decls.empty?
    end

    def add_decl(decl)
      @decls << decl
      @type = decl.type unless @type
      # TODO: report an error if there are duplicated declarations
    end

    def remove_decl(decl)
      @decls.delete(decl) || raise
      if @type == decl.type
        @type = @decls.empty? ? nil : @decls.to_a.first.type
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
typeprof-0.30.1 lib/typeprof/core/env/type_alias_entity.rb
typeprof-0.30.0 lib/typeprof/core/env/type_alias_entity.rb