blob: cd6fcbf56cf05313da730a50a69d01400a66fb7a [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;
Christoffer Quist Adamsen7e2a9d42023-03-28 13:05:04 +02009import com.android.tools.r8.graph.lens.NonIdentityGraphLens;
Christoffer Quist Adamsen9684aa32021-01-21 16:32:29 +010010import 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
Christoffer Quist Adamseneb5af052021-02-19 08:27:05 +010037 SyntheticClasspathClassReference internalRewrite(
38 SynthesizingContext rewrittenContext, NonIdentityGraphLens lens) {
Christoffer Quist Adamsen9684aa32021-01-21 16:32:29 +010039 assert type == lens.lookupType(type)
40 : "Unexpected classpath rewrite of type " + type.toSourceString();
Christoffer Quist Adamseneb5af052021-02-19 08:27:05 +010041 assert getContext() == rewrittenContext
42 : "Unexpected classpath rewrite of context type " + getContext();
Christoffer Quist Adamsen9684aa32021-01-21 16:32:29 +010043 return this;
44 }
45}