Skip to content

Commit b987c1f

Browse files
Replace is_a? calls with convenient alternatives (#15860)
1 parent 631c7e6 commit b987c1f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/comparable.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ module Comparable(T)
4040
def ==(other : T)
4141
if self.is_a?(Reference)
4242
# Need to do two different comparisons because the compiler doesn't yet
43-
# restrict something like `other.is_a?(Reference) || other.is_a?(Nil)`.
43+
# restrict something like `other.is_a?(Reference) || other.nil?`.
4444
# See #2461
4545
return true if other.is_a?(Reference) && self.same?(other)
46-
return true if other.is_a?(Nil) && self.same?(other)
46+
return true if other.nil? && self.same?(other)
4747
end
4848

4949
cmp = self <=> other

src/compiler/crystal/interpreter/compiler.cr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,8 @@ class Crystal::Repl::Compiler < Crystal::Visitor
10991099
end
11001100

11011101
private def dispatch_class_var(owner : Type, metaclass : Bool, node : ASTNode, &)
1102-
types = owner.all_subclasses.select { |t| t.is_a?(ClassVarContainer) }
1102+
types = [] of Crystal::Type
1103+
owner.all_subclasses.each { |t| types << t if t.is_a?(ClassVarContainer) }
11031104
types.push(owner)
11041105
types.sort_by! { |type| -type.depth }
11051106

0 commit comments

Comments
 (0)