JS backend: descriptor parameter of DescriptorPredicate#apply marked as @NotNull.
This commit is contained in:
+3
-4
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.k2js.translate.intrinsic.functions.factories;
|
package org.jetbrains.k2js.translate.intrinsic.functions.factories;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.intellij.openapi.util.Pair;
|
import com.intellij.openapi.util.Pair;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -36,11 +35,11 @@ public abstract class CompositeFIF implements FunctionIntrinsicFactory {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Predicate<FunctionDescriptor> getPredicate() {
|
public DescriptorPredicate getPredicate() {
|
||||||
return new DescriptorPredicate() {
|
return new DescriptorPredicate() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(@Nullable FunctionDescriptor descriptor) {
|
public boolean apply(@NotNull FunctionDescriptor descriptor) {
|
||||||
return descriptor != null && findIntrinsic(descriptor) != null;
|
return findIntrinsic(descriptor) != null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -53,8 +53,7 @@ public enum PrimitiveUnaryOperationFIF implements FunctionIntrinsicFactory {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private static final DescriptorPredicate NO_PARAMETERS = new DescriptorPredicate() {
|
private static final DescriptorPredicate NO_PARAMETERS = new DescriptorPredicate() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(@Nullable FunctionDescriptor descriptor) {
|
public boolean apply(@NotNull FunctionDescriptor descriptor) {
|
||||||
assert descriptor != null;
|
|
||||||
return !JsDescriptorUtils.hasParameters(descriptor);
|
return !JsDescriptorUtils.hasParameters(descriptor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -72,7 +71,7 @@ public enum PrimitiveUnaryOperationFIF implements FunctionIntrinsicFactory {
|
|||||||
public FunctionIntrinsic getIntrinsic(@NotNull FunctionDescriptor descriptor) {
|
public FunctionIntrinsic getIntrinsic(@NotNull FunctionDescriptor descriptor) {
|
||||||
Name name = descriptor.getName();
|
Name name = descriptor.getName();
|
||||||
|
|
||||||
JsUnaryOperator jsOperator = null;
|
JsUnaryOperator jsOperator;
|
||||||
if ("inv".equals(name.asString())) {
|
if ("inv".equals(name.asString())) {
|
||||||
jsOperator = JsUnaryOperator.BIT_NOT;
|
jsOperator = JsUnaryOperator.BIT_NOT;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -17,10 +17,10 @@
|
|||||||
package org.jetbrains.k2js.translate.intrinsic.functions.patterns;
|
package org.jetbrains.k2js.translate.intrinsic.functions.patterns;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||||
|
|
||||||
public interface DescriptorPredicate extends Predicate<FunctionDescriptor> {
|
public interface DescriptorPredicate extends Predicate<FunctionDescriptor> {
|
||||||
@Override
|
@Override
|
||||||
boolean apply(@Nullable FunctionDescriptor descriptor);
|
boolean apply(@SuppressWarnings("NullableProblems") @NotNull FunctionDescriptor descriptor);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-5
@@ -18,7 +18,6 @@ package org.jetbrains.k2js.translate.intrinsic.functions.patterns;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||||
@@ -85,8 +84,7 @@ public final class PatternBuilder {
|
|||||||
|
|
||||||
return new DescriptorPredicate() {
|
return new DescriptorPredicate() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(@Nullable FunctionDescriptor descriptor) {
|
public boolean apply(@NotNull FunctionDescriptor descriptor) {
|
||||||
assert descriptor != null;
|
|
||||||
//TODO: no need to wrap if we check beforehand
|
//TODO: no need to wrap if we check beforehand
|
||||||
try {
|
try {
|
||||||
return doApply(descriptor);
|
return doApply(descriptor);
|
||||||
@@ -146,8 +144,8 @@ public final class PatternBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(@Nullable FunctionDescriptor functionDescriptor) {
|
public boolean apply(@NotNull FunctionDescriptor functionDescriptor) {
|
||||||
if (functionDescriptor == null || (functionDescriptor.getReceiverParameter() == null) == receiverParameterExists) {
|
if ((functionDescriptor.getReceiverParameter() == null) == receiverParameterExists) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user