| Summary: | Interface in EPackage with Classes with validation produces uncompilable ValidationClass | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Modeling] EMF | Reporter: | Axel Uhl <eclipse> | ||||
| Component: | Core | Assignee: | Ed Merks <Ed.Merks> | ||||
| Status: | RESOLVED WORKSFORME | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | ed | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Axel Uhl
I'm getting
public boolean validateA(Serializable a, DiagnosticChain diagnostics, Map<Object, Object> context)
{
return validate_EveryDefaultConstraint((EObject)a, diagnostics, context);
}
I.e., the instance is cast to EObject.
Please attach a test case rather than a description of how to produce one.
Note that I'm testing with EMF 2.6.
Created attachment 173374 [details]
Project reproducing the problem
I assume the problem originates from a specific set-up of a class in the OCL.ecore model: Visitor. It is configured as an interface, its generated version does for some reason not extend EObject.
The generator expects Visitor to extend EObject (it's a generated interface and it's GenModel specifies EObject as the Root Extends Interface) but the actual source code blocks merging so that's not actually the case. Of course a simple workaround is to specialize the generated code like this.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated not
*/
public boolean validateB(B<?, ?, ?, ?, ?, ?, ?, ?, ?, ?> b, DiagnosticChain diagnostics, Map<Object, Object> context) {
return validate_EveryDefaultConstraint((EObject)b, diagnostics, context);
}
When a package only contains interfaces, no validator seems to be generated at all. I was wondering why validation code is generated into the validator for interfaces if they appear in a package also containing non-interface classes. When there is at least one constraint on at least one of the classes (even pure interfaces can have constraints) a validator that covers all classes in the package is generated. This generated validator "overrides" the default validator (EObjectValidator) that's otherwise used and otherwise covers all classes in the package. |