package jetbrains.mps.kotlin.smartcast;

/*Generated by MPS */

import jetbrains.mps.kotlin.behavior.TypeReference;
import org.jetbrains.mps.openapi.model.SNode;
import java.util.Objects;

/**
 * Special type reference that is not really a type.
 * Specific to smart cast analysis
 * 
 * see https://kotlinlang.org/spec/type-inference.html#smart-cast-transfer-functions
 */
public class IsNullableTypeReference implements TypeReference {
  private final TypeReference myType;
  public IsNullableTypeReference(TypeReference type) {
    myType = type;
  }
  @Override
  public SNode compute() {
    throw new IllegalStateException("not meant to be used outside typesystem");
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    IsNullableTypeReference reference = as_ks0q37_a0a1a4(o, IsNullableTypeReference.class);
    return (reference != null ? Objects.equals(reference.myType, myType) : false);
  }

  @Override
  public int hashCode() {
    return myType.hashCode();
  }
  private static <T> T as_ks0q37_a0a1a4(Object o, Class<T> type) {
    return (type.isInstance(o) ? (T) o : null);
  }
}
