Skip to content

Commit

Permalink
Add futures showing that override can be applied to init() and post…
Browse files Browse the repository at this point in the history
…init() (#26518)

[trivial, not reviewed]

This adds some futures noting that `override` can be applied to `init()`
and `postinit()`, where we should probably flag that as an error (issue
#26515).
  • Loading branch information
bradcray authored Jan 14, 2025
2 parents a4397d5 + f5a3ea0 commit 174c9ae
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/classes/initializers/inheritance/override.bad
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
({x = 45}, {x = 45, y = 33})
17 changes: 17 additions & 0 deletions test/classes/initializers/inheritance/override.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class C {
var x: int;
proc init() {
this.x = 45;
}
}

class D: C {
var y: int;
override proc init() {
this.y = 33;
}
}

var myC = new C();
var myD = new D();
writeln((myC, myD));
7 changes: 7 additions & 0 deletions test/classes/initializers/inheritance/override.future
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bug: postinit() shouldn't accept 'override'

I don't believe that init() routines should accept 'override'
decorations given that they aren't really dynamically dispatched or
overridden in the normal way.

#26515
1 change: 1 addition & 0 deletions test/classes/initializers/inheritance/override.good
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
override.chpl:10: error: the 'override' keyword cannot be applied to 'init()' routines
2 changes: 2 additions & 0 deletions test/classes/initializers/postInit/override.bad
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
In C.postinit()
In D.postinit()
13 changes: 13 additions & 0 deletions test/classes/initializers/postInit/override.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class C {
proc postinit() {
writeln("In C.postinit()");
}
}

class D: C {
override proc postinit() {
writeln("In D.postinit()");
}
}

var myD = new D();
7 changes: 7 additions & 0 deletions test/classes/initializers/postInit/override.future
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bug: postinit() shouldn't accept 'override'

I don't believe that postinit() routines should accept 'override'
decorations given that they aren't really dynamically dispatched or
overridden in the normal way.

#26515
1 change: 1 addition & 0 deletions test/classes/initializers/postInit/override.good
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
override.chpl:8: error: the 'override' keyword cannot be applied to 'postinit()' routines
2 changes: 2 additions & 0 deletions test/classes/initializers/postInit/override2.bad
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
In C.postinit()
In D.postinit()
13 changes: 13 additions & 0 deletions test/classes/initializers/postInit/override2.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class C {
proc postinit() throws {
writeln("In C.postinit()");
}
}

class D: C {
override proc postinit() {
writeln("In D.postinit()");
}
}

var myD = new D();
7 changes: 7 additions & 0 deletions test/classes/initializers/postInit/override2.future
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bug: postinit() shouldn't accept 'override'

I don't believe that postinit() routines should accept 'override'
decorations given that they aren't really dynamically dispatched or
overridden in the normal way.

#26515
1 change: 1 addition & 0 deletions test/classes/initializers/postInit/override2.good
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
override2.chpl:8: error: the 'override' keyword cannot be applied to 'postinit()' routines
1 change: 1 addition & 0 deletions test/classes/initializers/postInit/override3.bad
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In D.postinit()
10 changes: 10 additions & 0 deletions test/classes/initializers/postInit/override3.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class C {
}

class D: C {
override proc postinit() throws {
writeln("In D.postinit()");
}
}

var myD = new D();
7 changes: 7 additions & 0 deletions test/classes/initializers/postInit/override3.future
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bug: postinit() shouldn't accept 'override'

I don't believe that postinit() routines should accept 'override'
decorations given that they aren't really dynamically dispatched or
overridden in the normal way.

#26515
1 change: 1 addition & 0 deletions test/classes/initializers/postInit/override3.good
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
override3.chpl:5: error: the 'override' keyword cannot be applied to 'postinit()' routines

0 comments on commit 174c9ae

Please sign in to comment.