Skip to content

Commit

Permalink
WIP - Enable parameter() DSL to be extended
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWoodworth committed Jan 4, 2024
1 parent daa3149 commit fc36aa0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions api/parameterize.api
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
public abstract interface annotation class com/benwoodworth/parameterize/ExperimentalParameterizeApi : java/lang/annotation/Annotation {
}

public final class com/benwoodworth/parameterize/ParameterizeConfiguration {
public static final field Companion Lcom/benwoodworth/parameterize/ParameterizeConfiguration$Companion;
public final fun getDecorator ()Lkotlin/jvm/functions/Function3;
Expand Down Expand Up @@ -94,9 +97,11 @@ public final class com/benwoodworth/parameterize/ParameterizeScope {

public final class com/benwoodworth/parameterize/ParameterizeScope$Parameter {
public static final synthetic fun box-impl (Lkotlin/sequences/Sequence;)Lcom/benwoodworth/parameterize/ParameterizeScope$Parameter;
public static fun constructor-impl (Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
public fun equals (Ljava/lang/Object;)Z
public static fun equals-impl (Lkotlin/sequences/Sequence;Ljava/lang/Object;)Z
public static final fun equals-impl0 (Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;)Z
public final fun getArguments ()Lkotlin/sequences/Sequence;
public fun hashCode ()I
public static fun hashCode-impl (Lkotlin/sequences/Sequence;)I
public fun toString ()Ljava/lang/String;
Expand Down
7 changes: 7 additions & 0 deletions src/commonMain/kotlin/Annotations.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.benwoodworth.parameterize

@Retention(AnnotationRetention.BINARY)
@SinceKotlin("1.3")
@RequiresOptIn
@MustBeDocumented
public annotation class ExperimentalParameterizeApi
13 changes: 10 additions & 3 deletions src/commonMain/kotlin/Parameterize.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public class ParameterizeScope internal constructor(
* ```
*/
public fun <T> parameter(arguments: Sequence<T>): Parameter<T> =
@OptIn(ExperimentalParameterizeApi::class)
Parameter(arguments)

/** @suppress */
Expand All @@ -156,10 +157,16 @@ public class ParameterizeScope internal constructor(
}


/** @suppress */
/**
* @constructor
* **Experimental:** Prefer using the scope-limited [parameter] function instead, if possible.
* The constructor will be made `@PublishedApi internal` once context receivers are introduced to the language.
*
* @suppress
*/
@JvmInline
public value class Parameter<out T> internal constructor(
internal val arguments: Sequence<T>
public value class Parameter<out T> @ExperimentalParameterizeApi constructor(
public val arguments: Sequence<T>
)

/** @suppress */
Expand Down

0 comments on commit fc36aa0

Please sign in to comment.