Resolve parenthesized element as expression
This commit is contained in:
+1
-5
@@ -107,15 +107,11 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
@Override
|
||||
public JetTypeInfo visitParenthesizedExpression(@NotNull JetParenthesizedExpression expression, ExpressionTypingContext context) {
|
||||
return visitParenthesizedExpression(expression, context, false);
|
||||
}
|
||||
|
||||
public JetTypeInfo visitParenthesizedExpression(JetParenthesizedExpression expression, ExpressionTypingContext context, boolean isStatement) {
|
||||
JetExpression innerExpression = expression.getExpression();
|
||||
if (innerExpression == null) {
|
||||
return JetTypeInfo.create(null, context.dataFlowInfo);
|
||||
}
|
||||
return facade.getTypeInfo(innerExpression, context.replaceScope(context.scope), isStatement);
|
||||
return facade.getTypeInfo(innerExpression, context.replaceScope(context.scope));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
-5
@@ -415,11 +415,6 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
return components.expressionTypingServices.getBlockReturnedType(expression, context, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetTypeInfo visitParenthesizedExpression(@NotNull JetParenthesizedExpression expression, ExpressionTypingContext context) {
|
||||
return basic.visitParenthesizedExpression(expression, context, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetTypeInfo visitLabeledExpression(@NotNull JetLabeledExpression expression, ExpressionTypingContext context) {
|
||||
return basic.visitLabeledExpression(expression, context, true);
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
data class A(val a: Int, val b: Int)
|
||||
|
||||
fun box() : String
|
||||
{
|
||||
(@a val x = 1)
|
||||
(@b fun a() = 2)
|
||||
(@c val (z, z2) = A(1, 2))
|
||||
|
||||
if (x != 1) return "fail 1"
|
||||
|
||||
if (a() != 2) return "fail 2"
|
||||
|
||||
if (z != 1 || z2 != 2) return "fail 3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -15,7 +15,7 @@ open class AllEvenNum() {
|
||||
}
|
||||
|
||||
}
|
||||
(i = i + 1)
|
||||
i = i + 1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
class C {
|
||||
|
||||
fun f (<!UNUSED_PARAMETER!>a<!> : Boolean, <!UNUSED_PARAMETER!>b<!> : Boolean) {
|
||||
@b (while (true)
|
||||
@b while (true)
|
||||
@a {
|
||||
<!NOT_A_LOOP_LABEL!>break@f<!>
|
||||
break
|
||||
<!UNREACHABLE_CODE!>break@b<!>
|
||||
<!NOT_A_LOOP_LABEL!>break@a<!>
|
||||
})
|
||||
}
|
||||
|
||||
<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>continue<!>
|
||||
|
||||
@b (while (true)
|
||||
@b while (true)
|
||||
@a {
|
||||
<!NOT_A_LOOP_LABEL!>continue@f<!>
|
||||
continue
|
||||
<!UNREACHABLE_CODE!>continue@b<!>
|
||||
<!NOT_A_LOOP_LABEL!>continue@a<!>
|
||||
})
|
||||
}
|
||||
|
||||
<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>break<!>
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun test() {
|
||||
(@d <!DECLARATION_IN_ILLEGAL_CONTEXT!>val bar = 2<!>)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
internal fun test(): kotlin.Unit
|
||||
@@ -3552,6 +3552,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ParenthesizedVariable.kt")
|
||||
public void testParenthesizedVariable() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deparenthesize/ParenthesizedVariable.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/duplicateJvmSignature")
|
||||
|
||||
-6
@@ -4317,12 +4317,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("labeledDeclarations2.kt")
|
||||
public void testLabeledDeclarations2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/labels/labeledDeclarations2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("propertyAccessor.kt")
|
||||
public void testPropertyAccessor() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/labels/propertyAccessor.kt");
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
class C {
|
||||
|
||||
fun f (<warning>a</warning> : Boolean, <warning>b</warning> : Boolean) {
|
||||
@b (while (true)
|
||||
@b (<error descr="[EXPRESSION_EXPECTED] While is not an expression, and only expressions are allowed here">while (true)
|
||||
@a {
|
||||
<error>break@f</error>
|
||||
break
|
||||
<warning>break@b</warning>
|
||||
break@b
|
||||
<error>break@a</error>
|
||||
})
|
||||
}</error>)
|
||||
|
||||
<error>continue</error>
|
||||
|
||||
@b (while (true)
|
||||
@b (<error descr="[EXPRESSION_EXPECTED] While is not an expression, and only expressions are allowed here">while (true)
|
||||
@a {
|
||||
<error>continue@f</error>
|
||||
continue
|
||||
<warning>continue@b</warning>
|
||||
continue@b
|
||||
<error>continue@a</error>
|
||||
})
|
||||
}</error>)
|
||||
|
||||
<error>break</error>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
|
||||
// ERROR: Assignments are not expressions, and only expressions are allowed in this context
|
||||
|
||||
fun foo() {
|
||||
var x = 0
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
|
||||
// ERROR: Assignments are not expressions, and only expressions are allowed in this context
|
||||
|
||||
fun foo() {
|
||||
var x = 0
|
||||
|
||||
Reference in New Issue
Block a user