Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type param constraints now respect default cap of the type. #2675

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/collections/_test.pony
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ class \nodoc\ iso _TestSort is UnitTest
[""; "%*&^*&^&"; "***"; "Hello"; "bar"; "f00"; "foo"; "foo"],
[""; "Hello"; "foo"; "bar"; "foo"; "f00"; "%*&^*&^&"; "***"])

fun test_sort[A: (Comparable[A] val & Stringable)](
fun test_sort[A: (Comparable[A] val & Stringable val)](
h: TestHelper,
sorted: Array[A],
unsorted: Array[A])
Expand Down
2 changes: 1 addition & 1 deletion packages/collections/persistent/map.pony
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use mut = "collections"

type Map[K: (mut.Hashable val & Equatable[K]), V: Any #share] is
type Map[K: (mut.Hashable val & Equatable[K] val), V: Any #share] is
HashMap[K, V, mut.HashEq[K]]
"""
A map that uses structural equality on the key.
Expand Down
2 changes: 1 addition & 1 deletion packages/collections/persistent/set.pony
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use mut = "collections"

type Set[A: (mut.Hashable val & Equatable[A])] is HashSet[A, mut.HashEq[A]]
type Set[A: (mut.Hashable val & Equatable[A] val)] is HashSet[A, mut.HashEq[A]]

type SetIs[A: Any #share] is HashSet[A, mut.HashIs[A]]

Expand Down
4 changes: 2 additions & 2 deletions packages/pony_test/test_helper.pony
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class val TestHelper
"""
_check_eq[A]("eq", expect, actual, msg, loc)

fun _check_eq[A: (Equatable[A] #read & Stringable)]
fun _check_eq[A: (Equatable[A] #read & Stringable #read)]
(check: String, expect: A, actual: A, msg: String, loc: SourceLoc)
: Bool
=>
Expand Down Expand Up @@ -221,7 +221,7 @@ class val TestHelper
"""
_check_ne[A]("ne", not_expect, actual, msg, loc)

fun _check_ne[A: (Equatable[A] #read & Stringable)]
fun _check_ne[A: (Equatable[A] #read & Stringable #read)]
(check: String, not_expect: A, actual: A, msg: String, loc: SourceLoc)
: Bool
=>
Expand Down
14 changes: 2 additions & 12 deletions src/libponyc/pass/names.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,8 @@ static bool names_type(pass_opt_t* opt, ast_t** astp, ast_t* def)

if(tcap == TK_NONE)
{
if((opt->check.frame->constraint != NULL) ||
(opt->check.frame->iftype_constraint != NULL))
{
// A primitive constraint is a val, otherwise #any.
if(ast_id(def) == TK_PRIMITIVE)
tcap = TK_VAL;
else
tcap = TK_CAP_ANY;
} else {
// Use the default capability.
tcap = ast_id(def_cap);
}
// Use the default capability.
tcap = ast_id(def_cap);
}

ast_setid(cap, tcap);
Expand Down
Loading