Diagnostic: support anonymous objects in inline functions
This commit is contained in:
+10
-2
@@ -63,12 +63,20 @@ public class InlineAnalyzerExtension implements FunctionAnalyzerExtension.Analyz
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitObjectDeclaration(@NotNull JetObjectDeclaration declaration) {
|
public void visitObjectDeclaration(@NotNull JetObjectDeclaration declaration) {
|
||||||
trace.report(Errors.NOT_YET_SUPPORTED_IN_INLINE.on(declaration, declaration, descriptor));
|
if (declaration.getParent() instanceof JetObjectLiteralExpression) {
|
||||||
|
super.visitObjectDeclaration(declaration);
|
||||||
|
} else {
|
||||||
|
trace.report(Errors.NOT_YET_SUPPORTED_IN_INLINE.on(declaration, declaration, descriptor));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitNamedFunction(@NotNull JetNamedFunction function) {
|
public void visitNamedFunction(@NotNull JetNamedFunction function) {
|
||||||
trace.report(Errors.NOT_YET_SUPPORTED_IN_INLINE.on(function, function, descriptor));
|
if (function.getParent().getParent() instanceof JetObjectDeclaration) {
|
||||||
|
super.visitNamedFunction(function);
|
||||||
|
} else {
|
||||||
|
trace.report(Errors.NOT_YET_SUPPORTED_IN_INLINE.on(function, function, descriptor));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE
|
||||||
|
|
||||||
|
inline fun <R> inlineFun(p: () -> R) {
|
||||||
|
val s = object {
|
||||||
|
|
||||||
|
val z = p()
|
||||||
|
|
||||||
|
fun a() {
|
||||||
|
p()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,14 +12,6 @@ inline fun unsupported() {
|
|||||||
object BInner {}
|
object BInner {}
|
||||||
}<!>
|
}<!>
|
||||||
|
|
||||||
val s = <!NOT_YET_SUPPORTED_IN_INLINE!>object {
|
|
||||||
fun a() {
|
|
||||||
val sInner = object {
|
|
||||||
fun aInner() {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}<!>
|
|
||||||
|
|
||||||
<!NOT_YET_SUPPORTED_IN_INLINE!>fun local() {
|
<!NOT_YET_SUPPORTED_IN_INLINE!>fun local() {
|
||||||
fun localInner() {}
|
fun localInner() {}
|
||||||
}<!>
|
}<!>
|
||||||
|
|||||||
@@ -4191,6 +4191,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/tests/inline"), Pattern.compile("^(.+)\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/tests/inline"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("anonymousObjects.kt")
|
||||||
|
public void testAnonymousObjects() throws Exception {
|
||||||
|
doTest("compiler/testData/diagnostics/tests/inline/anonymousObjects.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("assignment.kt")
|
@TestMetadata("assignment.kt")
|
||||||
public void testAssignment() throws Exception {
|
public void testAssignment() throws Exception {
|
||||||
doTest("compiler/testData/diagnostics/tests/inline/assignment.kt");
|
doTest("compiler/testData/diagnostics/tests/inline/assignment.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user