Commit ca6dbe1
committed
Fix build issues
1. When running `make build` the compiler complains that it “can’t type check this expression in reasonable time” in `ObjectiveCInitExtension.swift`. I put the expression in an explicitly declared variable to help out the compiler’s tiny brain.
2. The test `testPolymorphicPropWithBool` is failing. Looking at the code, we test that an `NSNumber` is a bool via:
```
if ([value isKindOfClass:[NSNumber class]] && strcmp([value objCType], @encode(BOOL)) == 0) {
self->_polymorphicProp = [EverythingPolymorphicProp objectWithBoolean:[value boolValue] & 0x1];
}
```
However, I’m seeing weird behavior where `@encode(BOOL)` is not returning `c` as [Apple documentation](https://developer.apple.com/documentation/objectivec/bool) says it should: ```
BOOL is explicitly signed so @encode(BOOL) is c rather than C even if -funsigned-char is used.
```
Here is what I was seeing in the debugger:
```
(lldb) po @encode(BOOL)
"B"
(lldb) po [@yES objCType]
"c"
(lldb) po [@no objCType]
"c"
```
I am not sure why this is retuning `B`, but it seems a safer check would be:
```
if ([value isKindOfClass:[NSNumber class]] && strcmp([value objCType], [[NSNumber numberWithBool:0] objCType]) == 0) {
self->_polymorphicProp = [EverythingPolymorphicProp objectWithBoolean:[value boolValue] & 0x1];
}
```
I added this change to fix the tests.1 parent a2fe6e1 commit ca6dbe1
File tree
3 files changed
+5
-2
lines changed- .github/workflows
- Sources/Core
3 files changed
+5
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | | - | |
| 275 | + | |
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
0 commit comments