blob: d05e123ab227b2eeaa1b5d9158765e079e46124d [file] [log] [blame]
// Copyright (c) 2021, 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.diagnostic;
import com.android.tools.r8.Keep;
import com.android.tools.r8.origin.Origin;
/** A context that references a missing definition in the program, classpath, or library. */
@Keep
public interface DefinitionContext {
/** The origin of the context. */
Origin getOrigin();
/** Predicate that is true iff this is an instance of {@link DefinitionClassContext}. */
default boolean isClassContext() {
return false;
}
/** Predicate that is true iff this is an instance of {@link DefinitionFieldContext}. */
default boolean isFieldContext() {
return false;
}
/** Predicate that is true iff this is an instance of {@link DefinitionMethodContext}. */
default boolean isMethodContext() {
return false;
}
/**
* Return a non-null {@link DefinitionClassContext} if this type is {@link
* DefinitionClassContext}.
*
* @return this with static type of {@link DefinitionClassContext}.
*/
default DefinitionClassContext asClassContext() {
return null;
}
/**
* Return a non-null {@link DefinitionFieldContext} if this type is {@link
* DefinitionFieldContext}.
*
* @return this with static type of {@link DefinitionFieldContext}.
*/
default DefinitionFieldContext asFieldContext() {
return null;
}
/**
* Return a non-null {@link DefinitionMethodContext} if this type is {@link
* DefinitionMethodContext}.
*
* @return this with static type of {@link DefinitionMethodContext}.
*/
default DefinitionMethodContext asMethodContext() {
return null;
}
}