コード例 #1
0
 @Nullable
 private LazyClassDescriptor computeCompanionObjectDescriptor(
     @Nullable KtObjectDeclaration companionObject) {
   KtClassLikeInfo companionObjectInfo = getCompanionObjectInfo(companionObject);
   if (!(companionObjectInfo instanceof KtClassOrObjectInfo)) {
     return null;
   }
   Name name = ((KtClassOrObjectInfo) companionObjectInfo).getName();
   assert name != null;
   getUnsubstitutedMemberScope()
       .getContributedClassifier(name, NoLookupLocation.WHEN_GET_COMPANION_OBJECT);
   ClassDescriptor companionObjectDescriptor =
       c.getTrace().get(BindingContext.CLASS, companionObject);
   if (companionObjectDescriptor instanceof LazyClassDescriptor) {
     assert DescriptorUtils.isCompanionObject(companionObjectDescriptor)
         : "Not a companion object: " + companionObjectDescriptor;
     return (LazyClassDescriptor) companionObjectDescriptor;
   } else {
     return null;
   }
 }