L-value of assignment expression can now be annotated with expression-targeted annotation #KT-9154 Fixed
This commit is contained in:
+6
@@ -335,6 +335,12 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
final ExpressionTypingContext context =
|
||||
contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE).replaceScope(scope).replaceContextDependency(INDEPENDENT);
|
||||
JetExpression leftOperand = expression.getLeft();
|
||||
if (leftOperand instanceof JetAnnotatedExpression) {
|
||||
// We will lose all annotations during deparenthesizing, so we have to resolve them right now
|
||||
components.annotationResolver.resolveAnnotationsWithArguments(
|
||||
scope, ((JetAnnotatedExpression) leftOperand).getAnnotationEntries(), context.trace
|
||||
);
|
||||
}
|
||||
JetExpression left = deparenthesizeWithResolutionStrategy(leftOperand, new Function<JetTypeReference, Void>() {
|
||||
@Override
|
||||
public Void apply(JetTypeReference reference) {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
@Target(AnnotationTarget.EXPRESSION)
|
||||
annotation class ExprAnn
|
||||
|
||||
fun foo(): Int {
|
||||
var a: Int
|
||||
@ExprAnn a = 1
|
||||
@ExprAnn a += 1
|
||||
return a
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
public fun foo(): kotlin.Int
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.annotation() public final class ExprAnn : kotlin.Annotation {
|
||||
public constructor ExprAnn()
|
||||
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
|
||||
}
|
||||
@@ -1040,6 +1040,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("assignment.kt")
|
||||
public void testAssignment() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/assignment.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("documented.kt")
|
||||
public void testDocumented() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/documented.kt");
|
||||
|
||||
Reference in New Issue
Block a user