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
3333public 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