in Sources/MockoloFramework/Utils/SwiftType.swift [333:383]
func processTypeParams(with typeParamList: [String]) -> SwiftType {
if someOrAny == .some {
var result = self
result.someOrAny = .any
return result
}
switch kind {
case .tuple(let tuple):
let newElements = tuple.elements.map {
Tuple.Element(label: $0.label, type: $0.type.processTypeParams(with: typeParamList))
}
/// convert `(Any)` to `Any` for readability
if newElements.count == 1 && newElements[0].type == .Any {
return newElements[0].type
}
return self.copy(kind: .tuple(.init(elements: newElements)))
case .nominal(let nominal):
if isOptional {
let wrapped = nominal.genericParameterTypes[0].processTypeParams(with: typeParamList)
var resultKind = nominal
resultKind.genericParameterTypes[0] = wrapped
return self.copy(kind: .nominal(resultKind))
}
let typeIDs = includingIdentifiers()
let hasGenericType = typeParamList.contains(where: { typeIDs.contains($0) })
if hasGenericType {
var result = self
result.kind = SwiftType.Any.kind
result.someOrAny = nil
return result
} else {
return self
}
case .closure(var closure):
if closure.arguments.contains(where: {
$0.type.processTypeParams(with: typeParamList) != $0.type
}) {
return .Any
}
closure.returning = closure.returning.processTypeParams(with: typeParamList)
return self.copy(kind: .closure(closure))
case .composition(let composition):
return self.copy(kind: .composition(.init(
elements: composition.elements.map { $0.processTypeParams(with: typeParamList) }
)))
}
}