• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rokucommunity / brighterscript / #15048

01 Jan 2026 11:17PM UTC coverage: 87.048% (-0.9%) from 87.907%
#15048

push

web-flow
Merge 02ba2bb57 into 2ea4d2108

14498 of 17595 branches covered (82.4%)

Branch coverage included in aggregate %.

192 of 261 new or added lines in 12 files covered. (73.56%)

897 existing lines in 48 files now uncovered.

15248 of 16577 relevant lines covered (91.98%)

24112.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.29
/src/types/ArrayType.ts
1

2
import { SymbolTypeFlag } from '../SymbolTypeFlag';
1✔
3
import { isArrayType, isDynamicType, isEnumMemberType, isInvalidType, isObjectType } from '../astUtils/reflection';
1✔
4
import type { TypeCompatibilityData } from '../interfaces';
5
import { BscType } from './BscType';
1✔
6
import { BscTypeKind } from './BscTypeKind';
1✔
7
import type { BuiltInInterfaceOverride } from './BuiltInInterfaceAdder';
8
import { BuiltInInterfaceAdder } from './BuiltInInterfaceAdder';
1✔
9
import { DynamicType } from './DynamicType';
1✔
10
import { IntegerType } from './IntegerType';
1✔
11
import { unionTypeFactory } from './UnionType';
1✔
12
import { getUniqueType, isUnionTypeCompatible } from './helpers';
1✔
13
import { util } from '../util';
1✔
14

15
export class ArrayType extends BscType {
1✔
16
    constructor(...innerTypes: BscType[]) {
17
        super();
191,519✔
18
        this.innerTypes = innerTypes;
191,519✔
19
    }
20

21
    public readonly kind = BscTypeKind.ArrayType;
191,519✔
22
    public isBuiltIn = true;
191,519✔
23

24
    public innerTypes: BscType[] = [];
191,519✔
25

26
    public _defaultType: BscType;
27
    private isCheckingInnerTypesForDefaultType = false;
191,519✔
28

29
    public get defaultType(): BscType {
30
        if (this._defaultType) {
9,928✔
31
            return this._defaultType;
1,229✔
32
        }
33
        if (this.innerTypes?.length === 0 || this.isCheckingInnerTypesForDefaultType) {
8,699!
34
            return DynamicType.instance;
8,518✔
35
        }
36
        this.isCheckingInnerTypesForDefaultType = true;
181✔
37

38
        let resultType = this.innerTypes[0];
181✔
39
        if (this.innerTypes?.length > 1) {
181!
40
            resultType = getUniqueType(this.innerTypes, unionTypeFactory) ?? DynamicType.instance;
31!
41
        }
42
        if (isEnumMemberType(resultType)) {
181✔
43
            resultType = resultType.parentEnumType ?? resultType;
2!
44
        }
45
        this._defaultType = util.getDefaultTypeFromValueType(resultType);
181✔
46
        this.isCheckingInnerTypesForDefaultType = false;
181✔
47
        return this._defaultType;
181✔
48
    }
49

50
    public isTypeCompatible(targetType: BscType, data?: TypeCompatibilityData) {
51

52
        if (isDynamicType(targetType)) {
25✔
53
            return true;
1✔
54
        } else if (isObjectType(targetType)) {
24✔
55
            return true;
3✔
56
        } else if (isInvalidType(targetType)) {
21✔
57
            return true;
5✔
58
        } else if (isUnionTypeCompatible(this, targetType)) {
16!
UNCOV
59
            return true;
×
60
        } else if (isArrayType(targetType)) {
16✔
61
            const compatible = this.defaultType.isTypeCompatible(targetType.defaultType, data);
10✔
62
            if (data) {
10✔
63
                data.actualType = targetType.defaultType;
6✔
64
                data.expectedType = this.defaultType;
6✔
65
            }
66
            return compatible;
10✔
67
        } else if (this.checkCompatibilityBasedOnMembers(targetType, SymbolTypeFlag.runtime, data)) {
6✔
68
            return true;
3✔
69
        }
70
        return false;
3✔
71
    }
72

73
    public toString() {
74
        return `Array<${this.defaultType.toString()}>`;
8,848✔
75
    }
76

77
    public toTypeString(): string {
UNCOV
78
        return 'object';
×
79
    }
80

81
    public isEqual(targetType: BscType): boolean {
82
        if (isArrayType(targetType)) {
3✔
83
            if (targetType.innerTypes.length !== this.innerTypes.length) {
1!
UNCOV
84
                return false;
×
85
            }
86
            for (let i = 0; i < this.innerTypes.length; i++) {
1✔
UNCOV
87
                if (!this.innerTypes[i].isEqual(targetType.innerTypes[i])) {
×
UNCOV
88
                    return false;
×
89
                }
90
            }
91
            return true;
1✔
92
        }
93
        return false;
2✔
94
    }
95

96
    addBuiltInInterfaces() {
97
        if (!this.hasAddedBuiltInInterfaces) {
141✔
98
            const overrideMap = new Map<string, BuiltInInterfaceOverride>();
58✔
99
            const defaultType = this.defaultType;
58✔
100
            overrideMap
58✔
101
                // ifArray
102
                .set('peek', { returnType: defaultType })
103
                .set('pop', { returnType: defaultType })
104
                .set('push', { parameterTypes: [defaultType] })
105
                .set('shift', { returnType: defaultType })
106
                .set('unshift', { parameterTypes: [defaultType] })
107
                .set('append', { parameterTypes: [this] })
108
                // ifArrayGet
109
                .set('get', { returnType: defaultType })
110
                // ifArraySet
111
                .set('get', { parameterTypes: [IntegerType.instance, defaultType] })
112
                //ifEnum
113
                .set('next', { returnType: defaultType });
114
            BuiltInInterfaceAdder.addBuiltInInterfacesToType(this, overrideMap);
58✔
115
        }
116
        this.hasAddedBuiltInInterfaces = true;
141✔
117
    }
118
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc