package org.reasm;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;

/**
 * A value that references a function.
 *
 * @author Francis Gagné
 */
@Immutable
public final class FunctionValue extends Value {

    @Nonnull
    private final Function function;

    /**
     * Initializes a new FunctionValue.
     *
     * @param function
     *            the function
     */
    public FunctionValue(@Nonnull Function function) {
        if (function == null) {
            throw new NullPointerException("function");
        }

        this.function = function;
    }

    @Override
    public final boolean equals(@CheckForNull Object obj) {
        if (this == obj) {
            return true;
        }

        if (obj == null) {
            return false;
        }

        if (this.getClass() != obj.getClass()) {
            return false;
        }

        if (!this.function.equals(((FunctionValue) obj).function)) {
            return false;
        }

        return true;
    }

    @Override
    public final int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + System.identityHashCode(this.function);
        return result;
    }

    @Nonnull
    @Override
    public final String toString() {
        return "FunctionValue [function=" + this.function + "]";
    }

    @Override
    final <T> T accept(@Nonnull ValueVisitor<T> visitor) {
        return visitor.visitFunction(this.function);
    }

}

@@ -622,32 +622,165 @@
 unction;%0A    %7D%0A%0A
+    @Override%0A    final %3CT%3E T accept(@Nonnull ValueVisitor%3CT%3E visitor) %7B%0A        return visitor.visitFunction(this.function);%0A    %7D%0A%0A
     @Override%0A  
@@ -1324,32 +1324,8 @@
 t + 
-System.identityHashCode(
 this
@@ -1329,24 +1329,34 @@
 his.function
+.hashCode(
 );%0A        r
@@ -1436,24 +1436,24 @@
 oString() %7B%0A
+
         retu
@@ -1516,139 +1516,6 @@
  %7D%0A%0A
-    @Override%0A    final %3CT%3E T accept(@Nonnull ValueVisitor%3CT%3E visitor) %7B%0A        return visitor.visitFunction(this.function);%0A    %7D%0A%0A
 %7D%0A

Implement FunctionValue.hashCode() consistently with equals()