diff --git a/src/compiler/crystal/codegen/codegen.cr b/src/compiler/crystal/codegen/codegen.cr index c40b58ab1040..df6afa474132 100644 --- a/src/compiler/crystal/codegen/codegen.cr +++ b/src/compiler/crystal/codegen/codegen.cr @@ -257,7 +257,6 @@ module Crystal emit_vars_debug_info(@program.vars) if @debug.variables? end - getter llvm_typer getter llvm_context def new_builder(llvm_context) diff --git a/src/compiler/crystal/semantic/abstract_def_checker.cr b/src/compiler/crystal/semantic/abstract_def_checker.cr index 46aa702d805e..418cf388c609 100644 --- a/src/compiler/crystal/semantic/abstract_def_checker.cr +++ b/src/compiler/crystal/semantic/abstract_def_checker.cr @@ -230,10 +230,7 @@ class Crystal::AbstractDefChecker end private def report_warning(node, message) - return unless @program.warnings.all? - return if @program.ignore_warning_due_to_location?(node.location) - - @program.warning_failures << node.warning(message) + @program.report_warning(node, message) end class ReplacePathWithTypeVar < Visitor diff --git a/src/compiler/crystal/semantic/warnings.cr b/src/compiler/crystal/semantic/warnings.cr new file mode 100644 index 000000000000..d74f6e495870 --- /dev/null +++ b/src/compiler/crystal/semantic/warnings.cr @@ -0,0 +1,10 @@ +module Crystal + class Program + def report_warning(node : ASTNode, message : String) + return unless self.warnings.all? + return if self.ignore_warning_due_to_location?(node.location) + + self.warning_failures << node.warning(message) + end + end +end diff --git a/src/compiler/crystal/syntax/ast.cr b/src/compiler/crystal/syntax/ast.cr index 7b5b8be6ea42..6baed31bd27d 100644 --- a/src/compiler/crystal/syntax/ast.cr +++ b/src/compiler/crystal/syntax/ast.cr @@ -539,7 +539,7 @@ module Crystal property block_arg : ASTNode? property named_args : Array(NamedArgument)? property name_location : Location? - property name_size = -1 + @name_size = -1 property doc : String? property visibility = Visibility::Public property? global : Bool @@ -575,6 +575,8 @@ module Crystal @name_size end + setter name_size + def accept_children(visitor) @obj.try &.accept visitor @args.each &.accept visitor diff --git a/src/compiler/crystal/tools/init.cr b/src/compiler/crystal/tools/init.cr index 7a191055ea5f..a559ea129089 100644 --- a/src/compiler/crystal/tools/init.cr +++ b/src/compiler/crystal/tools/init.cr @@ -206,7 +206,7 @@ module Crystal class InitProject getter config : Config - getter views : Array(View)? + @views : Array(View)? def initialize(@config : Config) end diff --git a/src/compiler/crystal/types.cr b/src/compiler/crystal/types.cr index b41522c73bd7..f74d42d9c1d1 100644 --- a/src/compiler/crystal/types.cr +++ b/src/compiler/crystal/types.cr @@ -1192,10 +1192,6 @@ module Crystal superclass.try &.add_subclass(self) end - def struct? - @struct - end - def has_attribute?(name) return true if packed? && name == "Packed" false @@ -2099,10 +2095,6 @@ module Crystal end end - def filter_by_responds_to(name) - including_types.try &.filter_by_responds_to(name) - end - def filter_by_responds_to(name) @generic_type.filter_by_responds_to(name) ? self : nil end diff --git a/src/compiler/crystal/util.cr b/src/compiler/crystal/util.cr index 9e5ef4a69bfa..10caed8bfbca 100644 --- a/src/compiler/crystal/util.cr +++ b/src/compiler/crystal/util.cr @@ -1,5 +1,7 @@ module Crystal - def self.relative_filename(filename : String) : String + def self.relative_filename(filename) + return filename unless filename.is_a?(String) + if base_file = filename.lchop? Dir.current if file_prefix = base_file.lchop? '/' return file_prefix @@ -9,10 +11,6 @@ module Crystal filename end - def self.relative_filename(filename) - filename - end - def self.error(msg, color, exit_code = 1, stderr = STDERR, leading_error = true) stderr.print "Error: ".colorize.toggle(color).red.bold if leading_error stderr.puts msg.colorize.toggle(color).bright diff --git a/src/io/byte_format.cr b/src/io/byte_format.cr index ff28be93f6e8..6f6b6a1082cd 100644 --- a/src/io/byte_format.cr +++ b/src/io/byte_format.cr @@ -43,8 +43,6 @@ module IO::ByteFormat abstract def encode(int : UInt64, io : IO) abstract def encode(int : Int128, io : IO) abstract def encode(int : UInt128, io : IO) - abstract def encode(int : Float32, io : IO) - abstract def encode(int : Float64, io : IO) abstract def encode(int : Int8, bytes : Bytes) abstract def encode(int : UInt8, bytes : Bytes) @@ -56,8 +54,6 @@ module IO::ByteFormat abstract def encode(int : UInt64, bytes : Bytes) abstract def encode(int : Int128, bytes : Bytes) abstract def encode(int : UInt128, bytes : Bytes) - abstract def encode(int : Float32, bytes : Bytes) - abstract def encode(int : Float64, bytes : Bytes) abstract def decode(int : Int8.class, io : IO) abstract def decode(int : UInt8.class, io : IO) @@ -69,8 +65,6 @@ module IO::ByteFormat abstract def decode(int : UInt64.class, io : IO) abstract def decode(int : Int128.class, io : IO) abstract def decode(int : UInt128.class, io : IO) - abstract def decode(int : Float32.class, io : IO) - abstract def decode(int : Float64.class, io : IO) abstract def decode(int : Int8.class, bytes : Bytes) abstract def decode(int : UInt8.class, bytes : Bytes) @@ -82,8 +76,6 @@ module IO::ByteFormat abstract def decode(int : UInt64.class, bytes : Bytes) abstract def decode(int : Int128.class, bytes : Bytes) abstract def decode(int : UInt128.class, bytes : Bytes) - abstract def decode(int : Float32.class, bytes : Bytes) - abstract def decode(int : Float64.class, bytes : Bytes) def encode(float : Float32, io : IO) encode(float.unsafe_as(Int32), io) diff --git a/src/llvm/builder.cr b/src/llvm/builder.cr index 4a1a99bc2dcf..7180212fbbff 100644 --- a/src/llvm/builder.cr +++ b/src/llvm/builder.cr @@ -127,7 +127,7 @@ class LLVM::Builder Value.new LibLLVM.build_extract_value(self, value, index, name) end - {% for name in %w(bit_cast si2fp ui2fp zext sext trunc fpext fptrunc fp2si fp2ui si2fp ui2fp int2ptr ptr2int) %} + {% for name in %w(bit_cast zext sext trunc fpext fptrunc fp2si fp2ui si2fp ui2fp int2ptr ptr2int) %} def {{name.id}}(value, type, name = "") # check_type({{name}}, type) # check_value(value) diff --git a/src/mime/multipart.cr b/src/mime/multipart.cr index d5ba88c32388..f5126fe057f7 100644 --- a/src/mime/multipart.cr +++ b/src/mime/multipart.cr @@ -83,7 +83,7 @@ module MIME::Multipart # Yields a `Multipart::Builder` to the given block, writing to *io* and # using *boundary*. `#finish` is automatically called on the builder. - def self.build(io, boundary = Multipart.generate_boundary) + def self.build(io : IO, boundary : String = Multipart.generate_boundary) builder = Builder.new(io, boundary) yield builder builder.finish @@ -91,7 +91,7 @@ module MIME::Multipart # Yields a `Multipart::Builder` to the given block, returning the generated # message as a `String`. - def self.build(boundary = Multipart.generate_boundary) + def self.build(boundary : String = Multipart.generate_boundary) String.build do |io| build(io, boundary) { |g| yield g } end @@ -104,7 +104,7 @@ module MIME::Multipart # # MIME::Multipart.generate_boundary # => "---------------------------dQu6bXHYb4m5zrRC3xPTGwV" # ``` - def self.generate_boundary + def self.generate_boundary : String "--------------------------#{Random::Secure.urlsafe_base64(18)}" end diff --git a/src/string/builder.cr b/src/string/builder.cr index c7dc2adf7867..bd6f94b8f15c 100644 --- a/src/string/builder.cr +++ b/src/string/builder.cr @@ -6,7 +6,7 @@ require "io" class String::Builder < IO getter bytesize : Int32 getter capacity : Int32 - getter buffer : Pointer(UInt8) + @buffer : Pointer(UInt8) def initialize(capacity : Int = 64) String.check_capacity_in_bounds(capacity) diff --git a/src/uri.cr b/src/uri.cr index 4cdca7378f9e..e60a807ef36b 100644 --- a/src/uri.cr +++ b/src/uri.cr @@ -502,19 +502,6 @@ class URI end end - # Parses `raw_url` into an URI. The `raw_url` may be relative or absolute. - # - # ``` - # require "uri" - # - # uri = URI.parse("http://crystal-lang.org") # => # - # uri.scheme # => "http" - # uri.host # => "crystal-lang.org" - # ``` - def self.parse(raw_url : String) : URI - URI::Parser.new(raw_url).run.uri - end - # [RFC 3986 6.2.2.3](https://tools.ietf.org/html/rfc3986#section-5.2.4) private def remove_dot_segments(path : String) result = [] of String diff --git a/src/uuid.cr b/src/uuid.cr index f9596b790a09..7e7c36e70993 100644 --- a/src/uuid.cr +++ b/src/uuid.cr @@ -30,7 +30,7 @@ struct UUID V5 = 5 end - protected getter bytes : StaticArray(UInt8, 16) + @bytes : StaticArray(UInt8, 16) # Generates UUID from *bytes*, applying *version* and *variant* to the UUID if # present. diff --git a/src/xml/node.cr b/src/xml/node.cr index 828ff4736804..6a4bca8d79b8 100644 --- a/src/xml/node.cr +++ b/src/xml/node.cr @@ -11,11 +11,6 @@ struct XML::Node initialize(node.as(LibXML::Node*)) end - # ditto - def initialize(node : LibXML::Doc*) - initialize(node.as(LibXML::Node*)) - end - # ditto def initialize(@node : LibXML::Node*) end