Closed wickwirew closed 7 years ago
Heres an example of the original issue. Without the Any it works
class TestClass {
var value: Int = 0
}
var instance: Any = TestClass()
try? set(35, key: "value", for: &instance)
print((instance as! TestClass).value) // Prints 0
Merging #7 into master will decrease coverage by
<.01%
. The diff coverage is75%
.
@@ Coverage Diff @@
## master #7 +/- ##
==========================================
- Coverage 80.38% 80.38% -0.01%
==========================================
Files 27 27
Lines 566 571 +5
==========================================
+ Hits 455 459 +4
- Misses 111 112 +1
Impacted Files | Coverage Δ | |
---|---|---|
Sources/Reflection/Set.swift | 45.45% <0%> (-4.55%) |
:arrow_down: |
Sources/Reflection/Storage.swift | 87.5% <100%> (+4.16%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 9400cd8...d1f70b7. Read the comment docs.
@bradhilton did you take a look at this? (:
@bradhilton any chance this can be reviewed and merged?
By the way, I believe this should fix https://github.com/Zewo/Zewo/issues/237 and possibly https://github.com/Zewo/Zewo/issues/238.
I ran into an issue setting a value on an object that was casted as an Any. From what I can tell the problem was in the storage. The type of the instance was not being recognized as AnyClass even though it is. What is happening is once it is passed to
storage<T>
casted as anAny
the methodtype(of:)
no longer returns the correct type of the instance, it returnsAny
due to the generics. Would like to hear your input.Not sure if this is the best way to fix it. Another solution would be to remove the generics but that may break other things. This is less invasive