@@ -307,11 +307,26 @@ function* generateInstructionTypes(
307
307
kind : 'Property' ,
308
308
objectType : value . object . identifier . type ,
309
309
objectName : getName ( names , value . object . identifier . id ) ,
310
- propertyName : value . property ,
310
+ propertyName : {
311
+ kind : 'literal' ,
312
+ value : value . property ,
313
+ } ,
311
314
} ) ;
312
315
break ;
313
316
}
314
317
318
+ case 'ComputedLoad' : {
319
+ yield equation ( left , {
320
+ kind : 'Property' ,
321
+ objectType : value . object . identifier . type ,
322
+ objectName : getName ( names , value . object . identifier . id ) ,
323
+ propertyName : {
324
+ kind : 'computed' ,
325
+ value : value . property . identifier . type ,
326
+ } ,
327
+ } ) ;
328
+ break ;
329
+ }
315
330
case 'MethodCall' : {
316
331
const returnType = makeType ( ) ;
317
332
yield equation ( value . property . identifier . type , {
@@ -336,7 +351,10 @@ function* generateInstructionTypes(
336
351
kind : 'Property' ,
337
352
objectType : value . value . identifier . type ,
338
353
objectName : getName ( names , value . value . identifier . id ) ,
339
- propertyName : makePropertyLiteral ( propertyName ) ,
354
+ propertyName : {
355
+ kind : 'literal' ,
356
+ value : makePropertyLiteral ( propertyName ) ,
357
+ } ,
340
358
} ) ;
341
359
} else {
342
360
break ;
@@ -353,7 +371,10 @@ function* generateInstructionTypes(
353
371
kind : 'Property' ,
354
372
objectType : value . value . identifier . type ,
355
373
objectName : getName ( names , value . value . identifier . id ) ,
356
- propertyName : makePropertyLiteral ( property . key . name ) ,
374
+ propertyName : {
375
+ kind : 'literal' ,
376
+ value : makePropertyLiteral ( property . key . name ) ,
377
+ } ,
357
378
} ) ;
358
379
}
359
380
}
@@ -410,7 +431,6 @@ function* generateInstructionTypes(
410
431
case 'RegExpLiteral' :
411
432
case 'MetaProperty' :
412
433
case 'ComputedStore' :
413
- case 'ComputedLoad' :
414
434
case 'Await' :
415
435
case 'GetIterator' :
416
436
case 'IteratorNext' :
@@ -454,12 +474,13 @@ class Unifier {
454
474
return ;
455
475
}
456
476
const objectType = this . get ( tB . objectType ) ;
457
- let propertyType ;
458
- if ( typeof tB . propertyName === 'number' ) {
459
- propertyType = null ;
460
- } else {
461
- propertyType = this . env . getPropertyType ( objectType , tB . propertyName ) ;
462
- }
477
+ const propertyType =
478
+ tB . propertyName . kind === 'literal'
479
+ ? this . env . getPropertyType ( objectType , tB . propertyName . value )
480
+ : this . env . getFallthroughPropertyType (
481
+ objectType ,
482
+ tB . propertyName . value ,
483
+ ) ;
463
484
if ( propertyType !== null ) {
464
485
this . unify ( tA , propertyType ) ;
465
486
}
@@ -677,7 +698,11 @@ class Unifier {
677
698
const RefLikeNameRE = / ^ (?: [ a - z A - Z $ _ ] [ a - z A - Z $ _ 0 - 9 ] * ) R e f $ | ^ r e f $ / ;
678
699
679
700
function isRefLikeName ( t : PropType ) : boolean {
680
- return RefLikeNameRE . test ( t . objectName ) && t . propertyName === 'current' ;
701
+ return (
702
+ t . propertyName . kind === 'literal' &&
703
+ RefLikeNameRE . test ( t . objectName ) &&
704
+ t . propertyName . value === 'current'
705
+ ) ;
681
706
}
682
707
683
708
function tryUnionTypes ( ty1 : Type , ty2 : Type ) : Type | null {
0 commit comments