public override bool CanCastTo(IType other) { if (other is ArrayType) { return(_baseType.CanCastTo(((ArrayType)other)._baseType)); } else { return(base.CanCastTo(other)); } }
/// <summary> /// Verifies whether the return type matches the function return type. /// </summary> /// <param name="actualReturnType">The type of the value which is returned.</param> /// <param name="definedReturnType">The type of the function specified in the function signature.</param> /// <param name="positionInSourceCode">The current position of the token in the source code. Used for throwing exceptions.</param> protected void VerifyReturnType(IType actualReturnType, IType definedReturnType, long positionInSourceCode) { if (object.ReferenceEquals(null, actualReturnType)) { if (!object.ReferenceEquals(null, definedReturnType)) { throw new CompileException(positionInSourceCode, "Function does not return a value"); } } else if (object.ReferenceEquals(null, definedReturnType)) { throw new CompileException(positionInSourceCode, "Function must not return a value"); } else if (!actualReturnType.CanCastTo(definedReturnType)) { throw new CompileException(positionInSourceCode, "Function return value does not match definition"); } }