Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicated defs #8270

Merged
merged 14 commits into from
Oct 11, 2019
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
1 change: 0 additions & 1 deletion src/compiler/crystal/codegen/codegen.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions src/compiler/crystal/semantic/abstract_def_checker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/compiler/crystal/semantic/warnings.cr
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion src/compiler/crystal/syntax/ast.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -575,6 +575,8 @@ module Crystal
@name_size
end

setter name_size

def accept_children(visitor)
@obj.try &.accept visitor
@args.each &.accept visitor
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/tools/init.cr
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ module Crystal

class InitProject
getter config : Config
getter views : Array(View)?
@views : Array(View)?

def initialize(@config : Config)
end
Expand Down
8 changes: 0 additions & 8 deletions src/compiler/crystal/types.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions src/compiler/crystal/util.cr
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
8 changes: 0 additions & 8 deletions src/io/byte_format.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these useless?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because they are defined as non-abstract a few lines below. It doesn't make sense to define a method as abstract and as non-abstract in the same type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I'm blind :)


abstract def encode(int : Int8, bytes : Bytes)
abstract def encode(int : UInt8, bytes : Bytes)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/llvm/builder.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/mime/multipart.cr
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ 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
end

# 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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/string/builder.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 0 additions & 13 deletions src/uri.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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:0x1068a7e40 @scheme="http", @host="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
Expand Down
2 changes: 1 addition & 1 deletion src/uuid.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 0 additions & 5 deletions src/xml/node.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down