Appearance
| 1 | namespace Semantic is | |
| 2 | use Types.Type | |
| 3 | ||
| 4 | // Where an expression whose result type is still a placeholder is | |
| 5 | // passed to a formal that is settled, the formal is what that result | |
| 6 | // has to be: an empty list literal handed to a `string[]` parameter | |
| 7 | // holds strings. The formal and the actual are walked in step, and | |
| 8 | // each result placeholder found in the actual is given the settled | |
| 9 | // type in the formal's matching position as a lower bound. Nothing | |
| 10 | // else is bounded: a local's placeholder takes its type from its own | |
| 11 | // initializer and assignments, not from a call it is passed to. | |
| 12 | class RESULT_ORIGIN_OFFER is | |
| 13 | offer(formal: Type?, actual: Type?) static is | |
| 14 | if !formal? \/ !actual? then | |
| 15 | return | |
| 16 | fi | |
| 17 | ||
| 18 | if let placeholder: Types.INFERRED_VARIABLE_TYPE = actual then | |
| 19 | if isa Symbols.INFERRED_RESULT_ORIGIN(placeholder.origin) /\ formal.is_settled then | |
| 20 | let _ = INFERENCE_TRACE.add_lower_bound("result_origin.formal", placeholder.origin, formal) | |
| 21 | fi | |
| 22 | ||
| 23 | return | |
| 24 | fi | |
| 25 | ||
| 26 | if !actual.contains_inferred then | |
| 27 | return | |
| 28 | fi | |
| 29 | ||
| 30 | if let actual_generic: Types.GENERIC = actual then | |
| 31 | if let formal_generic: Types.GENERIC = formal then | |
| 32 | if | |
| 33 | formal_generic.symbol.root_unspecialized_symbol == actual_generic.symbol.root_unspecialized_symbol /\ | |
| 34 | formal_generic.arguments.count == actual_generic.arguments.count | |
| 35 | then | |
| 36 | for i in 0..actual_generic.arguments.count do | |
| 37 | offer(formal_generic.arguments[i], actual_generic.arguments[i]) | |
| 38 | od | |
| 39 | fi | |
| 40 | fi | |
| 41 | fi | |
| 42 | si | |
| 43 | si | |
| 44 | si |