@@ -640,6 +640,14 @@ export class Program extends DiagnosticEmitter {
640640 }
641641 private _regexpInstance : Class | null = null ;
642642
643+ /** Gets the standard `Object` prototype. */
644+ get objectPrototype ( ) : ClassPrototype {
645+ let cached = this . _objectPrototype ;
646+ if ( ! cached ) this . _objectPrototype = cached = < ClassPrototype > this . require ( CommonNames . Object , ElementKind . ClassPrototype ) ;
647+ return cached ;
648+ }
649+ private _objectPrototype : ClassPrototype | null = null ;
650+
643651 /** Gets the standard `Object` instance. */
644652 get objectInstance ( ) : Class {
645653 let cached = this . _objectInstance ;
@@ -1257,10 +1265,11 @@ export class Program extends DiagnosticEmitter {
12571265 }
12581266 }
12591267
1260- // register ArrayBuffer (id=0), String (id=1), ArrayBufferView (id=2)
1261- assert ( this . arrayBufferInstance . id == 0 ) ;
1262- assert ( this . stringInstance . id == 1 ) ;
1263- assert ( this . arrayBufferViewInstance . id == 2 ) ;
1268+ // register foundational classes with fixed ids
1269+ assert ( this . objectInstance . id == 0 ) ;
1270+ assert ( this . arrayBufferInstance . id == 1 ) ;
1271+ assert ( this . stringInstance . id == 2 ) ;
1272+ assert ( this . arrayBufferViewInstance . id == 3 ) ;
12641273
12651274 // register classes backing basic types
12661275 this . registerWrapperClass ( Type . i8 , CommonNames . I8 ) ;
@@ -2044,7 +2053,14 @@ export class Program extends DiagnosticEmitter {
20442053 }
20452054
20462055 // remember classes that extend another class
2047- if ( declaration . extendsType ) queuedExtends . push ( element ) ;
2056+ if ( declaration . extendsType ) {
2057+ queuedExtends . push ( element ) ;
2058+ } else if (
2059+ ! element . hasDecorator ( DecoratorFlags . Unmanaged ) &&
2060+ element . internalName != BuiltinNames . Object
2061+ ) {
2062+ element . implicitlyExtendsObject = true ;
2063+ }
20482064
20492065 // initialize members
20502066 let memberDeclarations = declaration . members ;
@@ -4165,6 +4181,8 @@ export class ClassPrototype extends DeclaredElement {
41654181 instances : Map < string , Class > | null = null ;
41664182 /** Classes extending this class. */
41674183 extendees : Set < ClassPrototype > = new Set ( ) ;
4184+ /** Whether this class implicitly extends `Object`. */
4185+ implicitlyExtendsObject : bool = false ;
41684186
41694187 constructor (
41704188 /** Simple name. */
0 commit comments