Annotation arguments resolve refactoring via ForceResolveUtil. Deptecated...Intention fixed accordingly
This commit is contained in:
@@ -587,8 +587,6 @@ public class BodyResolver {
|
||||
resolvePropertyDelegate(c, property, propertyDescriptor, delegateExpression, propertyScope, propertyScope);
|
||||
}
|
||||
|
||||
AnnotationResolver.resolveAnnotationsArguments(propertyDescriptor.getAnnotations());
|
||||
|
||||
resolvePropertyAccessors(c, property, propertyDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,6 @@ class FunctionDescriptorResolver(
|
||||
typeResolver.resolveType(innerScope, receiverTypeRef, trace, true)
|
||||
else
|
||||
expectedFunctionType.getReceiverType()
|
||||
receiverType?.let { AnnotationResolver.resolveAnnotationsArguments(it.getAnnotations()) }
|
||||
|
||||
|
||||
val valueParameterDescriptors = createValueParameterDescriptors(function, functionDescriptor, innerScope, trace, expectedFunctionType)
|
||||
@@ -167,6 +166,7 @@ class FunctionDescriptorResolver(
|
||||
modality,
|
||||
visibility
|
||||
)
|
||||
receiverType?.let { AnnotationResolver.resolveAnnotationsArguments(it.getAnnotations()) }
|
||||
for (valueParameterDescriptor in valueParameterDescriptors) {
|
||||
AnnotationResolver.resolveAnnotationsArguments(valueParameterDescriptor.getType().getAnnotations())
|
||||
}
|
||||
|
||||
@@ -270,6 +270,7 @@ public class LazyTopDownAnalyzer {
|
||||
val descriptor = lazyDeclarationResolver!!.resolveToDescriptor(property) as PropertyDescriptor
|
||||
|
||||
c.getProperties().put(property, descriptor)
|
||||
ForceResolveUtil.forceResolveAllContents(descriptor.getAnnotations())
|
||||
registerTopLevelFqName(topLevelFqNames, property, descriptor)
|
||||
|
||||
registerScope(c, property)
|
||||
@@ -280,7 +281,12 @@ public class LazyTopDownAnalyzer {
|
||||
|
||||
private fun createFunctionDescriptors(c: TopDownAnalysisContext, functions: List<JetNamedFunction>) {
|
||||
for (function in functions) {
|
||||
c.getFunctions().put(function, lazyDeclarationResolver!!.resolveToDescriptor(function) as SimpleFunctionDescriptor)
|
||||
val simpleFunctionDescriptor = lazyDeclarationResolver!!.resolveToDescriptor(function) as SimpleFunctionDescriptor
|
||||
c.getFunctions().put(function, simpleFunctionDescriptor)
|
||||
ForceResolveUtil.forceResolveAllContents(simpleFunctionDescriptor.getAnnotations())
|
||||
for (parameterDescriptor in simpleFunctionDescriptor.getValueParameters()) {
|
||||
ForceResolveUtil.forceResolveAllContents(parameterDescriptor.getAnnotations())
|
||||
}
|
||||
registerScope(c, function)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.resolve.AnnotationResolver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
@@ -62,6 +63,7 @@ public class ForceResolveUtil {
|
||||
|
||||
public static void forceResolveAllContents(@NotNull Annotations annotations) {
|
||||
doForceResolveAllContents(annotations);
|
||||
AnnotationResolver.resolveAnnotationsArguments(annotations);
|
||||
for (AnnotationDescriptor annotation : annotations) {
|
||||
doForceResolveAllContents(annotation);
|
||||
}
|
||||
@@ -85,6 +87,7 @@ public class ForceResolveUtil {
|
||||
forceResolveAllContents(typeParameterDescriptor.getUpperBounds());
|
||||
}
|
||||
forceResolveAllContents(callableDescriptor.getReturnType());
|
||||
forceResolveAllContents(callableDescriptor.getAnnotations());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -211,7 +211,6 @@ public class LazyDeclarationResolver {
|
||||
throw new IllegalStateException("No descriptor resolved for " + declaration + ":\n" +
|
||||
PsiUtilPackage.getElementTextWithContext(declaration));
|
||||
}
|
||||
AnnotationResolver.resolveAnnotationsArguments(result.getAnnotations());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -90,6 +90,7 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express
|
||||
context.trace, context.dataFlowInfo, context.expectedType
|
||||
)
|
||||
}
|
||||
// Necessary for local functions
|
||||
AnnotationResolver.resolveAnnotationsArguments(functionDescriptor.getAnnotations());
|
||||
|
||||
val functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(context.scope, functionDescriptor, context.trace)
|
||||
@@ -140,7 +141,7 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express
|
||||
val expectedType = context.expectedType
|
||||
val functionTypeExpected = !noExpectedType(expectedType) && KotlinBuiltIns.isFunctionOrExtensionFunctionType(expectedType)
|
||||
|
||||
val functionDescriptor = createFunctionDescriptor(expression, context)
|
||||
val functionDescriptor = createFunctionLiteralDescriptor(expression, context)
|
||||
val safeReturnType = computeReturnType(expression, context, functionDescriptor, functionTypeExpected)
|
||||
functionDescriptor.setReturnType(safeReturnType)
|
||||
|
||||
@@ -153,7 +154,7 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express
|
||||
return createCheckedTypeInfo(resultType, context, expression)
|
||||
}
|
||||
|
||||
private fun createFunctionDescriptor(
|
||||
private fun createFunctionLiteralDescriptor(
|
||||
expression: JetFunctionLiteralExpression,
|
||||
context: ExpressionTypingContext
|
||||
): AnonymousFunctionDescriptor {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
annotation class My
|
||||
|
||||
fun foo() {
|
||||
val s = object {
|
||||
@My fun bar() {}
|
||||
}
|
||||
s.bar()
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
internal fun foo(): kotlin.Unit
|
||||
|
||||
internal final annotation class My : kotlin.Annotation {
|
||||
public constructor My()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
annotation class My
|
||||
|
||||
fun foo(): Int {
|
||||
val s = object {
|
||||
@My val bar: Int = 0
|
||||
}
|
||||
return s.bar
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
internal fun foo(): kotlin.Int
|
||||
|
||||
internal final annotation class My : kotlin.Annotation {
|
||||
public constructor My()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Result type can be annotated
|
||||
annotation class My(val x: Int)
|
||||
|
||||
fun foo(): @My(42) Int = 24
|
||||
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
internal fun foo(): @[My(x = IntegerValueType(42): IntegerValueType(42))] kotlin.Int
|
||||
|
||||
internal final annotation class My : kotlin.Annotation {
|
||||
public constructor My(/*0*/ x: kotlin.Int)
|
||||
internal final val x: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -615,6 +615,24 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AnnotatedLocalObjectFun.kt")
|
||||
public void testAnnotatedLocalObjectFun() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectFun.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AnnotatedLocalObjectProperty.kt")
|
||||
public void testAnnotatedLocalObjectProperty() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectProperty.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AnnotatedResultType.kt")
|
||||
public void testAnnotatedResultType() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("AnnotationForClassTypeParameter.kt")
|
||||
public void testAnnotationForClassTypeParameter() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.kt");
|
||||
|
||||
@@ -262,7 +262,6 @@ public abstract class ElementResolver protected(
|
||||
}
|
||||
|
||||
private fun doResolveAnnotations(annotations: Annotations) {
|
||||
AnnotationResolver.resolveAnnotationsArguments(annotations)
|
||||
ForceResolveUtil.forceResolveAllContents(annotations)
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -105,6 +105,7 @@ public class DeprecatedCallableAddReplaceWithIntention : JetSelfTargetingRangeIn
|
||||
val bindingContext = this.analyze()
|
||||
// val deprecatedConstructor = KotlinBuiltIns.getInstance().getDeprecatedAnnotation().getUnsubstitutedPrimaryConstructor()
|
||||
for (entry in getAnnotationEntries()) {
|
||||
entry.analyze()
|
||||
val resolvedCall = entry.getCalleeExpression().getResolvedCall(bindingContext) ?: continue
|
||||
if (!resolvedCall.getStatus().isSuccess()) continue
|
||||
// if (resolvedCall.getResultingDescriptor() != deprecatedConstructor) continue
|
||||
|
||||
Reference in New Issue
Block a user