getBestCandidate method

TypeInfo getBestCandidate(
  1. TypeInfo type
)

Implementation

TypeInfo getBestCandidate(TypeInfo type) {

  List<TypeInfo> candidates = getNonAbstractSubtypes(type);

  candidates.sort((t1, t2) => typeSystem.isSubtypeOf(t1.type, t2.type) ? 1 : 0);

  if (candidates.length > 1) {
    //throw new Exception('too many ${type.displayName}');
  }
  if (candidates.length == 0) {
    throw new Exception('no initialisation candidate for ' + type.fullName);
  }
  return candidates[0];
}