@@ -170,22 +170,34 @@ public struct TerminatorResult {
170
170
/// ArgumentConventions indexed on a SIL function's argument index.
171
171
/// When derived from an ApplySite, this corresponds to the callee index.
172
172
public struct ArgumentConventions : Collection , CustomStringConvertible {
173
- public let functionConvention : FunctionConvention
173
+ public let originalFunctionConvention : FunctionConvention
174
+ public let substitutedFunctionConvention : FunctionConvention ?
174
175
175
- public var bridgedFunctionType : BridgedASTType { functionConvention. bridgedFunctionType }
176
-
177
- /// Indirect results including the error result.
176
+ /// Indirect results including the error result. Apply type
177
+ /// substitution if it is available.
178
178
public var indirectSILResults : LazyFilterSequence < FunctionConvention . Results > {
179
- functionConvention. indirectSILResults
179
+ if let substitutedFunctionConvention {
180
+ return substitutedFunctionConvention. indirectSILResults
181
+ }
182
+ return originalFunctionConvention. indirectSILResults
180
183
}
181
184
182
185
/// Number of SIL arguments for the function type's results
183
186
/// including the error result. Use this to avoid lazy iteration.
184
187
var indirectSILResultCount : Int {
185
- functionConvention. indirectSILResultCount
188
+ originalFunctionConvention. indirectSILResultCount
189
+ }
190
+
191
+ public var originalParameters : FunctionConvention . Parameters {
192
+ originalFunctionConvention. parameters
186
193
}
187
194
188
- public var parameters : FunctionConvention . Parameters { functionConvention. parameters }
195
+ public var parameters : FunctionConvention . Parameters {
196
+ if let substitutedFunctionConvention {
197
+ return substitutedFunctionConvention. parameters
198
+ }
199
+ return originalFunctionConvention. parameters
200
+ }
189
201
190
202
public var startIndex : Int { 0 }
191
203
@@ -207,17 +219,22 @@ public struct ArgumentConventions : Collection, CustomStringConvertible {
207
219
208
220
/// The SIL argument index of the 'self' paramter.
209
221
var selfIndex : Int ? {
210
- guard functionConvention . hasSelfParameter else { return nil }
222
+ guard originalFunctionConvention . hasSelfParameter else { return nil }
211
223
// self is the last parameter
212
224
return endIndex - 1
213
225
}
214
226
215
227
public var description : String {
216
- var str = String ( taking: bridgedFunctionType. getDebugDescription ( ) )
228
+ var str = String ( taking: originalFunctionConvention. bridgedFunctionType. getDebugDescription ( ) )
229
+ if let substitutedFunctionConvention {
230
+ str += " \n " + String( taking: substitutedFunctionConvention. bridgedFunctionType. getDebugDescription ( ) )
231
+ }
217
232
indirectSILResults. forEach {
218
233
str += " \n indirect result: " + $0. description
219
234
}
220
- parameters. forEach { str += " \n parameter: " + $0. description }
235
+ parameters. forEach {
236
+ str += " \n parameter: " + $0. description
237
+ }
221
238
return str
222
239
}
223
240
}
0 commit comments