blob: ee7aa41c27cf5377974a267fd8c8c7cb1fa9ffb2 [file] [log] [blame]
// Copyright (c) 2022, the R8 project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.graph.proto;
import com.android.tools.r8.graph.AppView;
import com.android.tools.r8.graph.DexType;
import com.android.tools.r8.graph.lens.GraphLens;
import com.android.tools.r8.ir.analysis.value.SingleValue;
import com.android.tools.r8.shaking.AppInfoWithLiveness;
import java.util.Objects;
public class RemovedReceiverInfo extends RemovedArgumentInfo {
RemovedReceiverInfo(SingleValue singleValue, DexType type) {
super(singleValue, type);
}
@Override
public boolean isRemovedReceiverInfo() {
return true;
}
@Override
@SuppressWarnings("ReferenceEquality")
public RemovedReceiverInfo rewrittenWithLens(
AppView<AppInfoWithLiveness> appView, GraphLens graphLens, GraphLens codeLens) {
DexType rewrittenType = graphLens.lookupType(getType(), codeLens);
SingleValue rewrittenSingleValue =
hasSingleValue()
? getSingleValue().rewrittenWithLens(appView, rewrittenType, graphLens, codeLens)
: null;
if (rewrittenSingleValue != getSingleValue() || rewrittenType != getType()) {
return new RemovedReceiverInfo(rewrittenSingleValue, rewrittenType);
}
return this;
}
@Override
@SuppressWarnings({"EqualsGetClass", "ReferenceEquality"})
public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
RemovedReceiverInfo other = (RemovedReceiverInfo) obj;
return getType() == other.getType() && Objects.equals(getSingleValue(), other.getSingleValue());
}
@Override
public int hashCode() {
return Objects.hash(getSingleValue(), getType());
}
public static class Builder extends BuilderBase<Builder> {
public static Builder create() {
return new Builder();
}
public RemovedReceiverInfo build() {
return new RemovedReceiverInfo(singleValue, type);
}
@Override
Builder self() {
return this;
}
}
}