HaxeFoundation / HaxeFoundation/haxe
[nullsafety] overloads and null safety
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
Example:
```haxe
@:nullSafety(Strict)
extern class Foo {
@:overload(function(value: Int): Int {})
@:overload(function(value: Null): String {})
static function foo(): Void;
}
@:nullSafety(Strict)
abstract Bar(Int) from Int {
@:op(A + B) private function plusInt(value: Int) {
return this + value;
}
@:op(A + B) private function plusNullString(value: Null) {
return value == null ? '$this' : '$this:$value';
}
}
@:nullSafety(Strict)
class Main {
public static function main() {
Foo.foo(null); // Error expects Int
(1: Bar) + null; // Error expects Int
}
}
```
Right now null safety does not affect choice of an overload to use, it happens after. I assume it can be put on a long-term todo list?
(Example above can be fixed by moving overload with a null string above int one, but this is just an example, real issue is overloads for `T` and `Null` and this can't be fixed by placing `Null` above, since then `T` will never be used.)
Contributor guide
Assessment
This issue has not been assessed yet.