blob: 5b9ba3cfc29ec3ac6b3aeaeb38f060f82ce249de [file] [log] [blame]
Christoffer Quist Adamsen9684aa32021-01-21 16:32:29 +01001// Copyright (c) 2020, the R8 project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4package com.android.tools.r8.synthesis;
5
6import com.android.tools.r8.graph.DexClass;
7import com.android.tools.r8.graph.DexClasspathClass;
8import com.android.tools.r8.graph.DexType;
9import com.android.tools.r8.graph.GraphLens.NonIdentityGraphLens;
10import com.android.tools.r8.synthesis.SyntheticNaming.SyntheticKind;
11import java.util.function.Function;
12
13/**
14 * Reference to a synthetic class item.
15 *
16 * <p>This class is internal to the synthetic items collection, thus package-protected.
17 */
18class SyntheticClasspathClassReference
19 extends SyntheticClassReference<
20 SyntheticClasspathClassReference, SyntheticClasspathClassDefinition, DexClasspathClass> {
21
22 SyntheticClasspathClassReference(SyntheticKind kind, SynthesizingContext context, DexType type) {
23 super(kind, context, type);
24 }
25
26 @Override
27 SyntheticClasspathClassDefinition lookupDefinition(Function<DexType, DexClass> definitions) {
28 DexClass clazz = definitions.apply(type);
29 if (clazz == null) {
30 return null;
31 }
32 assert clazz.isClasspathClass();
33 return new SyntheticClasspathClassDefinition(getKind(), getContext(), clazz.asClasspathClass());
34 }
35
36 @Override
37 SyntheticClasspathClassReference rewrite(NonIdentityGraphLens lens) {
38 assert type == lens.lookupType(type)
39 : "Unexpected classpath rewrite of type " + type.toSourceString();
40 return this;
41 }
42}