@abaplint/core 2.120.21 → 2.120.22
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.
|
@@ -151,7 +151,7 @@ class CreateObject {
|
|
|
151
151
|
this.validateParameters(cdef, node, input);
|
|
152
152
|
}
|
|
153
153
|
static checkInstantiationAllowed(cdef, input) {
|
|
154
|
-
var _a, _b, _c
|
|
154
|
+
var _a, _b, _c;
|
|
155
155
|
const createVis = cdef.getCreateVisibility();
|
|
156
156
|
if (createVis === visibility_1.Visibility.Public) {
|
|
157
157
|
return undefined;
|
|
@@ -168,23 +168,30 @@ class CreateObject {
|
|
|
168
168
|
input.scope.isLocalFriend(cdef.getName(), enclosingClass)) {
|
|
169
169
|
return undefined;
|
|
170
170
|
}
|
|
171
|
+
const enclosingDefinition = input.scope.findClassDefinition(enclosingClass);
|
|
172
|
+
if (enclosingDefinition !== undefined) {
|
|
173
|
+
const implementedInterfaces = new _object_oriented_1.ObjectOriented(input.scope).findInterfaces(enclosingDefinition);
|
|
174
|
+
if (cdef.getFriends().some(friend => implementedInterfaces.some(implemented => implemented.name.toUpperCase() === friend.toUpperCase()))) {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
171
178
|
// subclasses of friends also have friendship
|
|
172
|
-
let enclosingSup =
|
|
179
|
+
let enclosingSup = enclosingDefinition === null || enclosingDefinition === void 0 ? void 0 : enclosingDefinition.getSuperClass();
|
|
173
180
|
while (enclosingSup !== undefined) {
|
|
174
181
|
if (cdef.getFriends().some(f => f.toUpperCase() === enclosingSup.toUpperCase()) ||
|
|
175
182
|
input.scope.isLocalFriend(cdef.getName(), enclosingSup)) {
|
|
176
183
|
return undefined;
|
|
177
184
|
}
|
|
178
|
-
enclosingSup = (
|
|
185
|
+
enclosingSup = (_a = input.scope.findClassDefinition(enclosingSup)) === null || _a === void 0 ? void 0 : _a.getSuperClass();
|
|
179
186
|
}
|
|
180
187
|
if (createVis === visibility_1.Visibility.Protected) {
|
|
181
188
|
// subclasses are also allowed
|
|
182
|
-
let sup = (
|
|
189
|
+
let sup = (_b = input.scope.findClassDefinition(enclosingClass)) === null || _b === void 0 ? void 0 : _b.getSuperClass();
|
|
183
190
|
while (sup !== undefined) {
|
|
184
191
|
if (sup.toUpperCase() === cdef.getName().toUpperCase()) {
|
|
185
192
|
return undefined;
|
|
186
193
|
}
|
|
187
|
-
sup = (
|
|
194
|
+
sup = (_c = input.scope.findClassDefinition(sup)) === null || _c === void 0 ? void 0 : _c.getSuperClass();
|
|
188
195
|
}
|
|
189
196
|
}
|
|
190
197
|
return cdef.getName() + " cannot be instantiated, class is defined as " +
|
package/build/src/registry.js
CHANGED