eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

[pivot] Inadequate UnlimitedNatural CG #2144

Open eclipse-ocl-bot opened 1 week ago

eclipse-ocl-bot commented 1 week ago

| --- | --- | | Bugzilla Link | 570809 | | Status | NEW | | Importance | P3 normal | | Reported | Feb 01, 2021 06:19 EDT | | Modified | Feb 04, 2021 03:59 EDT | | Reporter | Ed Willink |

Description

https://www.eclipse.org/forums/index.php/m/1837508/#msg_1837508 makes some inaccurate observations about UnlimitedNatural CG, but...

Extending the UsageTests to have some UnlimitedNatural cover after progressing Bug570717 reveals the use of BigInteger and some paarsing issues.

Incompatible type 'UnlimitedNatural' for «body» 'bug412736::EcoreUnlimitedNatural::flip'\ org.eclipse.emf.ecore.impl.EStringToStringMapEntryImpl@27a7ef08 (key: body, value: if b = then 1 else endif)\

As a minimum the messages shoukd be better.

eclipse-ocl-bot commented 1 week ago

By Ed Willink on Feb 03, 2021 09:54

It looks as if dropping the inheritance of UnlimitedNatural from Integer didn't get implemented by the CG. Consequently "1" is treated as an UnlimitedNatural. It now needs a conversion to avoid a UnlimitedNaturalValue is not an IntegerValue CCE.

eclipse-ocl-bot commented 1 week ago

By Ed Willink on Feb 04, 2021 03:59

It should be easy. The Pivot OCL parser already synthesizes toUnlimitedNatural() calls in the AS when a coercion is necessary to emulate the former inheritance.

Unfortunately the CG relies on the free casting of Integervalue to UnlimitedNatural value and so avoid distiny constants for integer/unlimited natural "1". Doubling up to synthesize UnlimitedNatural constants and to use unlimitedNaturalValueOf() in a couple of places and everything works. But unlimitedNaturalValueOf(-1) has to return UNLIMITED rather than invalid.

However EMF has a -2 (UNSPECIFIED) as well as a -1 (UNBOUNDED) multiplicity that is used in the XMLType.ecore RoundTripTest. This now fails with the -2 getting converted to -1 somewhere. Yuk! A ripple.