Class: Steep::Diagnostic::Signature::InvalidTypeApplication

Inherits:
Base
  • Object
show all
Defined in:
lib/steep/diagnostic/signature.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#location

Instance Method Summary collapse

Methods inherited from Base

#detail_lines, #diagnostic_code, #path

Methods included from Helper

#error_name, #full_message

Constructor Details

#initialize(name:, args:, params:, location:) ⇒ InvalidTypeApplication

Returns a new instance of InvalidTypeApplication.



85
86
87
88
89
90
# File 'lib/steep/diagnostic/signature.rb', line 85

def initialize(name:, args:, params:, location:)
  super(location: location)
  @name = name
  @args = args
  @params = params
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



82
83
84
# File 'lib/steep/diagnostic/signature.rb', line 82

def args
  @args
end

#nameObject (readonly)

Returns the value of attribute name.



81
82
83
# File 'lib/steep/diagnostic/signature.rb', line 81

def name
  @name
end

#paramsObject (readonly)

Returns the value of attribute params.



83
84
85
# File 'lib/steep/diagnostic/signature.rb', line 83

def params
  @params
end

Instance Method Details

#header_lineObject



92
93
94
95
96
97
98
99
100
101
# File 'lib/steep/diagnostic/signature.rb', line 92

def header_line
  case
  when params.empty?
    "Type `#{name}` is not generic but used as a generic type with #{args.size} arguments"
  when args.empty?
    "Type `#{name}` is generic but used as a non generic type"
  else
    "Type `#{name}` expects #{params.size} arguments, but #{args.size} arguments are given"
  end
end