Error: Class cast exception
I am trying to write TDL test cases for some sample projects and I get "java.lang.ClassCastException:class org.etsi.mts.tdl.impl.SimpleDataTypeImpl cannot be cast to class org.etsi.mts.tdl.StructuredDataType" exception frequently. As you can see below, there is no reference to my code in the stack and it seems the exception is thrown from somewhere else (I also checked my code several times to make sure everything is fine). It should be noted that without changing anything in my TDL code and just by cleaning the project and refreshing the workspace, the problem disappears!! so I am very confused about it.
!ENTRY org.eclipse.xtext.ui 4 0 2021-05-17 11:54:38.705
!MESSAGE Error updating dirty state editor
!STACK 0
org.eclipse.emf.common.util.WrappedException: java.lang.ClassCastException: class org.etsi.mts.tdl.impl.SimpleDataTypeImpl cannot be cast to class org.etsi.mts.tdl.StructuredDataType (org.etsi.mts.tdl.impl.SimpleDataTypeImpl and org.etsi.mts.tdl.StructuredDataType are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @729ecd74)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:245)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doResolveLazyCrossReference(LazyLinkingResource.java:204)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReference(LazyLinkingResource.java:163)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReferences(LazyLinkingResource.java:149)
at org.eclipse.xtext.EcoreUtil2.resolveLazyCrossReferences(EcoreUtil2.java:505)
at org.eclipse.xtext.resource.impl.DefaultResourceDescription.computeReferenceDescriptions(DefaultResourceDescription.java:136)
at org.eclipse.xtext.resource.impl.DefaultResourceDescription$2.get(DefaultResourceDescription.java:124)
at org.eclipse.xtext.resource.impl.DefaultResourceDescription$2.get(DefaultResourceDescription.java:121)
at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:76)
at org.eclipse.xtext.resource.impl.DefaultResourceDescription.getReferenceDescriptions(DefaultResourceDescription.java:121)
at org.eclipse.xtext.resource.DescriptionUtils.collectOutgoingReferences(DescriptionUtils.java:30)
at org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager.isAffected(DefaultResourceDescriptionManager.java:123)
at org.eclipse.xtext.ui.editor.DirtyStateEditorSupport.isReparseRequired(DirtyStateEditorSupport.java:663)
at org.eclipse.xtext.ui.editor.DirtyStateEditorSupport$UpdateEditorStateJob$1.exec(DirtyStateEditorSupport.java:162)
at org.eclipse.xtext.ui.editor.DirtyStateEditorSupport$UpdateEditorStateJob$1.exec(DirtyStateEditorSupport.java:1)
at org.eclipse.xtext.util.concurrent.IReadAccess.lambda$tryReadOnly$0(IReadAccess.java:57)
at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:70)
at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.internalReadOnly(XtextDocument.java:525)
at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.readOnly(XtextDocument.java:497)
at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:136)
at org.eclipse.xtext.util.concurrent.IReadAccess.tryReadOnly(IReadAccess.java:53)
at org.eclipse.xtext.util.concurrent.IReadAccess.tryReadOnly(IReadAccess.java:71)
at org.eclipse.xtext.ui.editor.DirtyStateEditorSupport$UpdateEditorStateJob.run(DirtyStateEditorSupport.java:147)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)