Project

General

Profile

Actions

Bug #6020

closed

Unexpected is_a/kind_of behaviour

Added by MasterLambaster (Alex N) almost 13 years ago. Updated almost 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0dev (2012-02-14 trunk 34598) [x86_64-darwin11.3.0]
Backport:
[ruby-core:42607]

Description

=begin
I've noticed some inconsistent is_a?/kind_of? methods behavior in a very special cases
self.class #=> Object

BasicObject.is_a?(BasicObject) #=> true
Module.is_a?(Module) #=> true
Class.is_a?(Class) #=> true
Object.is_a?(Object) #=> true

BasicObject.is_a?(Module) #=> true

Integer.is_a?(Integer) #=> false
class A; end
A.is_a?(A) #=> false

module B; end
B.is_a?(B) #=> false

class C < Object; end
C.is_a?(C) #=> false
C.is_a?(Object) #=> true
C.is_a?(BasicObject) #=> true
C.is_a?(Module) #=> true
C.is_a?(Class) #=> true

c = C.new
c.is_a?(Module) #=> false
c.is_a?(Class) #=> false

It looks like it's because Class, Module, Object and BasicObject have class Class, superclass is set properly.
Anyway all is logical but not expected.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0