Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make shouldUseOverrideKeyword ignore initialize method #176

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Name, Name> = {
'!': 'negate',
'-': 'invert',
Expand Down Expand Up @@ -59,4 +61,4 @@ export const KEYWORDS = {
FIXTURE: 'fixture',
PROGRAM: 'program',
PACKAGE: 'package',
} as const
} as const
6 changes: 3 additions & 3 deletions src/interpreter/runtimeModel.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -184,7 +186,7 @@ export const shouldOnlyInheritFromMixin = error<Mixin>(node => node.supertypes.e
}))

export const shouldUseOverrideKeyword = warning<Method>(node =>
node.isOverride || !superclassMethod(node)
node.isOverride || !superclassMethod(node) || node.name == INITIALIZE_METHOD_NAME
)

export const possiblyReturningBlock = warning<Method>(node => {
Expand Down
Loading