-
-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't duplicate match checks for inherited trait bodies (#4628)
Due to how default method bodies are implemented, we only want to do match checks within the context of the trait, not in the context of the class that has inherited the method. Closes #4612
- Loading branch information
1 parent
1ed6ec1
commit 92d75bc
Showing
3 changed files
with
184 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
## Don't duplicate match checks for inherited trait bodies | ||
|
||
Due to how we were doing match checks, some usages of match in default method bodies of traits and interfaces could end up failing checking once they were "inherited" by the implementing class. | ||
|
||
For example, the following failed to compile: | ||
|
||
```pony | ||
primitive Prim | ||
fun ignore() => None | ||
trait A | ||
fun union(): (Prim | None) | ||
fun match_it(): Bool => | ||
match union() | ||
| let p: Prim => | ||
p.ignore() | ||
true | ||
| None => | ||
false | ||
end | ||
class B is A | ||
fun union(): Prim => | ||
Prim | ||
``` | ||
|
||
We've updated to only do the match checks checking the trait's default method bodies. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
This won't compile if there is a regression for issue #4612. | ||
""" | ||
|
||
actor Main | ||
new create(env: Env) => | ||
None | ||
|
||
primitive Prim | ||
fun ignore() => None | ||
|
||
trait A | ||
fun union(): (Prim | None) | ||
|
||
fun match_it(): Bool => | ||
match union() | ||
| let p: Prim => | ||
p.ignore() | ||
true | ||
| None => | ||
false | ||
end | ||
|
||
class B is A | ||
fun union(): Prim => | ||
Prim |