Skip to content

Commit 91769d2

Browse files
authored
fix(abg): reinstate public copy method in binding classes (#1627)
Fixes #1626. A long-term approach is tracked in #1629.
1 parent 060e80b commit 91769d2

15 files changed

+53
-25
lines changed

.github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ println(Checkout(fetchTags_Untyped = "false"))
2828
println(AlwaysUntypedActionForTests_Untyped(foobar_Untyped = "baz"))
2929
println(ActionsSetupGradle())
3030
println(Cache(path = listOf("some-path"), key = "some-key"))
31+
32+
// Ensure that 'copy(...)' method is exposed.
33+
Checkout(fetchTags = false).copy(fetchTags = true)

action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ private fun TypeSpec.Builder.replaceWith(replaceWith: CodeBlock?): TypeSpec.Buil
390390
private fun TypeSpec.Builder.addClassConstructorAnnotation(): TypeSpec.Builder {
391391
addAnnotation(
392392
AnnotationSpec
393-
.builder(ConsistentCopyVisibility::class.asClassName())
393+
.builder(ExposedCopyVisibility::class.asClassName())
394394
.build(),
395395
)
396396
return this

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputs.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import io.github.typesafegithub.workflows.domain.actions.Action
1212
import io.github.typesafegithub.workflows.domain.actions.RegularAction
1313
import java.util.LinkedHashMap
1414
import kotlin.Boolean
15-
import kotlin.ConsistentCopyVisibility
15+
import kotlin.ExposedCopyVisibility
1616
import kotlin.Float
1717
import kotlin.Int
1818
import kotlin.String
@@ -59,7 +59,7 @@ import kotlin.collections.toTypedArray
5959
* @param _customVersion Allows overriding action's version, for example to use a specific minor
6060
* version, or a newer version that the binding doesn't yet know about
6161
*/
62-
@ConsistentCopyVisibility
62+
@ExposedCopyVisibility
6363
public data class ActionWithAllTypesOfInputs private constructor(
6464
/**
6565
* <required> Short description

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsTest.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,29 @@ class ActionWithAllTypesOfInputsTest : DescribeSpec({
141141
}
142142
exception.message shouldBe "Only listStrings or listStrings_Untyped must be set, but not both"
143143
}
144+
145+
it("exposes copy method") {
146+
// given
147+
val action = ActionWithAllTypesOfInputs(
148+
fooBar = "test",
149+
bazGoo = true,
150+
binKin = false,
151+
intPint = 43,
152+
floPint = 123.456f,
153+
finBin = ActionWithAllTypesOfInputs.Bin.BooBar,
154+
gooZen = ActionWithAllTypesOfInputs.Zen.Special1,
155+
bahEnum = ActionWithAllTypesOfInputs.BahEnum.HelloWorld,
156+
listStrings = listOf("hello", "world"),
157+
listInts = listOf(1, 42),
158+
listEnums = listOf(ActionWithAllTypesOfInputs.MyEnum.One, ActionWithAllTypesOfInputs.MyEnum.Three),
159+
listIntSpecial = listOf(ActionWithAllTypesOfInputs.MyInt.TheAnswer, ActionWithAllTypesOfInputs.MyInt.Value(0))
160+
)
161+
162+
// when
163+
@Suppress("DATA_CLASS_INVISIBLE_COPY_USAGE_WARNING")
164+
val actionWithOneChange = action.copy(fooBar = "another")
165+
166+
// then
167+
actionWithOneChange.fooBar shouldBe "another"
168+
}
144169
})

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputs_Untyped.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ package io.github.typesafegithub.workflows.actions.johnsmith
1111
import io.github.typesafegithub.workflows.domain.actions.Action
1212
import io.github.typesafegithub.workflows.domain.actions.RegularAction
1313
import java.util.LinkedHashMap
14-
import kotlin.ConsistentCopyVisibility
1514
import kotlin.Deprecated
15+
import kotlin.ExposedCopyVisibility
1616
import kotlin.String
1717
import kotlin.Suppress
1818
import kotlin.Unit
@@ -68,7 +68,7 @@ import kotlin.collections.toTypedArray
6868
"Use the typed class instead",
6969
ReplaceWith("ActionWithAllTypesOfInputs"),
7070
)
71-
@ConsistentCopyVisibility
71+
@ExposedCopyVisibility
7272
public data class ActionWithAllTypesOfInputs_Untyped private constructor(
7373
/**
7474
* Short description

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithDeprecatedInputAndNameClash.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ package io.github.typesafegithub.workflows.actions.johnsmith
1111
import io.github.typesafegithub.workflows.domain.actions.Action
1212
import io.github.typesafegithub.workflows.domain.actions.RegularAction
1313
import java.util.LinkedHashMap
14-
import kotlin.ConsistentCopyVisibility
14+
import kotlin.ExposedCopyVisibility
1515
import kotlin.String
1616
import kotlin.Suppress
1717
import kotlin.Unit
@@ -33,7 +33,7 @@ import kotlin.collections.toTypedArray
3333
* @param _customVersion Allows overriding action's version, for example to use a specific minor
3434
* version, or a newer version that the binding doesn't yet know about
3535
*/
36-
@ConsistentCopyVisibility
36+
@ExposedCopyVisibility
3737
public data class ActionWithDeprecatedInputAndNameClash private constructor(
3838
/**
3939
* <required> Foo bar - new

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithFancyCharsInDocs.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ package io.github.typesafegithub.workflows.actions.johnsmith
1111
import io.github.typesafegithub.workflows.domain.actions.Action
1212
import io.github.typesafegithub.workflows.domain.actions.RegularAction
1313
import java.util.LinkedHashMap
14-
import kotlin.ConsistentCopyVisibility
14+
import kotlin.ExposedCopyVisibility
1515
import kotlin.String
1616
import kotlin.Suppress
1717
import kotlin.Unit
@@ -35,7 +35,7 @@ import kotlin.collections.toTypedArray
3535
* @param _customVersion Allows overriding action's version, for example to use a specific minor
3636
* version, or a newer version that the binding doesn't yet know about
3737
*/
38-
@ConsistentCopyVisibility
38+
@ExposedCopyVisibility
3939
public data class ActionWithFancyCharsInDocs private constructor(
4040
/**
4141
* This is a /* test */

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithInputsSharingType.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ package io.github.typesafegithub.workflows.actions.johnsmith
1111
import io.github.typesafegithub.workflows.domain.actions.Action
1212
import io.github.typesafegithub.workflows.domain.actions.RegularAction
1313
import java.util.LinkedHashMap
14-
import kotlin.ConsistentCopyVisibility
14+
import kotlin.ExposedCopyVisibility
1515
import kotlin.Int
1616
import kotlin.String
1717
import kotlin.Suppress
@@ -36,7 +36,7 @@ import kotlin.collections.toTypedArray
3636
* @param _customVersion Allows overriding action's version, for example to use a specific minor
3737
* version, or a newer version that the binding doesn't yet know about
3838
*/
39-
@ConsistentCopyVisibility
39+
@ExposedCopyVisibility
4040
public data class ActionWithInputsSharingType private constructor(
4141
/**
4242
* <required>

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoInputs.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ package io.github.typesafegithub.workflows.actions.johnsmith
1111
import io.github.typesafegithub.workflows.domain.actions.Action
1212
import io.github.typesafegithub.workflows.domain.actions.RegularAction
1313
import java.util.LinkedHashMap
14-
import kotlin.ConsistentCopyVisibility
14+
import kotlin.ExposedCopyVisibility
1515
import kotlin.String
1616
import kotlin.Suppress
1717
import kotlin.Unit
@@ -29,7 +29,7 @@ import kotlin.collections.Map
2929
* @param _customVersion Allows overriding action's version, for example to use a specific minor
3030
* version, or a newer version that the binding doesn't yet know about
3131
*/
32-
@ConsistentCopyVisibility
32+
@ExposedCopyVisibility
3333
public data class ActionWithNoInputs private constructor(
3434
/**
3535
* Type-unsafe map where you can put any inputs that are not yet supported by the binding

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithNoTypings_Untyped.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ package io.github.typesafegithub.workflows.actions.johnsmith
1111
import io.github.typesafegithub.workflows.domain.actions.Action
1212
import io.github.typesafegithub.workflows.domain.actions.RegularAction
1313
import java.util.LinkedHashMap
14-
import kotlin.ConsistentCopyVisibility
14+
import kotlin.ExposedCopyVisibility
1515
import kotlin.String
1616
import kotlin.Suppress
1717
import kotlin.Unit
@@ -51,7 +51,7 @@ import kotlin.collections.toTypedArray
5151
* @param _customVersion Allows overriding action's version, for example to use a specific minor
5252
* version, or a newer version that the binding doesn't yet know about
5353
*/
54-
@ConsistentCopyVisibility
54+
@ExposedCopyVisibility
5555
public data class ActionWithNoTypings_Untyped private constructor(
5656
public val foo_Untyped: String,
5757
public val bar_Untyped: String? = null,

0 commit comments

Comments
 (0)