Skip to content

Commit

Permalink
Work around type-checking error present in XCode 16.0
Browse files Browse the repository at this point in the history
This seems like a swift/xcode bug, but the work around is harmless
enough

This assignment should be a no-op, but it avoids hitting a type checking error I'm seeing in XCode Version 16.0 (16A242d) (stable release)
I did not experience this error on XCode 15.4

The error is:
> Cannot convert return expression of type 'Dictionary<Int, Double>' to return type 'Dictionary<String, Optional<JSONValue>>.RawValue' (aka 'Dictionary<String, Optional<Any>>')

JSONValue is defined in turf.
Maybe the complexity of the various expressible-by-literal's in JSONValue/JSONObject are leading to a compiler edgecase? Just a guess.
  • Loading branch information
michaelkirk committed Sep 17, 2024
1 parent 22b3107 commit e5390c8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion MapboxNavigation/Dictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ extension [Int: Double] {
Returns a copy of the stop dictionary with each value multiplied by the given factor.
*/
func multiplied(by factor: Double) -> Dictionary {
mapValues { $0 * factor }
// This assignment should be a no-op, but it avoids hitting a type checking error I'm seeing in XCode Version 16.0 (16A242d) (stable release)
// I did not experience this error on XCode 15.4
//
// The error is:
// > Cannot convert return expression of type 'Dictionary<Int, Double>' to return type 'Dictionary<String, Optional<JSONValue>>.RawValue' (aka 'Dictionary<String, Optional<Any>>')
//
// JSONValue is defined in turf.
// Maybe the complexity of the various expressible-by-literal's in JSONValue/JSONObject are leading to a compiler edgecase? Just a guess.
let tmp = mapValues { $0 * factor }
return tmp
}
}

0 comments on commit e5390c8

Please sign in to comment.