Appearance
| 1 | namespace Semantic.Symbols is | |
| 2 | use Types.Type | |
| 3 | ||
| 4 | // Resolves a member against each of a type variable's bounds and merges | |
| 5 | // what comes back, so a parameter declared `[T: A /\ B]` exposes the | |
| 6 | // members of both. | |
| 7 | // | |
| 8 | // Resolution over per-bound results: | |
| 9 | // | |
| 10 | // - 0 results → null | |
| 11 | // - 1 result → that result | |
| 12 | // - all FUNCTION_GROUPs → folded with merged_over, which keeps every | |
| 13 | // distinct signature and drops same-signature repeats. Shared | |
| 14 | // ancestry is the common repeat (`IComparisonOperators` extends | |
| 15 | // `IEqualityOperators`, so two bounds often contribute the same | |
| 16 | // inherited member twice), and a genuine same-signature clash | |
| 17 | // between unrelated bounds resolves to the first bound's member. | |
| 18 | // - mixed kinds → the first bound's result wins, the same | |
| 19 | // pragmatic fallback INTERSECTION.find_member | |
| 20 | // applies to a multi-trait clash. | |
| 21 | class GENERIC_ARGUMENT_MEMBER_LOOKUP(_bounds: Collections.List[Type]) is | |
| 22 | find_member(name: string) -> Symbol? is | |
| 23 | let first: Symbol? mut = null | |
| 24 | let merged_group: FUNCTION_GROUP? mut = null | |
| 25 | let count mut = 0 | |
| 26 | let all_groups mut = true | |
| 27 | ||
| 28 | for bound in _bounds do | |
| 29 | let result = bound.find_member(name) | |
| 30 | ||
| 31 | if !result? then | |
| 32 | continue | |
| 33 | fi | |
| 34 | ||
| 35 | count = count + 1 | |
| 36 | ||
| 37 | if !first? then | |
| 38 | first = result | |
| 39 | fi | |
| 40 | ||
| 41 | if isa FUNCTION_GROUP(result) then | |
| 42 | merged_group = | |
| 43 | if let prior = merged_group then | |
| 44 | prior.merged_over(result) | |
| 45 | else | |
| 46 | result | |
| 47 | fi | |
| 48 | else | |
| 49 | all_groups = false | |
| 50 | fi | |
| 51 | od | |
| 52 | ||
| 53 | if count == 0 then | |
| 54 | return null | |
| 55 | fi | |
| 56 | ||
| 57 | if count == 1 then | |
| 58 | return first | |
| 59 | fi | |
| 60 | ||
| 61 | if all_groups then | |
| 62 | return merged_group | |
| 63 | fi | |
| 64 | ||
| 65 | return first | |
| 66 | si | |
| 67 | si | |
| 68 | si |