IrConstructorCall support in JVM_IR, JS_IR, and FIR2IR

This commit is contained in:
Dmitry Petrov
2019-03-26 17:25:00 +03:00
parent 82128800c5
commit b78d1bb2b9
287 changed files with 9008 additions and 8128 deletions
@@ -150,7 +150,7 @@ internal class Fir2IrVisitor(
}
file.annotations.forEach {
val irCall = it.accept(this@Fir2IrVisitor, data) as? IrCall ?: return@forEach
val irCall = it.accept(this@Fir2IrVisitor, data) as? IrConstructorCall ?: return@forEach
annotations += irCall
}
}
@@ -258,7 +258,7 @@ internal class Fir2IrVisitor(
}
addFakeOverrides(klass, processedFunctionNames)
klass.annotations.forEach {
val irCall = it.accept(this@Fir2IrVisitor, null) as? IrCall ?: return@forEach
val irCall = it.accept(this@Fir2IrVisitor, null) as? IrConstructorCall ?: return@forEach
annotations += irCall
}
}
@@ -489,7 +489,7 @@ internal class Fir2IrVisitor(
setter = property.setter.accept(this@Fir2IrVisitor, type) as IrSimpleFunction
}
property.annotations.forEach {
annotations += it.accept(this@Fir2IrVisitor, null) as IrCall
annotations += it.accept(this@Fir2IrVisitor, null) as IrConstructorCall
}
return this
}
@@ -629,7 +629,8 @@ internal class Fir2IrVisitor(
val symbol = calleeReference.toSymbol(declarationStorage)
return typeRef.convertWithOffsets { startOffset, endOffset ->
when {
symbol is IrFunctionSymbol -> IrCallImpl(startOffset, endOffset, type, symbol)
symbol is IrConstructorSymbol -> IrConstructorCallImpl.fromSymbolOwner(startOffset, endOffset, type, symbol)
symbol is IrSimpleFunctionSymbol -> IrCallImpl(startOffset, endOffset, type, symbol)
symbol is IrPropertySymbol && symbol.isBound -> {
val getter = symbol.owner.getter
if (getter != null) {
@@ -660,7 +661,7 @@ internal class Fir2IrVisitor(
if (irConstructor == null) {
IrErrorCallExpressionImpl(startOffset, endOffset, type, "No annotation constructor found: ${irClass.name}")
} else {
IrCallImpl(startOffset, endOffset, type, irConstructor.symbol)
IrConstructorCallImpl.fromSymbolDescriptor(startOffset, endOffset, type, irConstructor.symbol)
}
}
@@ -771,7 +772,9 @@ internal class Fir2IrVisitor(
startOffset, endOffset, anonymousClassType, IrStatementOrigin.OBJECT_LITERAL,
listOf(
anonymousClass,
IrCallImpl(startOffset, endOffset, anonymousClassType, anonymousClass.constructors.first().symbol)
IrConstructorCallImpl.fromSymbolOwner(
startOffset, endOffset, anonymousClassType, anonymousClass.constructors.first().symbol
)
)
)
}
@@ -802,6 +802,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
runTest("compiler/testData/ir/irText/expressions/complexAugmentedAssignment.kt");
}
@TestMetadata("constructorWithOwnTypeParametersCall.kt")
public void testConstructorWithOwnTypeParametersCall() throws Exception {
runTest("compiler/testData/ir/irText/expressions/constructorWithOwnTypeParametersCall.kt");
}
@TestMetadata("contructorCall.kt")
public void testContructorCall() throws Exception {
runTest("compiler/testData/ir/irText/expressions/contructorCall.kt");
@@ -887,6 +892,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
runTest("compiler/testData/ir/irText/expressions/funImportedFromObject.kt");
}
@TestMetadata("genericConstructorCallWithTypeArguments.kt")
public void testGenericConstructorCallWithTypeArguments() throws Exception {
runTest("compiler/testData/ir/irText/expressions/genericConstructorCallWithTypeArguments.kt");
}
@TestMetadata("genericPropertyCall.kt")
public void testGenericPropertyCall() throws Exception {
runTest("compiler/testData/ir/irText/expressions/genericPropertyCall.kt");