From 51684b3fe1c9dc9b5c981cd105f088bdc2444b29 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 25 May 2015 12:07:01 +0300 Subject: [PATCH] Drop "Reflection types not loaded" diagnostic Reflection types are now considered to be built-in, so their absence means the runtime is broken and the compiler can't work at all; this condition probably should be handled on another level for all built-in types --- .../org/jetbrains/kotlin/diagnostics/Errors.java | 2 -- .../rendering/DefaultErrorMessages.java | 2 -- .../BasicExpressionTypingVisitor.java | 16 +--------------- .../tests/deprecated/functionUsage.kt | 2 +- .../tests/deprecated/genericConstructorUsage.kt | 2 +- .../tests/deprecated/propertyUsage.kt | 2 +- 6 files changed, 4 insertions(+), 22 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 5a206a364db..a49696f3842 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -446,8 +446,6 @@ public interface Errors { // Reflection - DiagnosticFactory0 REFLECTION_TYPES_NOT_LOADED = DiagnosticFactory0.create(ERROR); - DiagnosticFactory1 EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED = DiagnosticFactory1.create(ERROR); DiagnosticFactory0 CALLABLE_REFERENCE_LHS_NOT_A_CLASS = DiagnosticFactory0.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 50b3c468d8e..f397785ca6a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -596,8 +596,6 @@ public class DefaultErrorMessages { MAP.put(AMBIGUOUS_ANONYMOUS_TYPE_INFERRED, "Right-hand side has anonymous type. Please specify type explicitly", TO_STRING); - MAP.put(REFLECTION_TYPES_NOT_LOADED, "Reflection types can't be loaded. Please ensure that you have Kotlin Runtime in your classpath"); - MAP.put(EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED, "''{0}'' is a member and an extension at the same time. References to such elements are not allowed", NAME); MAP.put(CALLABLE_REFERENCE_LHS_NOT_A_CLASS, "Left hand side of a callable reference cannot be a type parameter"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index 85887b6268d..9571e76edf7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -502,11 +502,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { public JetTypeInfo visitClassLiteralExpression(@NotNull JetClassLiteralExpression expression, ExpressionTypingContext c) { JetType type = resolveClassLiteral(expression, c); if (type != null && !type.isError()) { - JetType kClassType = components.reflectionTypes.getKClassType(Annotations.EMPTY, type); - if (!kClassType.isError()) { - return TypeInfoFactoryPackage.createTypeInfo(kClassType, c); - } - c.trace.report(REFLECTION_TYPES_NOT_LOADED.on(expression.getDoubleColonTokenReference())); + return TypeInfoFactoryPackage.createTypeInfo(components.reflectionTypes.getKClassType(Annotations.EMPTY, type), c); } return TypeInfoFactoryPackage.createTypeInfo(ErrorUtils.createErrorType("Unresolved class"), c); @@ -723,11 +719,6 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { isExtension ); - if (type.isError()) { - context.trace.report(REFLECTION_TYPES_NOT_LOADED.on(expression.getDoubleColonTokenReference())); - return null; - } - AnonymousFunctionDescriptor functionDescriptor = new AnonymousFunctionDescriptor( context.scope.getContainingDeclaration(), Annotations.EMPTY, @@ -753,11 +744,6 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { JetType type = components.reflectionTypes.getKPropertyType(Annotations.EMPTY, receiverType, descriptor.getType(), isExtension, descriptor.isVar()); - if (type.isError()) { - context.trace.report(REFLECTION_TYPES_NOT_LOADED.on(expression.getDoubleColonTokenReference())); - return null; - } - LocalVariableDescriptor localVariable = new LocalVariableDescriptor(context.scope.getContainingDeclaration(), Annotations.EMPTY, Name.special(""), type, /* mutable = */ false, toSourceElement(expression)); diff --git a/compiler/testData/diagnostics/tests/deprecated/functionUsage.kt b/compiler/testData/diagnostics/tests/deprecated/functionUsage.kt index 79a174abf47..5a4b393d557 100644 --- a/compiler/testData/diagnostics/tests/deprecated/functionUsage.kt +++ b/compiler/testData/diagnostics/tests/deprecated/functionUsage.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_EXPRESSION, -REFLECTION_TYPES_NOT_LOADED +// !DIAGNOSTICS: -UNUSED_EXPRESSION class UsefulClass(val param: Int = 2) { fun get(instance: Any, property: PropertyMetadata) : Int = 1 diff --git a/compiler/testData/diagnostics/tests/deprecated/genericConstructorUsage.kt b/compiler/testData/diagnostics/tests/deprecated/genericConstructorUsage.kt index f5c6da93ed7..9c761989f26 100644 --- a/compiler/testData/diagnostics/tests/deprecated/genericConstructorUsage.kt +++ b/compiler/testData/diagnostics/tests/deprecated/genericConstructorUsage.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_EXPRESSION, -REFLECTION_TYPES_NOT_LOADED, -UNUSED_PARAMETER +// !DIAGNOSTICS: -UNUSED_EXPRESSION, -UNUSED_PARAMETER open class C() { deprecated("") diff --git a/compiler/testData/diagnostics/tests/deprecated/propertyUsage.kt b/compiler/testData/diagnostics/tests/deprecated/propertyUsage.kt index c9bbf666db8..6282e77f145 100644 --- a/compiler/testData/diagnostics/tests/deprecated/propertyUsage.kt +++ b/compiler/testData/diagnostics/tests/deprecated/propertyUsage.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_EXPRESSION, -REFLECTION_TYPES_NOT_LOADED +// !DIAGNOSTICS: -UNUSED_EXPRESSION class Delegate() { deprecated("text")