eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

[ocl25] Remove the UnlimitedNatural to Integer conformance #1340

Closed eclipse-ocl-bot closed 1 month ago

eclipse-ocl-bot commented 1 month ago

| --- | --- | | Bugzilla Link | 437661 | | Status | RESOLVED FIXED | | Importance | P3 normal | | Reported | Jun 18, 2014 05:40 EDT | | Modified | Sep 09, 2017 13:20 EDT | | Reporter | Ed Willink |

Description

Make UnlimitedNatural an isolated 'enumeration' type.

Useable only via Integer.toUnlimitedNatural(), UnlimitedNatural.toInteger().

eclipse-ocl-bot commented 1 month ago

By Ed Willink on Jun 18, 2014 05:50

(In reply to Ed Willink from comment #0)

Useable only via Integer.toUnlimitedNatural(), UnlimitedNatural.toInteger().

This causes about 30 failures on UML 2.5's OCL.

Typically on "is(1,1)" which now requires is(Integer,Integer) where is(Integer,UnlimitedNatural) is available.

? synthesize "is(1,1.toUnlimitedNatural())" as a disambiguation and potentially optimize as an UnlimitedNaturalExp in the AST.

? NumericLiterals are a superposition of alternative types allowing a deferred type matching selection.

eclipse-ocl-bot commented 1 month ago

By Ed Willink on Jun 18, 2014 06:13

(In reply to Ed Willink from comment #1)

? NumericLiterals are a superposition of alternative types allowing a deferred type matching selection.

No. Sometimes the deferred decision cannot be made. e.g. "1.oclType()" must have only one answer.

? synthesize "is(1,1.toUnlimitedNatural())" as a disambiguation and potentially optimize as an UnlimitedNaturalExp in the AST.

How is this modelled?

Define the single argument constructor static UnlimitedNatural(Integer).

Single argument constructors may be invoked automatically to perform type conversions for assignments and arguments.

eclipse-ocl-bot commented 1 month ago

By Ed Willink on Dec 08, 2014 16:28

Constructor-based coercions are difficult to resolve, since discovery of a coercion requires analysis of all potential types for a suitable constructor.

Complete OCL allows class complements so there is no particular problem in injecting a coercion in the source type.

In practice we only need Integer to UnlimitedNatural. We can generalize this to a limited modeling capability by allowing PrimitiveType::coercions to enumerate ownedOperations that can be used to coerce.

So a variant "operation" syntax for OCLstdlib to define a "coercion" that populates PrimitiveType::coercions.

Operation resolution requires multiple extension.s. If no operation can be found, try coercing the source type.

Once an operation has been found try coercing arguments that do not conform.

Coercion is just a wrapping OperationCallExp for the coercion operation.

Pushed to ewillink/ocl25

eclipse-ocl-bot commented 1 month ago

By Ed Willink on Sep 09, 2017 13:20

(In reply to Ed Willink from comment #3)

Pushed to ewillink/ocl25

Since making UML's OCL validation part of JUnit tests again two integer-literals need an oclAsType(UnlimitedNatural).

Additional coercion support added.