diff --git a/core/codegen/vdm2jml/src/main/java/org/overture/codegen/vdm2jml/NamedTypeInvDepCalculator.java b/core/codegen/vdm2jml/src/main/java/org/overture/codegen/vdm2jml/NamedTypeInvDepCalculator.java
index <HASH>..<HASH> 100644
--- a/core/codegen/vdm2jml/src/main/java/org/overture/codegen/vdm2jml/NamedTypeInvDepCalculator.java
+++ b/core/codegen/vdm2jml/src/main/java/org/overture/codegen/vdm2jml/NamedTypeInvDepCalculator.java
@@ -157,7 +157,7 @@ public class NamedTypeInvDepCalculator extends DepthFirstAnalysisAdaptor
 			// Say we are visiting a union type that is optional, e.g.
 			//T = [S | nat];
 			// Then we mark the previous type, e.g T as optional
-			if(previous != null)
+			if(optional && previous != null)
 			{
 				previous.makeOptional();
 			}
Fix for the named type invariant dependency calcutor.

A union type was by accident always mark as an optional type