Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Implement arity check for function types #16

Closed
@jacob314

Description

@jacob314

From di/lib/src/injector.dart

library di.check_bind_args;

import "src/module.dart";
export "src/module.dart" show DEFAULT_VALUE, IDENTITY, isSet, isNotSet;

checkBindArgs(dynamic toValue, Function toFactory,
              Type toImplementation, List inject, toInstanceOf) {
  int count = 0;
  bool argCountMatch = true;
  if (isSet(toValue)) count++;
  if (isSet(toFactory)) {
    count++;
    var len = inject.length;
    switch (len) {
      case 0: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _0; break;
      case 1: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _1; break;
      case 2: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _2; break;
      case 3: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _3; break;
      case 4: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _4; break;
      case 5: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _5; break;
      case 6: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _6; break;
      case 7: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _7; break;
      case 8: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _8; break;
      case 9: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _9; break;
      case 10: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _10; break;
      case 11: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _11; break;
      case 12: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _12; break;
      case 13: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _13; break;
      case 14: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _14; break;
      case 15: argCountMatch =  /* severe: InvalidRuntimeCheckError */ toFactory is _15; break;
    }
    if (!argCountMatch) throw "toFactory's argument count does not match amount provided by inject";
  }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions