diff --git a/src/comparable.cr b/src/comparable.cr index 7f7e0cc7fb8d..c0b0cc135291 100644 --- a/src/comparable.cr +++ b/src/comparable.cr @@ -40,10 +40,10 @@ module Comparable(T) def ==(other : T) if self.is_a?(Reference) # Need to do two different comparisons because the compiler doesn't yet - # restrict something like `other.is_a?(Reference) || other.is_a?(Nil)`. + # restrict something like `other.is_a?(Reference) || other.nil?`. # See #2461 return true if other.is_a?(Reference) && self.same?(other) - return true if other.is_a?(Nil) && self.same?(other) + return true if other.nil? && self.same?(other) end cmp = self <=> other diff --git a/src/compiler/crystal/interpreter/compiler.cr b/src/compiler/crystal/interpreter/compiler.cr index 9660c1c96c3f..6cd31fdf8e4e 100644 --- a/src/compiler/crystal/interpreter/compiler.cr +++ b/src/compiler/crystal/interpreter/compiler.cr @@ -1099,7 +1099,8 @@ class Crystal::Repl::Compiler < Crystal::Visitor end private def dispatch_class_var(owner : Type, metaclass : Bool, node : ASTNode, &) - types = owner.all_subclasses.select { |t| t.is_a?(ClassVarContainer) } + types = [] of Crystal::Type + owner.all_subclasses.each { |t| types << t if t.is_a?(ClassVarContainer) } types.push(owner) types.sort_by! { |type| -type.depth }