Skip to content

Commit

Permalink
Classes do not include AA members (#970)
Browse files Browse the repository at this point in the history
* Classes do not include AA members

* lint fix
  • Loading branch information
markwpearce authored Nov 30, 2023
1 parent d850411 commit 87a0397
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/types/BuiltInInterfaceAdder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ describe('BuiltInInterfaceAdder', () => {
expectTypeToBe(myType.getMemberType('join', { flags: SymbolTypeFlag.runtime }), TypedFunctionType);
});

it('should add members to ClassType', () => {
it('should not add members to ClassType', () => {
const myType = new ClassType('Klass');
BuiltInInterfaceAdder.addBuiltInInterfacesToType(myType);

expectTypeToBe(myType.getMemberType('clear', { flags: SymbolTypeFlag.runtime }), TypedFunctionType);
expectTypeToBe(myType.getMemberType('lookUp', { flags: SymbolTypeFlag.runtime }), TypedFunctionType);
expect(myType.getMemberType('clear', { flags: SymbolTypeFlag.runtime }).isResolvable()).to.be.false;
expect(myType.getMemberType('lookUp', { flags: SymbolTypeFlag.runtime }).isResolvable()).to.be.false;
});

it('should allow classes to override built in members', () => {
it('should allow classes to override AA members', () => {
const myType = new ClassType('Klass');
myType.addMember('clear', null, new BooleanType(), SymbolTypeFlag.runtime);
BuiltInInterfaceAdder.addBuiltInInterfacesToType(myType);
expectTypeToBe(myType.getMemberType('clear', { flags: SymbolTypeFlag.runtime }), BooleanType);
});

it('should not include members that have already been overridded', () => {
it('should not include members that have already been overrided', () => {
const myType = new ClassType('Klass');
myType.addMember('clear', null, new BooleanType(), SymbolTypeFlag.runtime);
BuiltInInterfaceAdder.addBuiltInInterfacesToType(myType);
Expand Down
4 changes: 1 addition & 3 deletions src/types/BuiltInInterfaceAdder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { TypedFunctionType } from './TypedFunctionType';
import type { SymbolTable } from '../SymbolTable';
import { SymbolTypeFlag } from '../SymbolTable';
import type { BscType } from './BscType';
import { isArrayType, isAssociativeArrayType, isBooleanType, isCallableType, isClassType, isComponentType, isDoubleType, isEnumMemberType, isFloatType, isIntegerType, isInterfaceType, isInvalidType, isLongIntegerType, isStringType } from '../astUtils/reflection';
import { isArrayType, isAssociativeArrayType, isBooleanType, isCallableType, isComponentType, isDoubleType, isEnumMemberType, isFloatType, isIntegerType, isInterfaceType, isInvalidType, isLongIntegerType, isStringType } from '../astUtils/reflection';
import type { ComponentType } from './ComponentType';
import util from '../util';
import type { UnionType } from './UnionType';
Expand Down Expand Up @@ -114,8 +114,6 @@ export class BuiltInInterfaceAdder {
return 'roInvalid';
} else if (isCallableType(theType)) {
return 'roFunction';
} else if (isClassType(theType)) {
return 'roAssociativeArray';
} else if (isAssociativeArrayType(theType)) {
return 'roAssociativeArray';
} else if (isArrayType(theType)) {
Expand Down

0 comments on commit 87a0397

Please sign in to comment.