diff --git a/src/constants.ts b/src/constants.ts index 86f4edfe..29339361 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -4,6 +4,8 @@ export const WOLLOK_EXTRA_STACK_TRACE_HEADER = 'Derived from TypeScript stack' export const WOLLOK_BASE_PACKAGE = 'wollok.' +export const INITIALIZE_METHOD_NAME = 'initialize' + export const PREFIX_OPERATORS: Record = { '!': 'negate', '-': 'invert', @@ -59,4 +61,4 @@ export const KEYWORDS = { FIXTURE: 'fixture', PROGRAM: 'program', PACKAGE: 'package', -} as const \ No newline at end of file +} as const diff --git a/src/interpreter/runtimeModel.ts b/src/interpreter/runtimeModel.ts index 84c9feb5..552abca9 100644 --- a/src/interpreter/runtimeModel.ts +++ b/src/interpreter/runtimeModel.ts @@ -1,8 +1,8 @@ -import { LIST_MODULE, SET_MODULE, WOLLOK_BASE_PACKAGE, WOLLOK_EXTRA_STACK_TRACE_HEADER } from '../constants' import { v4 as uuid } from 'uuid' +import { INITIALIZE_METHOD_NAME, LIST_MODULE, SET_MODULE, WOLLOK_BASE_PACKAGE, WOLLOK_EXTRA_STACK_TRACE_HEADER } from '../constants' import { getPotentiallyUninitializedLazy } from '../decorators' import { get, is, last, List, match, raise, when } from '../extensions' -import { Assignment, Body, Catch, Describe, Environment, Entity, Expression, Id, If, Literal, LiteralValue, Method, Module, Name, New, Node, Package, Program, Reference, Return, Self, Send, Singleton, Super, Test, Throw, Try, Variable, Class } from '../model' +import { Assignment, Body, Catch, Class, Describe, Entity, Environment, Expression, Id, If, Literal, LiteralValue, Method, Module, Name, New, Node, Package, Program, Reference, Return, Self, Send, Singleton, Super, Test, Throw, Try, Variable } from '../model' import { Interpreter } from './interpreter' const { isArray } = Array @@ -681,7 +681,7 @@ export class Evaluation { instance.set(field.name, initialValue) } - yield * this.send('initialize', instance) + yield * this.send(INITIALIZE_METHOD_NAME, instance) if(!instance.module.name || instance.module.is(Describe)) for (const field of instance.module.allFields) diff --git a/src/validator.ts b/src/validator.ts index 46267462..04f84d2f 100644 --- a/src/validator.ts +++ b/src/validator.ts @@ -18,12 +18,14 @@ // - Level could be different for the same Expectation on different nodes // - Problem could know how to convert to string, receiving the interpolation function (so it can be translated). This could let us avoid having parameters. // - Good default for simple problems, but with a config object for more complex, so we know what is each parameter -import { WOLLOK_BASE_PACKAGE } from './constants' -import { count, TypeDefinition, duplicates, is, isEmpty, last, List, match, notEmpty, when } from './extensions' +import { INITIALIZE_METHOD_NAME, WOLLOK_BASE_PACKAGE } from './constants' +import { count, duplicates, is, isEmpty, last, List, match, notEmpty, TypeDefinition, when } from './extensions' // - Unified problem type -import { Assignment, Body, Catch, Class, Code, Describe, Entity, Expression, Field, If, Import, +import { + Assignment, Body, Catch, Class, Code, Describe, Entity, Expression, Field, If, Import, Level, Literal, Method, Mixin, Module, NamedArgument, New, Node, Package, Parameter, ParameterizedType, Problem, - Program, Reference, Return, Self, Send, Sentence, Singleton, SourceIndex, SourceMap, Super, Test, Throw, Try, Variable } from './model' + Program, Reference, Return, Self, Send, Sentence, Singleton, SourceIndex, SourceMap, Super, Test, Throw, Try, Variable +} from './model' const { entries } = Object @@ -184,7 +186,7 @@ export const shouldOnlyInheritFromMixin = error(node => node.supertypes.e })) export const shouldUseOverrideKeyword = warning(node => - node.isOverride || !superclassMethod(node) + node.isOverride || !superclassMethod(node) || node.name == INITIALIZE_METHOD_NAME ) export const possiblyReturningBlock = warning(node => {