/** Replies if the type candidate is a subtype of the given super type. * * @param candidate the type to test. * @param jvmSuperType the expected JVM super-type. * @param sarlSuperType the expected SARL super-type. * @return <code>true</code> if the candidate is a sub-type of the super-type. */ public boolean isSubTypeOf(LightweightTypeReference candidate, Class<?> jvmSuperType, Class<? extends XtendTypeDeclaration> sarlSuperType) { if (candidate.isSubtypeOf(jvmSuperType)) { return true; } if (sarlSuperType != null) { final JvmType type = candidate.getType(); if (type instanceof JvmGenericType) { final JvmGenericType genType = (JvmGenericType) type; if (genType.getSuperTypes().isEmpty()) { for (final EObject sarlObject : this.sarlAssociations.getSourceElements(type)) { if (sarlSuperType.isInstance(sarlObject)) { return true; } } } } } return false; }
@Override protected JvmOperation deriveGenericDispatchOperationSignature( Iterable<JvmOperation> localOperations, JvmGenericType target) { final JvmOperation dispatcher = super.deriveGenericDispatchOperationSignature(localOperations, target); // // Fixing the behavior for determining the visibility of the dispatcher since // it does not fit the SARL requirements. // JvmVisibility higherVisibility = JvmVisibility.PRIVATE; for (final JvmOperation jvmOperation : localOperations) { final Iterable<XtendFunction> xtendFunctions = Iterables.filter( this.sarlAssociations.getSourceElements(jvmOperation), XtendFunction.class); for (final XtendFunction func : xtendFunctions) { JvmVisibility visibility = func.getVisibility(); if (visibility == null) { visibility = this.defaultVisibilityProvider.getDefaultJvmVisibility(func); } if (this.visibilityComparator.compare(visibility, higherVisibility) > 0) { higherVisibility = visibility; } } } dispatcher.setVisibility(higherVisibility); return dispatcher; }