- if (target is EventExpr) {
- EventInfo ei = ((EventExpr) target).EventInfo;
-
- Expression ml = MemberLookup (
- ec.ContainerType, ec.ContainerType, ei.Name,
- MemberTypes.Event, AllBindingFlags | BindingFlags.DeclaredOnly, loc);
-
- if (ml == null) {
- //
- // If this is the case, then the Event does not belong
- // to this Type and so, according to the spec
- // is allowed to only appear on the left hand of
- // the += and -= operators
- //
- // Note that target will not appear as an EventExpr
- // in the case it is being referenced within the same type container;
- // it will appear as a FieldExpr in that case.
- //
-
- if (!(source is BinaryDelegate)) {
- error70 (ei, loc);
- return null;
- }
- }
- }
-
- if (!(target is IAssignMethod) && (target.eclass != ExprClass.EventAccess)) {
- Error_ValueAssignment (loc);
- return null;
- }
-
- if ((source.eclass == ExprClass.Type) && (source is TypeExpr)) {
- source.Error_UnexpectedKind (ec.DeclContainer, "variable or value", loc);
- return null;
- } else if ((RootContext.Version == LanguageVersion.ISO_1) &&
- (source is MethodGroupExpr)){
- ((MethodGroupExpr) source).ReportUsageError ();
- return null;
-
- }
-
- if (target_type == source_type) {
- if (target.eclass == ExprClass.Variable) {
- New n = source as New;
- if (n == null)
- return this;
-
- if (n.HasInitializer) {
- n.SetTargetVariable (target);
- } else if (target_type.IsValueType) {
- n.SetTargetVariable (target);
- return n;
- }
- }
-
- return this;
- }
-
- //
- // If this assignment/operator was part of a compound binary
- // operator, then we allow an explicit conversion, as detailed
- // in the spec.
- //
-
- if (this is CompoundAssign){
- CompoundAssign a = (CompoundAssign) this;
-
- Binary b = source as Binary;
- if (b != null){
- //
- // 1. if the source is explicitly convertible to the
- // target_type
- //
-
- source = Convert.ExplicitConversion (ec, source, target_type, loc);
- if (source == null){
- a.original_source.Error_ValueCannotBeConverted (ec, loc, target_type, true);
- return null;
- }
-
- //
- // 2. and the original right side is implicitly convertible to
- // the type of target
- //
- if (Convert.ImplicitConversionExists (ec, a.original_source, target_type))
- return this;
-
- //
- // In the spec 2.4 they added: or if type of the target is int
- // and the operator is a shift operator...
- //
- if (source_type == TypeManager.int32_type &&
- (b.Oper == Binary.Operator.LeftShift || b.Oper == Binary.Operator.RightShift))
- return this;
-
- a.original_source.Error_ValueCannotBeConverted (ec, loc, target_type, false);
- return null;
- }
- }
-
- if (source.eclass == ExprClass.MethodGroup && !TypeManager.IsDelegateType (target_type)) {
- Report.Error (428, source.Location, "Cannot convert method group `{0}' to non-delegate type `{1}'. Did you intend to invoke the method?",
- ((MethodGroupExpr)source).Name, target.GetSignatureForError ());