示例#1
0
 public static <D extends CallableDescriptor> void splitLexicallyLocalDescriptors(
     @NotNull Collection<ResolutionCandidate<D>> allDescriptors,
     @NotNull DeclarationDescriptor containerOfTheCurrentLocality,
     @NotNull Collection<ResolutionCandidate<D>> local,
     @NotNull Collection<ResolutionCandidate<D>> nonlocal) {
   for (ResolutionCandidate<D> resolvedCall : allDescriptors) {
     if (DescriptorUtils.isLocal(containerOfTheCurrentLocality, resolvedCall.getDescriptor())) {
       local.add(resolvedCall);
     } else {
       nonlocal.add(resolvedCall);
     }
   }
 }
示例#2
0
 private static <D extends CallableDescriptor> boolean setImpliedThis(
     @NotNull JetScope scope, ResolutionCandidate<D> candidate) {
   ReceiverDescriptor expectedThisObject = candidate.getDescriptor().getExpectedThisObject();
   if (!expectedThisObject.exists()) return true;
   List<ReceiverDescriptor> receivers = Lists.newArrayList();
   scope.getImplicitReceiversHierarchy(receivers);
   for (ReceiverDescriptor receiver : receivers) {
     if (JetTypeChecker.INSTANCE.isSubtypeOf(receiver.getType(), expectedThisObject.getType())) {
       // TODO : Autocasts & nullability
       candidate.setThisObject(expectedThisObject);
       return true;
     }
   }
   return false;
 }