|
| 1 | +======================================================================== |
| 2 | +Simple nullable builtin type |
| 3 | +======================================================================== |
| 4 | +fun int.someMethod(self) {} |
| 5 | + |
| 6 | +fun main(value: int?) { |
| 7 | + value.someMethod(); |
| 8 | +} |
| 9 | +------------------------------------------------------------------------ |
| 10 | +3 0:8 to 0:18 Method 'someMethod' is never used (tolk) |
| 11 | +0 3:10 to 3:20 Cannot call method `someMethod` on nullable type `int?`, you need to unwrap it with `!` or explicitly check for `value != null` (tolk) |
| 12 | + |
| 13 | +======================================================================== |
| 14 | +Simple nullable builtin type, fixed |
| 15 | +======================================================================== |
| 16 | +fun int.someMethod(self) {} |
| 17 | + |
| 18 | +fun main(value: int?) { |
| 19 | + value!.someMethod(); |
| 20 | +} |
| 21 | +------------------------------------------------------------------------ |
| 22 | +no issues |
| 23 | + |
| 24 | +======================================================================== |
| 25 | +Simple nullable builtin type, fixed 2 |
| 26 | +======================================================================== |
| 27 | +fun int.someMethod(self) {} |
| 28 | + |
| 29 | +fun main(value: int?) { |
| 30 | + if (value == null) { |
| 31 | + return |
| 32 | + } |
| 33 | + value.someMethod(); |
| 34 | +} |
| 35 | +------------------------------------------------------------------------ |
| 36 | +no issues |
| 37 | + |
| 38 | +======================================================================== |
| 39 | +Simple nullable builtin type, fixed 3 |
| 40 | +======================================================================== |
| 41 | +fun int.someMethod(self) {} |
| 42 | + |
| 43 | +fun main(value: int?) { |
| 44 | + if (value != null) { |
| 45 | + value.someMethod(); |
| 46 | + } |
| 47 | +} |
| 48 | +------------------------------------------------------------------------ |
| 49 | +no issues |
| 50 | + |
| 51 | +======================================================================== |
| 52 | +Tensor nullable builtin type |
| 53 | +======================================================================== |
| 54 | +fun (int, slice).someMethod(self) {} |
| 55 | + |
| 56 | +fun main(value: (int, slice)?) { |
| 57 | + value.someMethod(); |
| 58 | +} |
| 59 | +------------------------------------------------------------------------ |
| 60 | +3 0:17 to 0:27 Method 'someMethod' is never used (tolk) |
| 61 | +0 3:10 to 3:20 Cannot call method `someMethod` on nullable type `(int, slice)?`, you need to unwrap it with `!` or explicitly check for `value != null` (tolk) |
| 62 | + |
| 63 | +======================================================================== |
| 64 | +Simple nullable builtin type without methods |
| 65 | +======================================================================== |
| 66 | +fun main(value: int?) { |
| 67 | + value.someMethod(); |
| 68 | +} |
| 69 | +------------------------------------------------------------------------ |
| 70 | +no issues |
| 71 | + |
| 72 | +======================================================================== |
| 73 | +Simple nullable builtin type with several methods |
| 74 | +======================================================================== |
| 75 | +fun (int, slice).someMethod(self) {} |
| 76 | +fun T.someMethod(self) {} |
| 77 | + |
| 78 | +fun main(value: int?) { |
| 79 | + value.someMethod(); |
| 80 | +} |
| 81 | +------------------------------------------------------------------------ |
| 82 | +3 0:17 to 0:27 Method 'someMethod' is never used (tolk) |
| 83 | + |
| 84 | +======================================================================== |
| 85 | +Simple nullable builtin type with complex qualifier |
| 86 | +======================================================================== |
| 87 | +fun int.someMethod(self) {} |
| 88 | + |
| 89 | +fun getData(): int? { return null } |
| 90 | + |
| 91 | +fun main() { |
| 92 | + getData().someMethod(); |
| 93 | +} |
| 94 | +------------------------------------------------------------------------ |
| 95 | +3 0:8 to 0:18 Method 'someMethod' is never used (tolk) |
| 96 | +0 5:14 to 5:24 Cannot call method `someMethod` on nullable type `int?`, you need to unwrap it with `!` or explicitly check for `getData() != null` (tolk) |
0 commit comments