Skip to content

Commit

Permalink
More API reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Jun 6, 2024
1 parent 7a14718 commit 8df8bb7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 23 deletions.
21 changes: 0 additions & 21 deletions eithernet/api/eithernet.api
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ public final class com/slack/eithernet/ExtensionsKt {
public abstract interface annotation class com/slack/eithernet/InternalEitherNetApi : java/lang/annotation/Annotation {
}

public final class com/slack/eithernet/KTypesKt {
public static final fun canonicalize (Lkotlin/reflect/KType;)Lkotlin/reflect/KType;
}

public abstract interface annotation class com/slack/eithernet/ResultType : java/lang/annotation/Annotation {
public abstract fun isArray ()Z
public abstract fun ownerType ()Ljava/lang/Class;
Expand All @@ -106,23 +102,6 @@ public final class com/slack/eithernet/TagsKt {
public static final fun tag (Lcom/slack/eithernet/ApiResult;Lkotlin/reflect/KClass;)Ljava/lang/Object;
}

public final class com/slack/eithernet/Types {
public static final field INSTANCE Lcom/slack/eithernet/Types;
public static final fun arrayOf (Ljava/lang/reflect/Type;)Ljava/lang/reflect/GenericArrayType;
public static final fun equals (Ljava/lang/reflect/Type;Ljava/lang/reflect/Type;)Z
public static final fun getRawType (Ljava/lang/reflect/Type;)Ljava/lang/Class;
public static final fun newParameterizedType (Ljava/lang/reflect/Type;[Ljava/lang/reflect/Type;)Ljava/lang/reflect/ParameterizedType;
public static final fun newParameterizedTypeWithOwner (Ljava/lang/reflect/Type;Ljava/lang/reflect/Type;[Ljava/lang/reflect/Type;)Ljava/lang/reflect/ParameterizedType;
public static final fun subtypeOf (Ljava/lang/reflect/Type;)Ljava/lang/reflect/WildcardType;
public static final fun supertypeOf (Ljava/lang/reflect/Type;)Ljava/lang/reflect/WildcardType;
}

public final class com/slack/eithernet/TypesKt {
public static final fun toKType (Ljava/lang/reflect/Type;ZLjava/util/List;)Lkotlin/reflect/KType;
public static synthetic fun toKType$default (Ljava/lang/reflect/Type;ZLjava/util/List;ILjava/lang/Object;)Lkotlin/reflect/KType;
public static final fun toKTypeProjection (Ljava/lang/reflect/Type;)Lkotlin/reflect/KTypeProjection;
}

public final class com/slack/eithernet/Util {
public static final fun resolve (Ljava/lang/reflect/Type;Ljava/lang/reflect/Type;Ljava/lang/Class;)Ljava/lang/reflect/Type;
}
Expand Down
1 change: 0 additions & 1 deletion eithernet/api/eithernet.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ final class com.slack.eithernet/ApiException : kotlin/Exception { // com.slack.e
final fun <get-error>(): kotlin/Any? // com.slack.eithernet/ApiException.error.<get-error>|<get-error>(){}[0]
}
final fun (com.slack.eithernet/ResultType).com.slack.eithernet/toKType(): kotlin.reflect/KType // com.slack.eithernet/toKType|[email protected](){}[0]
final fun (kotlin.reflect/KType).com.slack.eithernet/canonicalize(): kotlin.reflect/KType // com.slack.eithernet/canonicalize|[email protected](){}[0]
final fun (kotlin/Array<out kotlin/Annotation>).com.slack.eithernet/errorType(): kotlin/Pair<com.slack.eithernet/ResultType, kotlin/Array<kotlin/Annotation>>? // com.slack.eithernet/errorType|[email protected]<out|kotlin.Annotation>(){}[0]
final fun (kotlin/Array<out kotlin/Annotation>).com.slack.eithernet/statusCode(): kotlin/Pair<com.slack.eithernet/StatusCode, kotlin/Array<kotlin/Annotation>>? // com.slack.eithernet/statusCode|[email protected]<out|kotlin.Annotation>(){}[0]
final fun <#A: kotlin/Any, #B: kotlin/Any> (com.slack.eithernet/ApiResult<#A, #B>).com.slack.eithernet/successOrNull(): #A? // com.slack.eithernet/successOrNull|[email protected]<0:0,0:1>(){0§<kotlin.Any>;1§<kotlin.Any>}[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ internal expect class KTypeImpl(
annotations: List<Annotation>,
) : KType, EitherNetKType

@InternalEitherNetApi
public fun KType.canonicalize(): KType {
return when (this) {
is KTypeImpl -> this
Expand Down
3 changes: 3 additions & 0 deletions eithernet/src/jvmMain/kotlin/com/slack/eithernet/Types.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ internal fun Type.asArrayType(): GenericArrayType = Types.arrayOf(this)
* [wildcards][WildcardType] are stripped away in [type projections][KTypeProjection] as they are
* not relevant for serialization and are also not standalone [KType] subtypes in Kotlin.
*/
@InternalEitherNetApi
public fun Type.toKType(
isMarkedNullable: Boolean = true,
annotations: List<Annotation> = emptyList(),
Expand Down Expand Up @@ -70,6 +71,7 @@ public fun Type.toKType(
}

/** Creates a new [KTypeProjection] representation of this [Type] for use in [KType.arguments]. */
@InternalEitherNetApi
public fun Type.toKTypeProjection(): KTypeProjection {
return when (this) {
is Class<*>,
Expand All @@ -94,6 +96,7 @@ public fun Type.toKTypeProjection(): KTypeProjection {
}

/** Factory methods for types. */
@InternalEitherNetApi
public object Types {
/**
* Returns a new parameterized type, applying `typeArguments` to `rawType`. Use this method if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
*/
package com.slack.eithernet.test

import com.slack.eithernet.InternalEitherNetApi
import com.slack.eithernet.canonicalize
import kotlin.coroutines.Continuation
import kotlin.reflect.KType

/** A simple parameter endpoint key for use with [EndpointKey]. */
public class ParameterKey internal constructor(type: KType) {

private val type = type.canonicalize()
@OptIn(InternalEitherNetApi::class) private val type = type.canonicalize()

override fun equals(other: Any?): Boolean {
if (this === other) return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
*/
package com.slack.eithernet.test

import com.slack.eithernet.InternalEitherNetApi
import com.slack.eithernet.toKType
import java.lang.reflect.Method

@OptIn(InternalEitherNetApi::class)
@PublishedApi
internal fun EndpointKey.Companion.create(method: Method): EndpointKey {
return EndpointKey(
Expand Down

0 comments on commit 8df8bb7

Please sign in to comment.