From d38f0449eeda2ace10ef9787c94b3eaf8466a250 Mon Sep 17 00:00:00 2001 From: "Sean T. Allen" Date: Thu, 27 Aug 2026 17:43:40 -0400 Subject: [PATCH] Update code samples and prose for ponyc 0.70.0 constraint cap change ponyc 0.70.0 uses the default capability of the named type in constraints instead of substituting #any. Code samples that relied on the implicit #any need explicit capability annotations. --- code-samples/appendices-examples-test-helper.pony | 4 ++-- code-samples/control-structures-iftype-capability.pony | 2 +- ...pabilities-explicit-constraint-and-default-capability.pony | 2 +- docs/generics/generics-and-reference-capabilities.md | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code-samples/appendices-examples-test-helper.pony b/code-samples/appendices-examples-test-helper.pony index bdb0a603..0f9a5fbe 100644 --- a/code-samples/appendices-examples-test-helper.pony +++ b/code-samples/appendices-examples-test-helper.pony @@ -9,7 +9,7 @@ fun tag assert_error(test: ITest, msg: String = "") ? fun tag expect_error(test: ITest box, msg: String = ""): Bool fun tag assert_is (expect: Any, actual: Any, msg: String = "") ? fun tag expect_is (expect: Any, actual: Any, msg: String = ""): Bool -fun tag assert_eq[A: (Equatable[A] #read & Stringable)] +fun tag assert_eq[A: (Equatable[A] #read & Stringable #read)] (expect: A, actual: A, msg: String = "") ? -fun tag expect_eq[A: (Equatable[A] #read & Stringable)] +fun tag expect_eq[A: (Equatable[A] #read & Stringable #read)] (expect: A, actual: A, msg: String = ""): Bool \ No newline at end of file diff --git a/code-samples/control-structures-iftype-capability.pony b/code-samples/control-structures-iftype-capability.pony index 51474307..61f5f113 100644 --- a/code-samples/control-structures-iftype-capability.pony +++ b/code-samples/control-structures-iftype-capability.pony @@ -14,7 +14,7 @@ actor Main let cat2: Cat val = Cat maybe_rename[Cat val](cat2, env) - fun maybe_rename[A: Animal](a: A, env: Env) => + fun maybe_rename[A: Animal #any](a: A, env: Env) => iftype A <: Cat ref then a.set_name("Kitty") env.out.print(a.name()) diff --git a/code-samples/generics-and-reference-capabilities-explicit-constraint-and-default-capability.pony b/code-samples/generics-and-reference-capabilities-explicit-constraint-and-default-capability.pony index 19e2d296..5fd1b17a 100644 --- a/code-samples/generics-and-reference-capabilities-explicit-constraint-and-default-capability.pony +++ b/code-samples/generics-and-reference-capabilities-explicit-constraint-and-default-capability.pony @@ -1 +1 @@ -class Foo[A: Any] \ No newline at end of file +class Foo[A: Any #any] \ No newline at end of file diff --git a/docs/generics/generics-and-reference-capabilities.md b/docs/generics/generics-and-reference-capabilities.md index 3b99cbfd..94ca3ed7 100644 --- a/docs/generics/generics-and-reference-capabilities.md +++ b/docs/generics/generics-and-reference-capabilities.md @@ -6,7 +6,7 @@ In the examples presented previously we've explicitly set the reference capabili --8<-- "generics-foo-with-any-val.pony::1" ``` -If the capability is left out of the type parameter then the generic class or function can accept any reference capability. This would look like: +To accept any reference capability, use `#any` as the capability on the constraint. This would look like: ```pony --8<-- "generics-and-reference-capabilities-explicit-constraint-and-default-capability.pony"