[FIR] Bind return expression to function symbol instead of function itself

This commit is contained in:
Dmitriy Novozhilov
2021-03-01 17:57:02 +03:00
committed by TeamCityServer
parent 245bc7c8e2
commit 714c2a8f93
12 changed files with 82 additions and 5 deletions
@@ -14922,6 +14922,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/fir/ClassBuilder.kt");
}
@Test
@TestMetadata("classCanNotBeCastedToVoid.kt")
public void testClassCanNotBeCastedToVoid() throws Exception {
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
}
@Test
@TestMetadata("ConstValAccess.kt")
public void testConstValAccess() throws Exception {
@@ -8,9 +8,12 @@ package org.jetbrains.kotlin.fir
abstract class FirAbstractTarget<E : FirTargetElement>(
override val labelName: String?
) : FirTarget<E> {
override lateinit var labeledElement: E
protected abstract var _labeledElement: E
final override val labeledElement: E
get() = _labeledElement
override fun bind(element: E) {
labeledElement = element
_labeledElement = element
}
}
}
@@ -6,8 +6,17 @@
package org.jetbrains.kotlin.fir
import org.jetbrains.kotlin.fir.declarations.FirFunction
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
class FirFunctionTarget(
labelName: String?,
val isLambda: Boolean
) : FirAbstractTarget<FirFunction<*>>(labelName)
) : FirAbstractTarget<FirFunction<*>>(labelName) {
private lateinit var targetSymbol: FirFunctionSymbol<*>
override var _labeledElement: FirFunction<*>
get() = targetSymbol.fir
set(value) {
targetSymbol = value.symbol
}
}
@@ -9,4 +9,6 @@ import org.jetbrains.kotlin.fir.expressions.FirLoop
class FirLoopTarget(
labelName: String?
) : FirAbstractTarget<FirLoop>(labelName)
) : FirAbstractTarget<FirLoop>(labelName) {
override lateinit var _labeledElement: FirLoop
}
@@ -0,0 +1,20 @@
class ASTNode
class Wrap(val message: String)
typealias WrappingStrategy = (childElement: ASTNode) -> Wrap?
fun getWrappingStrategy(): WrappingStrategy {
return wrap@{ childElement ->
Wrap("OK").let {
return@wrap it
}
}
}
fun getWrapAfterAnnotation(childElement: ASTNode): Wrap? {
return Wrap("OK")
}
fun box(): String {
return getWrappingStrategy().invoke(ASTNode())?.message ?: "fail"
}
@@ -14922,6 +14922,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/fir/ClassBuilder.kt");
}
@Test
@TestMetadata("classCanNotBeCastedToVoid.kt")
public void testClassCanNotBeCastedToVoid() throws Exception {
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
}
@Test
@TestMetadata("ConstValAccess.kt")
public void testConstValAccess() throws Exception {
@@ -14922,6 +14922,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/fir/ClassBuilder.kt");
}
@Test
@TestMetadata("classCanNotBeCastedToVoid.kt")
public void testClassCanNotBeCastedToVoid() throws Exception {
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
}
@Test
@TestMetadata("ConstValAccess.kt")
public void testConstValAccess() throws Exception {
@@ -12318,6 +12318,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/fir/ClassBuilder.kt");
}
@TestMetadata("classCanNotBeCastedToVoid.kt")
public void testClassCanNotBeCastedToVoid() throws Exception {
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
}
@TestMetadata("ConstValAccess.kt")
public void testConstValAccess() throws Exception {
runTest("compiler/testData/codegen/box/fir/ConstValAccess.kt");
@@ -10940,6 +10940,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
public void testAllFilesPresentInFir() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
@TestMetadata("classCanNotBeCastedToVoid.kt")
public void testClassCanNotBeCastedToVoid() throws Exception {
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/fullJdk")
@@ -10397,6 +10397,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
public void testAllFilesPresentInFir() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@TestMetadata("classCanNotBeCastedToVoid.kt")
public void testClassCanNotBeCastedToVoid() throws Exception {
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/fullJdk")
@@ -10397,6 +10397,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
public void testAllFilesPresentInFir() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
}
@TestMetadata("classCanNotBeCastedToVoid.kt")
public void testClassCanNotBeCastedToVoid() throws Exception {
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/fullJdk")
@@ -5228,6 +5228,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
public void testAllFilesPresentInFir() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@TestMetadata("classCanNotBeCastedToVoid.kt")
public void testClassCanNotBeCastedToVoid() throws Exception {
runTest("compiler/testData/codegen/box/fir/classCanNotBeCastedToVoid.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/fullJdk")