From cb233c0d41c5253a88ad37cc7e8e0d5f6244f2fb Mon Sep 17 00:00:00 2001 From: euglena1215 Date: Mon, 30 Sep 2024 15:25:50 +0900 Subject: [PATCH 1/3] remove unused UnexpectedSplat rule --- lib/steep/diagnostic/ruby.rb | 16 ---------------- sig/steep/diagnostic/ruby.rbs | 8 -------- smoke/diagnostics/unexpected_splat.rb | 1 - 3 files changed, 25 deletions(-) delete mode 100644 smoke/diagnostics/unexpected_splat.rb diff --git a/lib/steep/diagnostic/ruby.rb b/lib/steep/diagnostic/ruby.rb index f8b528451..78af44351 100644 --- a/lib/steep/diagnostic/ruby.rb +++ b/lib/steep/diagnostic/ruby.rb @@ -780,19 +780,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 @@ -1065,7 +1052,6 @@ def self.default UnexpectedJumpValue => :hint, UnexpectedKeywordArgument => :error, UnexpectedPositionalArgument => :error, - UnexpectedSplat => :hint, UnexpectedSuper => :information, UnexpectedTypeArgument => :hint, UnexpectedYield => :warning, @@ -1124,7 +1110,6 @@ def self.strict UnexpectedJumpValue => :error, UnexpectedKeywordArgument => :error, UnexpectedPositionalArgument => :error, - UnexpectedSplat => :warning, UnexpectedSuper => :error, UnexpectedTypeArgument => :error, UnexpectedYield => :error, @@ -1183,7 +1168,6 @@ def self.lenient UnexpectedJumpValue => nil, UnexpectedKeywordArgument => :information, UnexpectedPositionalArgument => :information, - UnexpectedSplat => nil, UnexpectedSuper => nil, UnexpectedTypeArgument => nil, UnexpectedYield => :information, diff --git a/sig/steep/diagnostic/ruby.rbs b/sig/steep/diagnostic/ruby.rbs index 8206d7704..ba965a465 100644 --- a/sig/steep/diagnostic/ruby.rbs +++ b/sig/steep/diagnostic/ruby.rbs @@ -504,14 +504,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 diff --git a/smoke/diagnostics/unexpected_splat.rb b/smoke/diagnostics/unexpected_splat.rb deleted file mode 100644 index 498495e5d..000000000 --- a/smoke/diagnostics/unexpected_splat.rb +++ /dev/null @@ -1 +0,0 @@ -{ foo: :bar, **123 } From f34dae578bdaa2db6c753c40b43be985ece37265 Mon Sep 17 00:00:00 2001 From: euglena1215 Date: Mon, 30 Sep 2024 15:31:04 +0900 Subject: [PATCH 2/3] remove unused IncompatibleMethodTypeAnnotation rule --- lib/steep/diagnostic/ruby.rb | 19 ------------------ sig/steep/diagnostic/ruby.rbs | 12 ------------ test/type_construction_test.rb | 35 ---------------------------------- 3 files changed, 66 deletions(-) diff --git a/lib/steep/diagnostic/ruby.rb b/lib/steep/diagnostic/ruby.rb index 78af44351..4e449a64d 100644 --- a/lib/steep/diagnostic/ruby.rb +++ b/lib/steep/diagnostic/ruby.rb @@ -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 @@ -1023,7 +1007,6 @@ def self.default IncompatibleAnnotation => :hint, IncompatibleArgumentForwarding => :warning, IncompatibleAssignment => :hint, - IncompatibleMethodTypeAnnotation => :hint, IncompatibleTypeCase => :hint, InsufficientKeywordArguments => :error, InsufficientPositionalArguments => :error, @@ -1081,7 +1064,6 @@ def self.strict IncompatibleAnnotation => :error, IncompatibleArgumentForwarding => :error, IncompatibleAssignment => :error, - IncompatibleMethodTypeAnnotation => :error, IncompatibleTypeCase => :error, InsufficientKeywordArguments => :error, InsufficientPositionalArguments => :error, @@ -1139,7 +1121,6 @@ def self.lenient IncompatibleAnnotation => nil, IncompatibleArgumentForwarding => :information, IncompatibleAssignment => :hint, - IncompatibleMethodTypeAnnotation => nil, IncompatibleTypeCase => nil, InsufficientKeywordArguments => :information, InsufficientPositionalArguments => :information, diff --git a/sig/steep/diagnostic/ruby.rbs b/sig/steep/diagnostic/ruby.rbs index ba965a465..3fd184aaa 100644 --- a/sig/steep/diagnostic/ruby.rbs +++ b/sig/steep/diagnostic/ruby.rbs @@ -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 diff --git a/test/type_construction_test.rb b/test/type_construction_test.rb index 94f8bce3e..9f799e95c 100644 --- a/test/type_construction_test.rb +++ b/test/type_construction_test.rb @@ -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 From a589395d3c410544bbbc0da04a993b7728a19598 Mon Sep 17 00:00:00 2001 From: euglena1215 Date: Mon, 30 Sep 2024 15:35:25 +0900 Subject: [PATCH 3/3] remove unused IncompatibleTypeCase rule --- lib/steep/diagnostic/ruby.rb | 22 ---------------------- sig/steep/diagnostic/ruby.rbs | 14 -------------- 2 files changed, 36 deletions(-) diff --git a/lib/steep/diagnostic/ruby.rb b/lib/steep/diagnostic/ruby.rb index 4e449a64d..929caab73 100644 --- a/lib/steep/diagnostic/ruby.rb +++ b/lib/steep/diagnostic/ruby.rb @@ -726,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" @@ -1007,7 +988,6 @@ def self.default IncompatibleAnnotation => :hint, IncompatibleArgumentForwarding => :warning, IncompatibleAssignment => :hint, - IncompatibleTypeCase => :hint, InsufficientKeywordArguments => :error, InsufficientPositionalArguments => :error, InsufficientTypeArgument => :hint, @@ -1064,7 +1044,6 @@ def self.strict IncompatibleAnnotation => :error, IncompatibleArgumentForwarding => :error, IncompatibleAssignment => :error, - IncompatibleTypeCase => :error, InsufficientKeywordArguments => :error, InsufficientPositionalArguments => :error, InsufficientTypeArgument => :error, @@ -1121,7 +1100,6 @@ def self.lenient IncompatibleAnnotation => nil, IncompatibleArgumentForwarding => :information, IncompatibleAssignment => :hint, - IncompatibleTypeCase => nil, InsufficientKeywordArguments => :information, InsufficientPositionalArguments => :information, InsufficientTypeArgument => nil, diff --git a/sig/steep/diagnostic/ruby.rbs b/sig/steep/diagnostic/ruby.rbs index 3fd184aaa..7b46c9a2b 100644 --- a/sig/steep/diagnostic/ruby.rbs +++ b/sig/steep/diagnostic/ruby.rbs @@ -449,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