package kotlin.reflect.jvm.internal;

import defpackage.kp6;
import defpackage.pq6;
import defpackage.qq3;
import java.lang.ref.SoftReference;

/* JADX INFO: loaded from: classes3.dex */
public class ReflectProperties {

    public static class LazySoftVal<T> extends Val<T> implements qq3<T> {
        private final qq3<T> initializer;
        private volatile SoftReference<Object> value;

        private static /* synthetic */ void $$$reportNull$$$0(int i) {
            throw new IllegalArgumentException("Argument for @NotNull parameter 'initializer' of kotlin/reflect/jvm/internal/ReflectProperties$LazySoftVal.<init> must not be null");
        }

        public LazySoftVal(@pq6 T t, @kp6 qq3<T> qq3Var) {
            if (qq3Var == null) {
                $$$reportNull$$$0(0);
            }
            this.value = null;
            this.initializer = qq3Var;
            if (t != null) {
                this.value = new SoftReference<>(escape(t));
            }
        }

        @Override // kotlin.reflect.jvm.internal.ReflectProperties.Val, defpackage.qq3
        public T invoke() {
            Object obj;
            SoftReference<Object> softReference = this.value;
            if (softReference != null && (obj = softReference.get()) != null) {
                return unescape(obj);
            }
            T t = (T) this.initializer.invoke();
            this.value = new SoftReference<>(escape(t));
            return t;
        }
    }

    public static abstract class Val<T> {
        private static final Object NULL_VALUE = new Object() { // from class: kotlin.reflect.jvm.internal.ReflectProperties.Val.1
        };

        public Object escape(T t) {
            return t == null ? NULL_VALUE : t;
        }

        public final T getValue(Object obj, Object obj2) {
            return invoke();
        }

        public abstract T invoke();

        /* JADX WARN: Multi-variable type inference failed */
        public T unescape(Object obj) {
            if (obj == NULL_VALUE) {
                return null;
            }
            return obj;
        }
    }

    private static /* synthetic */ void $$$reportNull$$$0(int i) {
        throw new IllegalArgumentException("Argument for @NotNull parameter 'initializer' of kotlin/reflect/jvm/internal/ReflectProperties.lazySoft must not be null");
    }

    @kp6
    public static <T> LazySoftVal<T> lazySoft(@pq6 T t, @kp6 qq3<T> qq3Var) {
        if (qq3Var == null) {
            $$$reportNull$$$0(0);
        }
        return new LazySoftVal<>(t, qq3Var);
    }

    @kp6
    public static <T> LazySoftVal<T> lazySoft(@kp6 qq3<T> qq3Var) {
        if (qq3Var == null) {
            $$$reportNull$$$0(1);
        }
        return lazySoft(null, qq3Var);
    }
}
