@ Check public void checkDefaultValueTypeCompatibleWithParameterType ( SarlFormalParameter param ) { final XExpression defaultValue = param . getDefaultValue ( ) ; if ( defaultValue != null ) { final JvmTypeReference rawType = param . getParameterType ( ) ; assert rawType != null ; final LightweightTypeReference toType = toLightweightTypeReference ( rawType , true ) ; if ( toType == null ) { error ( MessageFormat . format ( Messages . SARLValidator_20 , param . getName ( ) ) , param , XtendPackage . Literals . XTEND_PARAMETER__PARAMETER_TYPE , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , INVALID_TYPE ) ; return ; } LightweightTypeReference fromType = getExpectedType ( defaultValue ) ; if ( fromType == null ) { fromType = getActualType ( defaultValue ) ; if ( fromType == null ) { error ( MessageFormat . format ( Messages . SARLValidator_21 , param . getName ( ) ) , param , SARL_FORMAL_PARAMETER__DEFAULT_VALUE , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , INVALID_TYPE ) ; return ; } } if ( ! Utils . canCast ( fromType , toType , true , false , true ) ) { error ( MessageFormat . format ( Messages . SARLValidator_38 , getNameOfTypes ( fromType ) , canonicalName ( toType ) ) , param , SARL_FORMAL_PARAMETER__DEFAULT_VALUE , ValidationMessageAcceptor . INSIGNIFICANT_INDEX , INCOMPATIBLE_TYPES , canonicalName ( fromType ) , canonicalName ( toType ) ) ; } } }
Check if the default values of the formal parameters have a compatible type with the formal parameter .