Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions lib/steep/diagnostic/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -503,22 +503,6 @@ def header_line
end
end

class IncompatibleMethodTypeAnnotation < Base
attr_reader :interface_method
attr_reader :annotation_method
attr_reader :result

include ResultPrinter

def initialize(node:, interface_method:, annotation_method:, result:)
raise
super(node: node)
@interface_method = interface_method
@annotation_method = annotation_method
@result = result
end
end

class MethodReturnTypeAnnotationMismatch < Base
attr_reader :method_type
attr_reader :annotation_type
Expand Down Expand Up @@ -742,25 +726,6 @@ def header_line
end
end

class IncompatibleTypeCase < Base
attr_reader :var_name
attr_reader :result
attr_reader :relation

def initialize(node:, var_name:, result:, relation:)
super(node: node)
@var_name = var_name
@result = result
@relation = relation
end

include ResultPrinter

def header_line
"Type annotation for branch about `#{var_name}` is incompatible since #{relation} doesn't hold"
end
end

class UnreachableBranch < Base
def header_line
"The branch is unreachable"
Expand All @@ -780,19 +745,6 @@ def header_line
end
end

class UnexpectedSplat < Base
attr_reader :type

def initialize(node:, type:)
super(node: node)
@type = type
end

def header_line
"Hash splat is given with object other than `Hash[X, Y]`"
end
end

class ProcTypeExpected < Base
attr_reader :type

Expand Down Expand Up @@ -1036,8 +988,6 @@ def self.default
IncompatibleAnnotation => :hint,
IncompatibleArgumentForwarding => :warning,
IncompatibleAssignment => :hint,
IncompatibleMethodTypeAnnotation => :hint,
IncompatibleTypeCase => :hint,
InsufficientKeywordArguments => :error,
InsufficientPositionalArguments => :error,
InsufficientTypeArgument => :hint,
Expand Down Expand Up @@ -1065,7 +1015,6 @@ def self.default
UnexpectedJumpValue => :hint,
UnexpectedKeywordArgument => :error,
UnexpectedPositionalArgument => :error,
UnexpectedSplat => :hint,
UnexpectedSuper => :information,
UnexpectedTypeArgument => :hint,
UnexpectedYield => :warning,
Expand Down Expand Up @@ -1095,8 +1044,6 @@ def self.strict
IncompatibleAnnotation => :error,
IncompatibleArgumentForwarding => :error,
IncompatibleAssignment => :error,
IncompatibleMethodTypeAnnotation => :error,
IncompatibleTypeCase => :error,
InsufficientKeywordArguments => :error,
InsufficientPositionalArguments => :error,
InsufficientTypeArgument => :error,
Expand Down Expand Up @@ -1124,7 +1071,6 @@ def self.strict
UnexpectedJumpValue => :error,
UnexpectedKeywordArgument => :error,
UnexpectedPositionalArgument => :error,
UnexpectedSplat => :warning,
UnexpectedSuper => :error,
UnexpectedTypeArgument => :error,
UnexpectedYield => :error,
Expand Down Expand Up @@ -1154,8 +1100,6 @@ def self.lenient
IncompatibleAnnotation => nil,
IncompatibleArgumentForwarding => :information,
IncompatibleAssignment => :hint,
IncompatibleMethodTypeAnnotation => nil,
IncompatibleTypeCase => nil,
InsufficientKeywordArguments => :information,
InsufficientPositionalArguments => :information,
InsufficientTypeArgument => nil,
Expand Down Expand Up @@ -1183,7 +1127,6 @@ def self.lenient
UnexpectedJumpValue => nil,
UnexpectedKeywordArgument => :information,
UnexpectedPositionalArgument => :information,
UnexpectedSplat => nil,
UnexpectedSuper => nil,
UnexpectedTypeArgument => nil,
UnexpectedYield => :information,
Expand Down
34 changes: 0 additions & 34 deletions sig/steep/diagnostic/ruby.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -289,18 +289,6 @@ module Steep
def header_line: () -> ::String
end

class IncompatibleMethodTypeAnnotation < Base
attr_reader interface_method: untyped

attr_reader annotation_method: untyped

attr_reader result: untyped

include ResultPrinter

def initialize: (node: untyped, interface_method: untyped, annotation_method: untyped, result: untyped) -> void
end

class MethodReturnTypeAnnotationMismatch < Base
attr_reader method_type: untyped

Expand Down Expand Up @@ -461,20 +449,6 @@ module Steep
def header_line: () -> ::String
end

class IncompatibleTypeCase < Base
attr_reader var_name: untyped

attr_reader result: untyped

attr_reader relation: untyped

def initialize: (node: untyped, var_name: untyped, result: untyped, relation: untyped) -> void

include ResultPrinter

def header_line: () -> ::String
end

class UnreachableBranch < Base
def header_line: () -> String
end
Expand Down Expand Up @@ -504,14 +478,6 @@ module Steep
def header_line: () -> String
end

class UnexpectedSplat < Base
attr_reader type: untyped

def initialize: (node: untyped, type: untyped) -> void

def header_line: () -> "Hash splat is given with object other than `Hash[X, Y]`"
end

class ProcTypeExpected < Base
attr_reader type: untyped

Expand Down
1 change: 0 additions & 1 deletion smoke/diagnostics/unexpected_splat.rb

This file was deleted.

35 changes: 0 additions & 35 deletions test/type_construction_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1331,41 +1331,6 @@ def foo(x)
end
end

def test_new_method_with_incompatible_annotation
with_checker <<-EOF do |checker|
class A
def foo: (String) -> Integer
end
EOF

source = parse_ruby(<<-RUBY)
class A
# @type method foo: (String) -> String
def foo(x)
nil
end
end
RUBY

with_standard_construction(checker, source) do |construction, typing|
def_node = source.node.children[2]
type_name = parse_type("::A").name
instance_definition = checker.factory.definition_builder.build_instance(type_name)

construction.for_new_method(:foo,
def_node,
args: def_node.children[1].children,
self_type: parse_type("::A"),
definition: instance_definition)

skip "Skip testing if method type annotation is compatible with interface"

assert_equal 1, typing.errors.size
assert_instance_of Diagnostic::Ruby::IncompatibleMethodTypeAnnotation, typing.errors.first
end
end
end

def test_relative_type_name
with_checker <<-EOF do |checker|
class A::String
Expand Down