alexeyxo / protobuf-swift

Google ProtocolBuffers for Apple Swift
http://protobuf.io/#swift
Apache License 2.0
938 stars 138 forks source link

Generated files compile error "Ambiguous reference to member 'subscript'" #203

Closed gaplo917 closed 7 years ago

gaplo917 commented 7 years ago

Version of protoc (protoc --version)

3.2.0

Version of ProtocolBuffers.framework

3.0.9

.proto file to reproduce

message MyTest {
  map<bool, string> bool_to_string = 12;
};

Description

I know map<bool,string> data structure is a very rare to be used. But it is allowed in protobuf definition.

So, I would consider it is a bug.

      class override public func decodeToBuilder(jsonMap:Dictionary<String,Any>) throws -> Jsontest.MyTest.Builder {
        let resultDecodedBuilder = Jsontest.MyTest.Builder()
        if let jsonValueBoolToString = jsonMap["boolToString"] as? Dictionary<String, String> {
            var mapBoolToString = Dictionary<Bool, String>()
            for (keyBoolToString, valueBoolToString) in jsonValueBoolToString {
                let keyFromBoolToString = keyBoolToString
                mapBoolToString[keyFromBoolToString] = valueBoolToString
            }
            resultDecodedBuilder.boolToString = mapBoolToString
        }
        return resultDecodedBuilder
      }
// error : Ambiguous reference to member 'subscript'
mapBoolToString[keyFromBoolToString] = valueBoolToString