Home / Function/ mergeValueKinds() — react Function Reference

mergeValueKinds() — react Function Reference

Architecture documentation for the mergeValueKinds() function in InferMutationAliasingEffects.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  a7f0ad88_839a_0314_7ec4_dd3f06222c12["mergeValueKinds()"]
  d24875c3_c045_4414_2cc9_16f96d59c629["InferMutationAliasingEffects.ts"]
  a7f0ad88_839a_0314_7ec4_dd3f06222c12 -->|defined in| d24875c3_c045_4414_2cc9_16f96d59c629
  2f66f475_8a8e_7610_f27b_a0bed84c1b27["mergeAbstractValues()"]
  2f66f475_8a8e_7610_f27b_a0bed84c1b27 -->|calls| a7f0ad88_839a_0314_7ec4_dd3f06222c12
  041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"]
  a7f0ad88_839a_0314_7ec4_dd3f06222c12 -->|calls| 041ca752_10c1_3cda_1f5c_02f44a01310e
  style a7f0ad88_839a_0314_7ec4_dd3f06222c12 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts lines 2935–2975

function mergeValueKinds(a: ValueKind, b: ValueKind): ValueKind {
  if (a === b) {
    return a;
  } else if (a === ValueKind.MaybeFrozen || b === ValueKind.MaybeFrozen) {
    return ValueKind.MaybeFrozen;
    // after this a and b differ and neither are MaybeFrozen
  } else if (a === ValueKind.Mutable || b === ValueKind.Mutable) {
    if (a === ValueKind.Frozen || b === ValueKind.Frozen) {
      // frozen | mutable
      return ValueKind.MaybeFrozen;
    } else if (a === ValueKind.Context || b === ValueKind.Context) {
      // context | mutable
      return ValueKind.Context;
    } else {
      // mutable | immutable
      return ValueKind.Mutable;
    }
  } else if (a === ValueKind.Context || b === ValueKind.Context) {
    if (a === ValueKind.Frozen || b === ValueKind.Frozen) {
      // frozen | context
      return ValueKind.MaybeFrozen;
    } else {
      // context | immutable
      return ValueKind.Context;
    }
  } else if (a === ValueKind.Frozen || b === ValueKind.Frozen) {
    return ValueKind.Frozen;
  } else if (a === ValueKind.Global || b === ValueKind.Global) {
    return ValueKind.Global;
  } else {
    CompilerError.invariant(
      a === ValueKind.Primitive && b == ValueKind.Primitive,
      {
        reason: `Unexpected value kind in mergeValues()`,
        description: `Found kinds ${a} and ${b}`,
        loc: GeneratedSource,
      },
    );
    return ValueKind.Primitive;
  }
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does mergeValueKinds() do?
mergeValueKinds() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts.
Where is mergeValueKinds() defined?
mergeValueKinds() is defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts at line 2935.
What does mergeValueKinds() call?
mergeValueKinds() calls 1 function(s): invariant.
What calls mergeValueKinds()?
mergeValueKinds() is called by 1 function(s): mergeAbstractValues.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free