public override object Exec(NullType firstOperand, object arg) { // * Built-in types: no promotion, except string if (this.secondOperand is BoolType || this.secondOperand is CharType || this.secondOperand is DoubleType || this.secondOperand is IntType || this.secondOperand is VoidType) { return(-1); } // * BCL Value Types (structs): No promotion BCLClassType bclClass = TypeExpression.As <BCLClassType>(this.secondOperand); if (bclClass != null) { if (bclClass.TypeInfo.IsValueType) { return(-1); } // * Correct promotion to classes that are not value types return(0); } // * WriteType variable TypeVariable typeVariable = this.secondOperand as TypeVariable; if (typeVariable != null) { if (typeVariable.Substitution != null) { // * If the variable is bounded, the promotion is the one of its substitution return(firstOperand.AcceptOperation(new PromotionLevelOperation(typeVariable.EquivalenceClass.Substitution), arg)); } // * A free variable is complete promotion return(0); } // * Union type UnionType unionType = TypeExpression.As <UnionType>(this.secondOperand); if (unionType != null) { return(unionType.SuperType(firstOperand)); } // * Field type and bounded type variable FieldType fieldType = TypeExpression.As <FieldType>(this.secondOperand); if (fieldType != null) { return(firstOperand.AcceptOperation(new PromotionLevelOperation(fieldType.FieldTypeExpression), arg)); } // * Correct Promotion return(0); }