Buggy code:
public class BodyResolver { private final TopDownAnalysisContext context ; private final ObservableBindingTrace trace ; public BodyResolver ( TopDownAnalysisContext context ) { } public void resolveBehaviorDeclarationBodies ( ) { } private void resolveDelegationSpecifierLists ( ) { } private void resolveDelegationSpecifierList ( final JetClassOrObject jetClass , final MutableClassDescriptor descriptor ) { } private void checkSupertypeList ( @ NotNull MutableClassDescriptor supertypeOwner , @ NotNull Map < JetTypeReference , JetType > supertypes , Set < TypeConstructor > allowedFinalSupertypes ) { } private void resolveClassAnnotations ( ) { } private void resolveAnonymousInitializers ( ) { } private void resolveAnonymousInitializers ( JetClassOrObject jetClassOrObject , MutableClassDescriptor classDescriptor ) { if ( ! ( context . completeAnalysisNeeded ( jetClassOrObject ) ) ) return ; List < JetClassInitializer > anonymousInitializers = jetClassOrObject . getAnonymousInitializers ( ) ; <START_BUG> if ( jetClassOrObject . hasPrimaryConstructor ( ) ) { <END_BUG> ConstructorDescriptor primaryConstructor = classDescriptor . getUnsubstitutedPrimaryConstructor ( ) ; assert primaryConstructor != null ; final JetScope scopeForInitializers = classDescriptor . getScopeForInitializers ( ) ; ExpressionTypingServices typeInferrer = context . getSemanticServices ( ) . getTypeInferrerServices ( trace ) ; for ( JetClassInitializer anonymousInitializer : anonymousInitializers ) { typeInferrer . getType ( scopeForInitializers , anonymousInitializer . getBody ( ) , NO_EXPECTED_TYPE ) ; } } else { for ( JetClassInitializer anonymousInitializer : anonymousInitializers ) { context . getTrace ( ) . report ( ANONYMOUS_INITIALIZER_WITHOUT_CONSTRUCTOR . on ( anonymousInitializer ) ) ; } } } private void resolvePrimaryConstructorParameters ( ) { } private void resolveSecondaryConstructorBodies ( ) { } private void resolveSecondaryConstructorBody ( JetSecondaryConstructor declaration , final ConstructorDescriptor descriptor ) { } private void resolvePropertyDeclarationBodies ( ) { } private JetScope makeScopeForPropertyAccessor ( @ NotNull JetPropertyAccessor accessor , PropertyDescriptor propertyDescriptor ) { } private void resolvePropertyAccessors ( JetProperty property , PropertyDescriptor propertyDescriptor ) { } private ObservableBindingTrace createFieldTrackingTrace ( final PropertyDescriptor propertyDescriptor ) { } private void resolvePropertyInitializer ( JetProperty property , PropertyDescriptor propertyDescriptor , JetExpression initializer , JetScope scope ) { } private void resolveFunctionBodies ( ) { } private void resolveFunctionBody ( @ NotNull BindingTrace trace , @ NotNull JetDeclarationWithBody function , @ NotNull FunctionDescriptor functionDescriptor , @ NotNull JetScope declaringScope ) { } private void checkDefaultParameterValues ( List < JetParameter > valueParameters , List < ValueParameterDescriptor > valueParameterDescriptors , JetScope declaringScope ) { } private static void computeDeferredType ( JetType type ) { } private void computeDeferredTypes ( ) { } }

Fix:
if ( ( classDescriptor . getUnsubstitutedPrimaryConstructor ( ) ) != null ) {