@abaplint/core 2.97.9 → 2.97.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1286,7 +1286,7 @@ export declare class CurrentScope {
1286
1286
  findTypePoolConstant(name: string | undefined): TypedIdentifier | undefined;
1287
1287
  findTypePoolType(name: string): TypedIdentifier | undefined;
1288
1288
  /** Lookup interface in local and global scope */
1289
- findInterfaceDefinition(name: string): IInterfaceDefinition | undefined;
1289
+ findInterfaceDefinition(name: string | undefined): IInterfaceDefinition | undefined;
1290
1290
  findFormDefinition(name: string): IFormDefinition | undefined;
1291
1291
  findType(name: string | undefined): TypedIdentifier | undefined;
1292
1292
  findExtraLikeType(name: string | undefined): TypedIdentifier | undefined;
@@ -251,6 +251,9 @@ class CurrentScope {
251
251
  /** Lookup interface in local and global scope */
252
252
  findInterfaceDefinition(name) {
253
253
  var _a;
254
+ if (name === undefined) {
255
+ return undefined;
256
+ }
254
257
  const ilocal = (_a = this.current) === null || _a === void 0 ? void 0 : _a.findInterfaceDefinition(name);
255
258
  if (ilocal) {
256
259
  return ilocal;
@@ -190,21 +190,48 @@ class TypeUtils {
190
190
  // todo
191
191
  return true;
192
192
  }
193
+ structureContainsString(structure) {
194
+ for (const c of structure.getComponents()) {
195
+ if (c.type instanceof basic_1.StringType) {
196
+ return true;
197
+ }
198
+ }
199
+ return false;
200
+ }
193
201
  isAssignableStrict(source, target) {
194
- var _a;
202
+ var _a, _b;
195
203
  /*
196
204
  console.dir(source);
197
205
  console.dir(target);
198
206
  */
199
- if (source instanceof basic_1.CharacterType && target instanceof basic_1.CharacterType) {
200
- if (((_a = source.getAbstractTypeData()) === null || _a === void 0 ? void 0 : _a.derivedFromConstant) === true) {
201
- return source.getLength() <= target.getLength();
207
+ if (source instanceof basic_1.CharacterType) {
208
+ if (target instanceof basic_1.CharacterType) {
209
+ if (((_a = source.getAbstractTypeData()) === null || _a === void 0 ? void 0 : _a.derivedFromConstant) === true) {
210
+ return source.getLength() <= target.getLength();
211
+ }
212
+ return source.getLength() === target.getLength();
213
+ }
214
+ else if (target instanceof basic_1.IntegerType) {
215
+ if (((_b = source.getAbstractTypeData()) === null || _b === void 0 ? void 0 : _b.derivedFromConstant) === true) {
216
+ return true;
217
+ }
218
+ return false;
202
219
  }
203
- return source.getLength() === target.getLength();
204
220
  }
205
221
  else if (source instanceof basic_1.StringType && target instanceof basic_1.StructureType) {
206
- for (const c of target.getComponents()) {
207
- if (c.type instanceof basic_1.StringType) {
222
+ if (this.structureContainsString(target)) {
223
+ return false;
224
+ }
225
+ return true;
226
+ }
227
+ else if (source instanceof basic_1.StructureType && target instanceof basic_1.StructureType) {
228
+ const sourceComponents = source.getComponents();
229
+ const targetComponents = target.getComponents();
230
+ if (sourceComponents.length !== targetComponents.length) {
231
+ return false;
232
+ }
233
+ for (let i = 0; i < sourceComponents.length; i++) {
234
+ if (this.isAssignableStrict(sourceComponents[i].type, targetComponents[i].type) === false) {
208
235
  return false;
209
236
  }
210
237
  }
@@ -258,12 +285,17 @@ class TypeUtils {
258
285
  if (source instanceof basic_1.TableType && source.isWithHeader()) {
259
286
  return this.isAssignable(source.getRowType(), target);
260
287
  }
261
- else if (source instanceof basic_1.StructureType
262
- || source instanceof basic_1.VoidType
288
+ else if (source instanceof basic_1.VoidType
263
289
  || source instanceof basic_1.AnyType
264
290
  || source instanceof basic_1.UnknownType) {
265
291
  return true;
266
292
  }
293
+ else if (source instanceof basic_1.StructureType) {
294
+ if (this.structureContainsString(target) && !this.structureContainsString(source)) {
295
+ return false;
296
+ }
297
+ return true;
298
+ }
267
299
  else if (target.containsVoid() === true) {
268
300
  return true;
269
301
  }
@@ -59,6 +59,11 @@ class CreateObject {
59
59
  if (id instanceof types_1.InterfaceDefinition && type === undefined) {
60
60
  throw new Error("Interface reference, cannot be instantiated");
61
61
  }
62
+ else if (found instanceof basic_1.ObjectReferenceType
63
+ && type === undefined
64
+ && scope.findInterfaceDefinition(found.getQualifiedName())) {
65
+ throw new Error("Interface reference, cannot be instantiated");
66
+ }
62
67
  else if (id instanceof types_1.ClassDefinition && cdef === undefined) {
63
68
  cdef = id;
64
69
  }
@@ -63,7 +63,7 @@ class Registry {
63
63
  }
64
64
  static abaplintVersion() {
65
65
  // magic, see build script "version.sh"
66
- return "2.97.9";
66
+ return "2.97.11";
67
67
  }
68
68
  getDDICReferences() {
69
69
  return this.references;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.97.9",
3
+ "version": "2.97.11",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",