Add Object.same(_,_) to access built-in equality even for classes that may override ==.

Had to add a new metaclass for Object since it now has its own static method so we
can't just use Class as its metaclass. (We don't want *every* class to have a same(_,_)
static method.)
This commit is contained in:
Bob Nystrom
2015-05-01 07:55:28 -07:00
parent a907c143c8
commit fcf4197139
6 changed files with 116 additions and 31 deletions
+5 -1
View File
@@ -5,5 +5,9 @@ IO.print(Foo.type.name) // expect: Foo metaclass
// Make sure the built-in classes have proper names too.
IO.print(Object.name) // expect: Object
IO.print(Class.name) // expect: Class
IO.print(Bool.name) // expect: Bool
IO.print(Class.name) // expect: Class
// And metaclass names.
IO.print(Object.type.name) // expect: Object metaclass
IO.print(Bool.type.name) // expect: Bool metaclass
+1 -1
View File
@@ -3,7 +3,7 @@ class Foo {}
// A class is a class.
IO.print(Foo is Class) // expect: true
// It's metatype is also a class.
// Its metatype is also a class.
IO.print(Foo.type is Class) // expect: true
// The metatype's metatype is Class.