Skip to content

Commit bff1ad5

Browse files
authored
Merge pull request #480 from Systems-Modeling/ST6RI-676
ST6RI-676 Feature chain expression result typing can fail when used with indexing
2 parents 019c9ea + 9b487fc commit bff1ad5

4 files changed

Lines changed: 55 additions & 2 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//*
2+
XPECT_SETUP org.omg.kerml.xpect.tests.parsing.KerMLParsingTest
3+
ResourceSet {
4+
ThisFile {}
5+
File {from ="/library/Base.kerml"}
6+
File {from ="/library/Links.kerml"}
7+
File {from ="/library/Occurrences.kerml"}
8+
File {from ="/library/Performances.kerml"}
9+
File {from ="/library/ScalarValues.kerml"}
10+
File {from ="/library/Collections.kerml"}
11+
File {from ="/library/BaseFunctions.kerml"}
12+
}
13+
Workspace {
14+
JavaProject {
15+
SrcFolder {
16+
ThisFile {}
17+
File {from ="/library/Base.kerml"}
18+
File {from ="/library/Links.kerml"}
19+
File {from ="/library/Occurrences.kerml"}
20+
File {from ="/library/Performances.kerml"}
21+
File {from ="/library/ScalarValues.kerml"}
22+
File {from ="/library/Collections.kerml"}
23+
File {from ="/library/BaseFunctions.kerml"}
24+
}
25+
}
26+
}
27+
END_SETUP
28+
*/
29+
30+
// XPECT noErrors ---> ""
31+
package Indexing {
32+
classifier A {
33+
feature b : B;
34+
}
35+
classifier B {
36+
feature c;
37+
}
38+
feature a : A[*];
39+
feature b = a#(1).b;
40+
feature c = b.c;
41+
42+
feature arr : Collections::Array {
43+
:>> dimensions = (2, 3);
44+
:>> elements = ("a", "b", "c",
45+
"x", "y", "z");
46+
}
47+
feature arr13 = arr#(1,3);
48+
feature arr22 = arr#(2,2);
49+
}

org.omg.kerml.xtext/src/org/omg/kerml/xtext/validation/KerMLValidator.xtend

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ class KerMLValidator extends AbstractKerMLValidator {
453453
}
454454

455455
private def doCheckConnector(Connector c, Type location, EClass kind) {
456+
ElementUtil.transform(c)
456457
val cFeaturingTypes = c.featuringType
457458

458459
if (kind == SysMLPackage.Literals.FEATURE_MEMBERSHIP) {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.omg.sysml.lang.sysml.Feature;
2727
import org.omg.sysml.lang.sysml.OperatorExpression;
2828
import org.omg.sysml.lang.sysml.SysMLPackage;
29+
import org.omg.sysml.util.ElementUtil;
2930
import org.omg.sysml.util.ExpressionUtil;
3031
import org.omg.sysml.util.TypeUtil;
3132

@@ -47,8 +48,10 @@ public void addIndexingResultSubsetting() {
4748
if (INDEXING_OPERATOR.equals(target.getOperator())) {
4849
EList<Expression> arguments = target.getArgument();
4950
if (!arguments.isEmpty()) {
51+
Expression seqArgument = arguments.get(0);
52+
ElementUtil.transform(seqArgument);
53+
Feature seqResult = seqArgument.getResult();
5054
Feature resultFeature = target.getResult();
51-
Feature seqResult = arguments.get(0).getResult();
5255
if (resultFeature != null && seqResult != null)
5356
TypeUtil.addImplicitGeneralTypeTo(resultFeature, SysMLPackage.eINSTANCE.getSubsetting(), seqResult);
5457
}

sysml/src/examples/Geometry Examples/VehicleGeometryAndCoordinateFrames.sysml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ package VehicleGeometryAndCoordinateFrames {
5454
assert constraint {
5555
(1..numberOfBolts)->forAll {
5656
in i : Natural;
57-
private attribute lbcf : CoordinateFrame = lugBolts#(i).coordinateFrame;
57+
private attribute lbcf = lugBolts#(i).coordinateFrame;
5858
private attribute trs : TranslationRotationSequence {
5959
:>> source = wcf;
6060
:>> target = lbcf;

0 commit comments

Comments
 (0)