Transform IUO into `Optional` to prevent errors.

This commit is contained in:
Matyáš Kříž 2018-11-09 14:12:29 +01:00
parent 9d6ecf889c
commit 7ad094cf78
2 changed files with 3 additions and 4 deletions

View File

@ -11,7 +11,7 @@ extension Templates {
{% for property in container.properties %}
{{ property.accessibility }}{% if container.@type == "ClassDeclaration" %} override{% endif %} var {{ property.name }}: {{ property.type }} {
get {
return DefaultValueRegistry.defaultValue(for: ({{property.type}}).self)
return DefaultValueRegistry.defaultValue(for: ({{property.type|genericSafe}}).self)
}
{% ifnot property.isReadOnly %}
set { }

View File

@ -29,14 +29,13 @@ public struct InstanceVariable: Token {
}
public func serialize() -> [String : Any] {
let readOnlyString = readOnly ? "ReadOnly" : ""
return [
"name": name,
"type": type,
"accessibility": accessibility.sourceName,
"isReadOnly": readOnly,
"stubType": readOnly ?
(overriding ? "ClassToBeStubbedReadOnlyProperty" : "ProtocolToBeStubbedReadOnlyProperty") :
(overriding ? "ClassToBeStubbedProperty" : "ProtocolToBeStubbedProperty")
"stubType": overriding ? "ClassToBeStubbed\(readOnlyString)Property" : "ProtocolToBeStubbed\(readOnlyString)Property"
]
}
}