Appearance
| 1 | namespace Semantic is | |
| 2 | use Types.Type | |
| 3 | ||
| 4 | class SEQUENCE_ARGUMENT_FORMAL is | |
| 5 | // The type an array literal argument is to be built at in place of | |
| 6 | // the one its elements gave it, or null where it needs no other. | |
| 7 | // That is the formal it fills, when the literal as built does not | |
| 8 | // convert to the formal but each of its elements converts to the | |
| 9 | // formal's element type: `[("+", APP())]` is a (string, APP)[], | |
| 10 | // which is not an Iterable[(string, Op[string])] because a tuple | |
| 11 | // is a value type, but built at that formal each tuple converts | |
| 12 | // as a tuple value does anywhere else. | |
| 13 | // | |
| 14 | // - formal: the formal the literal fills, once the call's type | |
| 15 | // arguments are bound | |
| 16 | // - actual: the type the literal was built at | |
| 17 | build_at(formal: Type?, actual: Type?) -> Type? static is | |
| 18 | if !formal? \/ !actual? then | |
| 19 | return null | |
| 20 | fi | |
| 21 | ||
| 22 | if !formal.is_settled \/ formal.is_wild \/ formal.contains_function_generic_argument then | |
| 23 | return null | |
| 24 | fi | |
| 25 | ||
| 26 | if !actual.is_settled \/ actual.is_wild then | |
| 27 | return null | |
| 28 | fi | |
| 29 | ||
| 30 | if formal.is_assignable_from(actual) then | |
| 31 | return null | |
| 32 | fi | |
| 33 | ||
| 34 | let formal_element = formal.get_element_type() | |
| 35 | let actual_element = actual.get_element_type() | |
| 36 | ||
| 37 | if !formal_element? \/ !actual_element? then | |
| 38 | return null | |
| 39 | fi | |
| 40 | ||
| 41 | if !formal_element.is_assignable_from(actual_element) then | |
| 42 | return null | |
| 43 | fi | |
| 44 | ||
| 45 | return formal | |
| 46 | si | |
| 47 | si | |
| 48 | si |