public static void reportAmbiguousLabel( @NotNull BindingTrace trace, @NotNull JetSimpleNameExpression targetLabel, @NotNull Collection<DeclarationDescriptor> declarationsByLabel) { Collection<PsiElement> targets = Lists.newArrayList(); for (DeclarationDescriptor descriptor : declarationsByLabel) { PsiElement element = DescriptorToSourceUtils.descriptorToDeclaration(descriptor); assert element != null : "Label can only point to something in the same lexical scope"; targets.add(element); } if (!targets.isEmpty()) { trace.record(AMBIGUOUS_LABEL_TARGET, targetLabel, targets); } trace.report(AMBIGUOUS_LABEL.on(targetLabel)); }
private void reportEachConstructorOnCycle(@NotNull ConstructorDescriptor startConstructor) { ConstructorDescriptor currentConstructor = startConstructor; do { PsiElement constructorToReport = DescriptorToSourceUtils.descriptorToDeclaration(currentConstructor); if (constructorToReport != null) { JetConstructorDelegationCall call = ((JetSecondaryConstructor) constructorToReport).getDelegationCall(); assert call.getCalleeExpression() != null : "Callee expression of delegation call should not be null on cycle as there should be explicit 'this' calls"; trace.report(CYCLIC_CONSTRUCTOR_DELEGATION_CALL.on(call.getCalleeExpression())); } currentConstructor = getDelegatedConstructor(currentConstructor); assert currentConstructor != null : "Delegated constructor should not be null in cycle"; } while (startConstructor != currentConstructor); }