private static void generateTypeCheckBarrierIfNeeded( @NotNull InstructionAdapter iv, @NotNull FunctionDescriptor descriptor, @NotNull Type returnType, @Nullable final Type delegateParameterType) { BuiltinMethodsWithSpecialGenericSignature.DefaultValue defaultValue = BuiltinMethodsWithSpecialGenericSignature.getDefaultValueForOverriddenBuiltinFunction( descriptor); if (defaultValue == null) return; assert descriptor.getValueParameters().size() == 1 : "Should be descriptor with one value parameter, but found: " + descriptor; boolean isCheckForAny = delegateParameterType == null || OBJECT_TYPE.equals(delegateParameterType); final KotlinType kotlinType = descriptor.getValueParameters().get(0).getType(); if (isCheckForAny && TypeUtils.isNullableType(kotlinType)) return; iv.load(1, OBJECT_TYPE); Label afterBarrier = new Label(); if (isCheckForAny) { assert !TypeUtils.isNullableType(kotlinType) : "Only bridges for not-nullable types are necessary"; iv.ifnonnull(afterBarrier); } else { CodegenUtilKt.generateIsCheck(iv, kotlinType, boxType(delegateParameterType)); iv.ifne(afterBarrier); } StackValue.constant(defaultValue.getValue(), returnType).put(returnType, iv); iv.areturn(returnType); iv.visitLabel(afterBarrier); }