summaryrefslogtreecommitdiff
path: root/cpp/src/slice2swift/Gen.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2019-04-04 17:35:43 +0200
committerJose <jose@zeroc.com>2019-04-04 17:35:43 +0200
commit5dcb27a5ef863bcf78497dc3d481632a6ff22ad8 (patch)
tree17da53d5110f8d3d7c8b9d3047cc8910b97fa4f2 /cpp/src/slice2swift/Gen.cpp
parentFix operation optional parameters declaration (diff)
downloadice-5dcb27a5ef863bcf78497dc3d481632a6ff22ad8.tar.bz2
ice-5dcb27a5ef863bcf78497dc3d481632a6ff22ad8.tar.xz
ice-5dcb27a5ef863bcf78497dc3d481632a6ff22ad8.zip
Fix warning with structure unmarshalling for struct map to class
Diffstat (limited to 'cpp/src/slice2swift/Gen.cpp')
-rw-r--r--cpp/src/slice2swift/Gen.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp
index 61a7a7b7c32..4a63d087ab5 100644
--- a/cpp/src/slice2swift/Gen.cpp
+++ b/cpp/src/slice2swift/Gen.cpp
@@ -480,8 +480,9 @@ Gen::TypesVisitor::visitStructStart(const StructPtr& p)
const DataMemberList members = p->dataMembers();
const string optionalFormat = getOptionalFormat(p);
+ bool isClass = containsClassMembers(p);
out << sp;
- out << nl << "public " << (containsClassMembers(p) ? "class " : "struct ") << name;
+ out << nl << "public " << (isClass ? "class " : "struct ") << name;
if(legalKeyType)
{
out << ": Swift.Hashable";
@@ -502,7 +503,7 @@ Gen::TypesVisitor::visitStructStart(const StructPtr& p)
out << sp;
out << nl << "func read() throws -> " << name;
out << sb;
- out << nl << "var v = " << name << "()";
+ out << nl << (isClass ? "let" : "var") << " v = " << name << "()";
for(DataMemberList::const_iterator q = members.begin(); q != members.end(); ++q)
{
writeMarshalUnmarshalCode(out, (*q)->type(), p, "v." + fixIdent((*q)->name()), false);