@@ -595,29 +595,38 @@ export function compileCall(
595
595
let type = evaluateConstantType ( compiler , typeArguments , operands , reportNode ) ;
596
596
compiler . currentType = Type . bool ;
597
597
if ( ! type ) return module . unreachable ( ) ;
598
- let classType = type . classReference ;
599
- if ( classType ) {
600
- let stringInstance = compiler . program . stringInstance ;
601
- if ( stringInstance && classType . isAssignableTo ( stringInstance ) ) return module . i32 ( 1 ) ;
598
+ if ( type . is ( TypeFlags . REFERENCE ) ) {
599
+ let classReference = type . classReference ;
600
+ if ( classReference ) {
601
+ let stringInstance = compiler . program . stringInstance ;
602
+ if ( stringInstance && classReference . isAssignableTo ( stringInstance ) ) return module . i32 ( 1 ) ;
603
+ }
602
604
}
603
605
return module . i32 ( 0 ) ;
604
606
}
605
607
case BuiltinSymbols . isArray : { // isArray<T!>() / isArray<T?>(value: T) -> bool
606
608
let type = evaluateConstantType ( compiler , typeArguments , operands , reportNode ) ;
607
609
compiler . currentType = Type . bool ;
608
610
if ( ! type ) return module . unreachable ( ) ;
609
- let classReference = type . classReference ;
610
- if ( ! classReference ) return module . i32 ( 0 ) ;
611
- let classPrototype = classReference . prototype ;
612
- return module . i32 ( classPrototype . extends ( compiler . program . arrayPrototype ) ? 1 : 0 ) ;
611
+ if ( type . is ( TypeFlags . REFERENCE ) ) {
612
+ let classReference = type . classReference ;
613
+ if ( classReference ) {
614
+ return module . i32 ( classReference . prototype . extends ( compiler . program . arrayPrototype ) ? 1 : 0 ) ;
615
+ }
616
+ }
617
+ return module . i32 ( 0 ) ;
613
618
}
614
619
case BuiltinSymbols . isArrayLike : { // isArrayLike<T!>() / isArrayLike<T?>(value: T) -> bool
615
620
let type = evaluateConstantType ( compiler , typeArguments , operands , reportNode ) ;
616
621
compiler . currentType = Type . bool ;
617
622
if ( ! type ) return module . unreachable ( ) ;
618
- let classReference = type . classReference ;
619
- if ( ! classReference ) return module . i32 ( 0 ) ;
620
- return module . i32 ( classReference . isArrayLike ? 1 : 0 ) ;
623
+ if ( type . is ( TypeFlags . REFERENCE ) ) {
624
+ let classReference = type . classReference ;
625
+ if ( classReference ) {
626
+ return module . i32 ( classReference . isArrayLike ? 1 : 0 ) ;
627
+ }
628
+ }
629
+ return module . i32 ( 0 ) ;
621
630
}
622
631
case BuiltinSymbols . isFunction : { // isFunction<T!> / isFunction<T?>(value: T) -> bool
623
632
let type = evaluateConstantType ( compiler , typeArguments , operands , reportNode ) ;
@@ -637,7 +646,7 @@ export function compileCall(
637
646
checkTypeAbsent ( typeArguments , reportNode , prototype ) |
638
647
checkArgsRequired ( operands , 1 , reportNode , compiler )
639
648
) return module . unreachable ( ) ;
640
- let element = compiler . resolver . resolveExpression (
649
+ let element = compiler . resolver . lookupExpression (
641
650
operands [ 0 ] ,
642
651
compiler . currentFlow ,
643
652
Type . auto ,
@@ -747,8 +756,9 @@ export function compileCall(
747
756
checkTypeRequired ( typeArguments , reportNode , compiler ) |
748
757
checkArgsOptional ( operands , 0 , 1 , reportNode , compiler )
749
758
) return module . unreachable ( ) ;
750
- let classType = typeArguments ! [ 0 ] . classReference ;
751
- if ( ! classType ) {
759
+ let typeArgument = typeArguments ! [ 0 ] ;
760
+ let classType = typeArgument . classReference ;
761
+ if ( ! ( typeArgument . is ( TypeFlags . REFERENCE ) && classType !== null ) ) {
752
762
compiler . error (
753
763
DiagnosticCode . Operation_not_supported ,
754
764
reportNode . typeArgumentsRange
@@ -2436,8 +2446,9 @@ export function compileCall(
2436
2446
if (
2437
2447
checkTypeRequired ( typeArguments , reportNode , compiler , true )
2438
2448
) return module . unreachable ( ) ;
2439
- let classInstance = typeArguments ! [ 0 ] . classReference ;
2440
- if ( ! classInstance ) {
2449
+ let typeArgument = typeArguments ! [ 0 ] ;
2450
+ let classInstance = typeArgument . classReference ;
2451
+ if ( ! ( typeArgument . is ( TypeFlags . REFERENCE ) && classInstance !== null ) ) {
2441
2452
compiler . error (
2442
2453
DiagnosticCode . Operation_not_supported ,
2443
2454
reportNode . typeArgumentsRange
@@ -3665,7 +3676,7 @@ export function compileCall(
3665
3676
}
3666
3677
3667
3678
let classReference = type . classReference ;
3668
- if ( ! classReference || classReference . hasDecorator ( DecoratorFlags . UNMANAGED ) ) {
3679
+ if ( ! type . is ( TypeFlags . REFERENCE ) || ! classReference || classReference . hasDecorator ( DecoratorFlags . UNMANAGED ) ) {
3669
3680
compiler . error (
3670
3681
DiagnosticCode . Operation_not_supported ,
3671
3682
reportNode . range
@@ -4102,11 +4113,13 @@ export function compileVisitGlobals(compiler: Compiler): void {
4102
4113
for ( let element of compiler . program . elementsByName . values ( ) ) {
4103
4114
if ( element . kind != ElementKind . GLOBAL ) continue ;
4104
4115
let global = < Global > element ;
4105
- let classReference = global . type . classReference ;
4116
+ let globalType = global . type ;
4117
+ let classType = globalType . classReference ;
4106
4118
if (
4107
- global . is ( CommonFlags . COMPILED ) &&
4108
- classReference !== null &&
4109
- ! classReference . hasDecorator ( DecoratorFlags . UNMANAGED )
4119
+ globalType . is ( TypeFlags . REFERENCE ) &&
4120
+ classType !== null &&
4121
+ ! classType . hasDecorator ( DecoratorFlags . UNMANAGED ) &&
4122
+ global . is ( CommonFlags . COMPILED )
4110
4123
) {
4111
4124
if ( global . is ( CommonFlags . INLINED ) ) {
4112
4125
let value = global . constantIntegerValue ;
0 commit comments