# All files / src/semantics map-generic.js

100% Statements 11/11
100% Branches 0/0
100% Functions 1/1
100% Lines 11/11

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    21x
    21x
    21x

    21x
    4x
    4x
    4x
    4x

    4x

    4x
    4x

     // @flow
    import curry from "curry";
    import Syntax from "../Syntax";
    import { CLOSURE_TYPE } from "./metadata";

    export const mapGeneric = curry((options, node, _) => {
      const { types } = options;
      const [generic, T] = node.params;
      const realType = types[T.value];
      const [args, result] = realType.params;
      // Patch the node to be a real type which we can reference later
      const patch = {
        ...realType,
        range: generic.range,
        value: node.value,
        meta: { ...realType.meta, [CLOSURE_TYPE]: generic.value === "Lambda" },
        params: [
          {
            ...args,
            params: [
              {
                ...args,
                params: [],
                type: "i32",
                value: "i32",
                Type: Syntax.Type,
              },
              ...args.params,
            ],
          },
          result,
        ],
      };
      types[patch.value] = patch;
      return patch;
    });