@@ -640,6 +640,14 @@ export class Program extends DiagnosticEmitter {
640
640
}
641
641
private _regexpInstance : Class | null = null ;
642
642
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
+
643
651
/** Gets the standard `Object` instance. */
644
652
get objectInstance ( ) : Class {
645
653
let cached = this . _objectInstance ;
@@ -1257,10 +1265,11 @@ export class Program extends DiagnosticEmitter {
1257
1265
}
1258
1266
}
1259
1267
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 ) ;
1264
1273
1265
1274
// register classes backing basic types
1266
1275
this . registerWrapperClass ( Type . i8 , CommonNames . I8 ) ;
@@ -2044,7 +2053,14 @@ export class Program extends DiagnosticEmitter {
2044
2053
}
2045
2054
2046
2055
// 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
+ }
2048
2064
2049
2065
// initialize members
2050
2066
let memberDeclarations = declaration . members ;
@@ -4165,6 +4181,8 @@ export class ClassPrototype extends DeclaredElement {
4165
4181
instances : Map < string , Class > | null = null ;
4166
4182
/** Classes extending this class. */
4167
4183
extendees : Set < ClassPrototype > = new Set ( ) ;
4184
+ /** Whether this class implicitly extends `Object`. */
4185
+ implicitlyExtendsObject : bool = false ;
4168
4186
4169
4187
constructor (
4170
4188
/** Simple name. */
0 commit comments