Rename KotlinBuiltIns.isAny -> isAnyOrNullableAny
Reduce confusion, prevent bugs
This commit is contained in:
+1
-1
@@ -72,7 +72,7 @@ public class ArgumentTypeResolver {
|
|||||||
@NotNull JetType expectedType
|
@NotNull JetType expectedType
|
||||||
) {
|
) {
|
||||||
if (actualType == PLACEHOLDER_FUNCTION_TYPE) {
|
if (actualType == PLACEHOLDER_FUNCTION_TYPE) {
|
||||||
return isFunctionOrErrorType(expectedType) || KotlinBuiltIns.getInstance().isAny(expectedType); //todo function type extends
|
return isFunctionOrErrorType(expectedType) || KotlinBuiltIns.getInstance().isAnyOrNullableAny(expectedType); //todo function type extends
|
||||||
}
|
}
|
||||||
return JetTypeChecker.INSTANCE.isSubtypeOf(actualType, expectedType);
|
return JetTypeChecker.INSTANCE.isSubtypeOf(actualType, expectedType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ public class DataFlowUtils {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static JetType checkImplicitCast(@Nullable JetType expressionType, @NotNull JetExpression expression, @NotNull ExpressionTypingContext context, boolean isStatement) {
|
public static JetType checkImplicitCast(@Nullable JetType expressionType, @NotNull JetExpression expression, @NotNull ExpressionTypingContext context, boolean isStatement) {
|
||||||
if (expressionType != null && context.expectedType == NO_EXPECTED_TYPE && context.contextDependency == INDEPENDENT && !isStatement
|
if (expressionType != null && context.expectedType == NO_EXPECTED_TYPE && context.contextDependency == INDEPENDENT && !isStatement
|
||||||
&& (KotlinBuiltIns.getInstance().isUnit(expressionType) || KotlinBuiltIns.getInstance().isAny(expressionType))) {
|
&& (KotlinBuiltIns.getInstance().isUnit(expressionType) || KotlinBuiltIns.getInstance().isAnyOrNullableAny(expressionType))) {
|
||||||
context.trace.report(IMPLICIT_CAST_TO_UNIT_OR_ANY.on(expression, expressionType));
|
context.trace.report(IMPLICIT_CAST_TO_UNIT_OR_ANY.on(expression, expressionType));
|
||||||
}
|
}
|
||||||
return expressionType;
|
return expressionType;
|
||||||
|
|||||||
@@ -939,7 +939,7 @@ public class KotlinBuiltIns {
|
|||||||
&& type.getConstructor() == getNothing().getTypeConstructor();
|
&& type.getConstructor() == getNothing().getTypeConstructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAny(@NotNull JetType type) {
|
public boolean isAnyOrNullableAny(@NotNull JetType type) {
|
||||||
return !(type instanceof NamespaceType) &&
|
return !(type instanceof NamespaceType) &&
|
||||||
type.getConstructor() == getAny().getTypeConstructor();
|
type.getConstructor() == getAny().getTypeConstructor();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -636,7 +636,8 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
|
|||||||
|
|
||||||
if (!klass.equals(KotlinBuiltIns.getInstance().getNothing())) {
|
if (!klass.equals(KotlinBuiltIns.getInstance().getNothing())) {
|
||||||
Collection<JetType> supertypes = klass.getTypeConstructor().getSupertypes();
|
Collection<JetType> supertypes = klass.getTypeConstructor().getSupertypes();
|
||||||
if (supertypes.isEmpty() || !alwaysRenderAny && supertypes.size() == 1 && KotlinBuiltIns.getInstance().isAny(supertypes.iterator().next())) {
|
if (supertypes.isEmpty() || !alwaysRenderAny && supertypes.size() == 1 && KotlinBuiltIns.getInstance().isAnyOrNullableAny(
|
||||||
|
supertypes.iterator().next())) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
builder.append(" : ");
|
builder.append(" : ");
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class JetPluginUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkTypeIsStandard(JetType type, Project project) {
|
public static boolean checkTypeIsStandard(JetType type, Project project) {
|
||||||
if (KotlinBuiltIns.getInstance().isAny(type) || KotlinBuiltIns.getInstance().isNothingOrNullableNothing(type) || KotlinBuiltIns.getInstance().isUnit(type) ||
|
if (KotlinBuiltIns.getInstance().isAnyOrNullableAny(type) || KotlinBuiltIns.getInstance().isNothingOrNullableNothing(type) || KotlinBuiltIns.getInstance().isUnit(type) ||
|
||||||
KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(type)) {
|
KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(type)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class AddFunctionToSupertypeFix extends JetHintAction<JetNamedFunction> {
|
|||||||
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
|
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
|
||||||
// TODO: filter out impossible supertypes (for example when argument's type isn't visible in a superclass).
|
// TODO: filter out impossible supertypes (for example when argument's type isn't visible in a superclass).
|
||||||
for (ClassDescriptor supertypeDescriptor : getSupertypes(classDescriptor)) {
|
for (ClassDescriptor supertypeDescriptor : getSupertypes(classDescriptor)) {
|
||||||
if (KotlinBuiltIns.getInstance().isAny(supertypeDescriptor.getDefaultType())) continue;
|
if (KotlinBuiltIns.getInstance().isAnyOrNullableAny(supertypeDescriptor.getDefaultType())) continue;
|
||||||
functions.add(generateFunctionSignatureForType(functionDescriptor, supertypeDescriptor));
|
functions.add(generateFunctionSignatureForType(functionDescriptor, supertypeDescriptor));
|
||||||
}
|
}
|
||||||
return functions;
|
return functions;
|
||||||
|
|||||||
Reference in New Issue
Block a user