diff --git a/org.omg.sysml.logic/src/main/java/org/omg/sysml/delegate/invocation/InstantiationExpression_instantiatedType_InvocationDelegate.java b/org.omg.sysml.logic/src/main/java/org/omg/sysml/delegate/invocation/InstantiationExpression_instantiatedType_InvocationDelegate.java
index 1eb349fd0..4fbcc26df 100644
--- a/org.omg.sysml.logic/src/main/java/org/omg/sysml/delegate/invocation/InstantiationExpression_instantiatedType_InvocationDelegate.java
+++ b/org.omg.sysml.logic/src/main/java/org/omg/sysml/delegate/invocation/InstantiationExpression_instantiatedType_InvocationDelegate.java
@@ -1,7 +1,8 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2025 Model Driven Solutions, Inc.
- *
+ * Copyright (c) 2026 Obeo
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Eclipse Public License as published by
* the Eclipse Foundation, version 2 of the License.
@@ -21,6 +22,7 @@
package org.omg.sysml.delegate.invocation;
import java.lang.reflect.InvocationTargetException;
+import java.util.Objects;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EOperation;
@@ -40,11 +42,13 @@ public InstantiationExpression_instantiatedType_InvocationDelegate(EOperation op
@Override
public Object dynamicInvoke(InternalEObject target, EList> arguments) throws InvocationTargetException {
InstantiationExpression self = (InstantiationExpression) target;
- Element member =self.getOwnedMembership().stream().
- filter(m->!(m instanceof FeatureMembership)).
- map(Membership::getMemberElement).
- findFirst().orElse(null);
- return member instanceof Type? member: null;
+ Element member = self.getOwnedMembership().stream()
+ .filter(m->!(m instanceof FeatureMembership))
+ .map(Membership::getMemberElement)
+ .filter(Objects::nonNull)
+ .findFirst()
+ .orElse(null);
+ return member instanceof Type ? member: null;
}
}
diff --git a/org.omg.sysml.logic/src/test/java/org/omg/sysml/logic/InstantiationExpression_instantiatedType_InvocationDelegateTest.java b/org.omg.sysml.logic/src/test/java/org/omg/sysml/logic/InstantiationExpression_instantiatedType_InvocationDelegateTest.java
new file mode 100644
index 000000000..a53e9d819
--- /dev/null
+++ b/org.omg.sysml.logic/src/test/java/org/omg/sysml/logic/InstantiationExpression_instantiatedType_InvocationDelegateTest.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * SysML 2 Pilot Implementation
+ * Copyright (c) 2026 Obeo
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Eclipse Public License as published by
+ * the Eclipse Foundation, version 2 of the License.
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Eclipse Public License for more details.
+ *
+ * You should have received a copy of theEclipse Public License
+ * along with this program. If not, see .
+ *
+ * @license EPL-2.0
+ *
+ *******************************************************************************/
+package org.omg.sysml.logic;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.emf.ecore.InternalEObject;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.omg.sysml.delegate.invocation.InstantiationExpression_instantiatedType_InvocationDelegate;
+import org.omg.sysml.lang.sysml.InvocationExpression;
+import org.omg.sysml.lang.sysml.SysMLFactory;
+import org.omg.sysml.lang.sysml.SysMLPackage;
+
+public class InstantiationExpression_instantiatedType_InvocationDelegateTest {
+
+ @BeforeClass
+ public static void setUp() {
+ SysMLLogicStandaloneSetup.doSetup();
+ }
+
+ /**
+ * Test the call of InstantiationExpression_instantiatedType_InvocationDelegate will not throw an NPE
+ * @throws InvocationTargetException
+ */
+ @Test
+ public void incompleteInstantiationExpression() throws InvocationTargetException {
+ InvocationExpression invocationExpression = SysMLFactory.eINSTANCE.createInvocationExpression();
+ invocationExpression.getOwnedRelationship().add(SysMLFactory.eINSTANCE.createMembership());
+ new InstantiationExpression_instantiatedType_InvocationDelegate(SysMLPackage.eINSTANCE.getInstantiationExpression__InstantiatedType())
+ .dynamicInvoke((InternalEObject) invocationExpression,null);
+ }
+}