Skip to content

Commit 977fa78

Browse files
committed
KERML_-117 Revised adding result typing for index expressions.
- Added result subsetting if seq argument result type is an array type *and* a scalar value type.
1 parent 39a44c9 commit 977fa78

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

org.omg.sysml/src/org/omg/sysml/adapter/IndexExpressionAdapter.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2024 Model Driven Solutions, Inc.
3+
* Copyright (c) 2024, 2025 Model Driven Solutions, Inc.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Lesser General Public License as published by
@@ -33,6 +33,7 @@
3333
public class IndexExpressionAdapter extends OperatorExpressionAdapter {
3434

3535
public static final String ARRAY_TYPE = "Collections::Array";
36+
public static final String SCALAR_VALUE_TYPE = "ScalarValues::ScalarValue";
3637

3738
public IndexExpressionAdapter(IndexExpression element) {
3839
super(element);
@@ -51,7 +52,9 @@ protected void addResultTyping() {
5152
Expression seqArgument = arguments.get(0);
5253
ElementUtil.transform(seqArgument);
5354
Feature seqResult = seqArgument.getResult();
54-
if (!hasArrayType(seqResult)) {
55+
Type arrayType = getLibraryType(ARRAY_TYPE);
56+
Type scalarValueType = getLibraryType(SCALAR_VALUE_TYPE);
57+
if (!TypeUtil.conforms(target, arrayType) || TypeUtil.conforms(target, scalarValueType)) {
5558
Feature resultFeature = target.getResult();
5659
if (resultFeature != null && seqResult != null) {
5760
TypeUtil.addImplicitGeneralTypeTo(resultFeature, SysMLPackage.eINSTANCE.getSubsetting(), seqResult);
@@ -60,10 +63,4 @@ protected void addResultTyping() {
6063
}
6164
}
6265

63-
protected boolean hasArrayType(Feature feature) {
64-
Type arrayType = getLibraryType(ARRAY_TYPE);
65-
return arrayType != null &&
66-
feature.getType().stream().anyMatch(t->TypeUtil.conforms(t, arrayType));
67-
}
68-
6966
}

0 commit comments

Comments
 (0)