loonwerks / formal-methods-workbench

Other
20 stars 7 forks source link

Resolute builtin operator 'type' throws class cast exception on FeatureInstance #26

Closed reteprelief closed 5 years ago

reteprelief commented 5 years ago

If you invoke type(p) where p is a FeatureInstance for an EventDataPort a class cast exception is thrown.

The problem is the code in the method builtinType in the class ResoluteBuiltInFnCallEvaluator.

In the conditional branch of ne instanceof FeatureInstance the code test 'feature' for a class but then casts 'ne' to that class. The correct code should be: } else if (ne instanceof FeatureInstance) { FeatureInstance fi = (FeatureInstance) ne; Feature feature = fi.getFeature(); if (feature instanceof DataPort) { DataPort dp = (DataPort) feature; return dp.getDataFeatureClassifier(); } else if (feature instanceof EventDataPort) { EventDataPort dp = (EventDataPort) feature; return dp.getDataFeatureClassifier(); } else if (feature instanceof DataAccess) { DataAccess dp = (DataAccess) feature; return dp.getDataFeatureClassifier(); } else if (feature instanceof BusAccess) { BusAccess dp = (BusAccess) feature; BusFeatureClassifier val = dp.getBusFeatureClassifier(); if (val instanceof BusClassifier) { return (BusClassifier) val; } } else if (ne instanceof Feature) { Feature dp = feature; FeatureClassifier val = dp.getFeatureClassifier(); if (val instanceof ComponentClassifier) { return (ComponentClassifier) val; } }else if(feature instanceof FeatureGroup){ FeatureGroup featGroup = (FeatureGroup)feature; return featGroup.getAllFeatureGroupType(); }

I will also submit the correction as pull request. Peter Feiler

reteprelief commented 5 years ago

I am not permitted to push a branch with the correction, so you have to pick up the correction from the text above.

iamundson commented 5 years ago

Fix applied.