Skip to content

Commit

Permalink
Deprecate new
Browse files Browse the repository at this point in the history
Enhancements:
- Hint that `new` is deprecated and can be omitted (see  #1141)

Technical:
- Remove use of `new` thoughout compiler and integration tests
  • Loading branch information
degory committed Mar 30, 2024
1 parent bad1974 commit 48ef013
Show file tree
Hide file tree
Showing 391 changed files with 2,336 additions and 2,334 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
]
},
"ghul.compiler": {
"version": "0.8.27",
"version": "0.8.29",
"commands": [
"ghul-compiler"
]
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.8.28-alpha.111</Version>
<Version>0.8.29-alpha.2</Version>
<NoWarn>$(NoWarn);NU1507</NoWarn>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Test is
Std.out.write_line("start");

try
new Abstract().do_something();
Abstract().do_something();
catch ex: System.NotImplementedException
Std.out.write_line("expected: " + ex.message);
yrt
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/execution/anonymous-function/test.ghul
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Test is
entry() static is


let thing = new Thing(2);
let thing = Thing(2);

let sum_function = thing.create_sum_function();

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/execution/array-argument/test.ghul
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use Std = IO.Std;

class Main is
entry(args: string[]) static is
new Main().test(args);
Main().test(args);
si

init() is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ namespace Test is
entry() static is


let t = new Thing(111);
let t = Thing(111);

let u = new Thing(222);
let u = Thing(222);

let z = t % u;

Expand All @@ -31,7 +31,7 @@ namespace Test is
si

%(other: Thing) -> Thing is
return new Thing(self._value + other._value);
return Thing(self._value + other._value);
si

to_string() -> string is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Test is
entry() static is


let c = new C();
let c = C();

let a: object = c.f(123);
let b = c.f(456);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Test is
entry() static is


let list = new Collections.LIST[object]();
let list = Collections.LIST[object]();

list.add(1);
list.add(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ namespace Test is
entry() static is


new Main().test();
Main().test();
si

test() is
let map = new MAP[string,string]();
let map = MAP[string,string]();

map.add("A", "a");
map.add("B", "b");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Test is
entry() static is


let c = new COUNTER();
let c = COUNTER();

for v in 1::5 do
Std.out.write_line("will increment " + c.count + " by " + v + "...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Test is
entry() static is


let c: Counter = new COUNTER();
let c: Counter = COUNTER();

for v in 1::5 do
Std.out.write_line("will increment " + c.count + " by " + v + "...");
Expand Down
14 changes: 7 additions & 7 deletions integration-tests/execution/class-generic-traits/test.ghul
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ namespace Test is
test_integers() static is
let integers = [1, 2, 3, 4, 5];

let small_int_stack = new TWO_ELEMENT_STACK[int]();
let large_int_stack = new LIST_STACK[int]();
let small_int_stack = TWO_ELEMENT_STACK[int]();
let large_int_stack = LIST_STACK[int]();

let pp = new PUSHER_POPPER[int]();
let pp = PUSHER_POPPER[int]();

pp.push_all(small_int_stack, integers);
pp.pop_all(small_int_stack);
Expand All @@ -42,10 +42,10 @@ namespace Test is
test_strings() static is
let strings = ["one", "two", "three", "four", "chicken"];

let small_string_stack = new TWO_ELEMENT_STACK[string]();
let large_string_stack = new LIST_STACK[string]();
let small_string_stack = TWO_ELEMENT_STACK[string]();
let large_string_stack = LIST_STACK[string]();

let pp = new PUSHER_POPPER[string]();
let pp = PUSHER_POPPER[string]();

pp.push_all(small_string_stack, strings);
pp.pop_all(small_string_stack);
Expand Down Expand Up @@ -129,7 +129,7 @@ namespace Test is
is_empty: bool => _list.count == 0;

init() is
_list = new LIST[T]();
_list = LIST[T]();
si

push(t: T) is
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/execution/class-multiple-traits/test.ghul
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ namespace Test is
entry() static is


let rats = [new RAT(), new RAT(), new RAT()];
let rats = [RAT(), RAT(), RAT()];

let dog = new DOG("Spot");
let cat = new CAT("Mr Tibbles");
let chimera = new CHIMERA("Nigel");
let dog = DOG("Spot");
let cat = CAT("Mr Tibbles");
let chimera = CHIMERA("Nigel");

for r in rats do
vocalise(r);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace Test is
test_static_property();
test_static_local_variable();

new Main().test_instance_field();
new Main().test_instance_local_variable();
Main().test_instance_field();
Main().test_instance_local_variable();
si

test_static_field() static is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ namespace Test is
test_static_property();
test_static_local_variable();

new Main().test_instance_field();
new Main().test_instance_local_variable();
new Main().test_local_variable();
Main().test_instance_field();
Main().test_instance_local_variable();
Main().test_local_variable();
si

test_static_field() static is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Test is
entry() static is


new Main().test();
Main().test();
si

test() is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Test is
entry() static is


new Main().test();
Main().test();
si

test() is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Test is
entry() static is


new Main().test();
Main().test();
si

test() is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Test is
entry() static is


for i in new Main().test() do
for i in Main().test() do
let result = i("hello");

Std.out.write_line("inner result: " + result);
Expand All @@ -20,7 +20,7 @@ namespace Test is
test() -> Collections.Iterable[(string) -> int] is
let capture_1 = 444;

let inners = new Collections.LIST[(string) -> int]();
let inners = Collections.LIST[(string) -> int]();

for capture in 0..5 do
let outer = () is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Test is
entry() static is


new Main().test();
Main().test();
si

test() is
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/execution/collection-interop/test.ghul
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Test is
entry() static is


let list = new LIST[int]();
let list = LIST[int]();

list.add(1);
list.add(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Test is
entry() static is


let test = new Test("Hello world");
let test = Test("Hello world");

test.test();
si
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace Test is
entry() static is
Std.error.write_line("entry...");

let gi = new GENERIC[int](123);
let gc = new GENERIC[char]('x');
let gt = new GENERIC[(int,int)]((123,456));
let gi = GENERIC[int](123);
let gc = GENERIC[char]('x');
let gt = GENERIC[(int,int)]((123,456));

gi.test();
gc.test();
Expand Down
12 changes: 6 additions & 6 deletions integration-tests/execution/consume-iterator-traits/test.ghul
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ namespace Test is
entry() static is


new CONSUMER[string]().consume_array(["one", "two", "three"]);
new CONSUMER[string]().consume_iterable(["one", "two", "three"]);
new CONSUMER[string]().consume_iterable(new LIST[string](["one", "two", "three"]));
CONSUMER[string]().consume_array(["one", "two", "three"]);
CONSUMER[string]().consume_iterable(["one", "two", "three"]);
CONSUMER[string]().consume_iterable(LIST[string](["one", "two", "three"]));

new CONSUMER[int]().consume_array([1, 2, 3]);
new CONSUMER[int]().consume_iterable([1, 2, 3]);
new CONSUMER[int]().consume_iterable(new LIST[int]([1, 2, 3]));
CONSUMER[int]().consume_array([1, 2, 3]);
CONSUMER[int]().consume_iterable([1, 2, 3]);
CONSUMER[int]().consume_iterable(LIST[int]([1, 2, 3]));
si
si

Expand Down
4 changes: 2 additions & 2 deletions integration-tests/execution/convert-object-to-class/test.ghul
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ struct STRUCT_THINGER: GetAThing is
self.name = name;
si

get_a_thing() -> THING => new THING();
get_a_thing() -> THING => THING();

to_string() -> string => name;
si

test_convert_of_object_to_class() is
let s = new STRUCT_THINGER("hello");
let s = STRUCT_THINGER("hello");

let o: object;
let t: GetAThing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ struct STRUCT_THINGER: GetAThing is
self.name = name;
si

get_a_thing() -> THING => new THING();
get_a_thing() -> THING => THING();

to_string() -> string => name;
si

test_convert_of_object_to_struct() is
let s = new STRUCT_THINGER("hello");
let s = STRUCT_THINGER("hello");

let o: object;
let t: STRUCT_THINGER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class THINGER: GetAThing is
self.name = name;
si

get_a_thing() -> THING => new THING();
get_a_thing() -> THING => THING();

to_string() -> string => name;
si

test_convert_of_object_to_class() is
let s = new THINGER("hello");
let s = THINGER("hello");

let o: GetAThing;
let t: THINGER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ struct STRUCT_THINGER: GetAThing is
self.name = name;
si

get_a_thing() -> THING => new THING();
get_a_thing() -> THING => THING();

to_string() -> string => name;
si

test_convert_struct_object_to_trait() is
let s = new STRUCT_THINGER("hello");
let s = STRUCT_THINGER("hello");

let o: object;
let t: GetAThing;
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/execution/covariant-return-type/test.ghul
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ namespace Test is
entry() static is


let base = new BASE(111);
let base = BASE(111);

let derived = new DERIVED(222);
let derived = DERIVED(222);

let base_copy = base.copy();
Std.out.write_line("base copy: " + base_copy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ struct STRUCT_THINGER: GetAThing is
self.name = name;
si

get_a_thing() -> THING => new THING();
get_a_thing() -> THING => THING();

to_string() -> string => name;
si

test_explicit_convert_struct_to_object() is
let s = new STRUCT_THINGER("hello");
let s = STRUCT_THINGER("hello");

let o: object;

Expand Down
Loading

0 comments on commit 48ef013

Please sign in to comment.