FIR2IR: generate both dispatch & extension receiver without 'else if'

This commit is contained in:
Mikhail Glukhikh
2020-02-25 11:27:51 +03:00
parent 4f6fe1d0ca
commit 8c155578f7
21 changed files with 6 additions and 20 deletions
@@ -847,7 +847,8 @@ class Fir2IrVisitor(
val ownerFunction = symbol.owner
if (ownerFunction.dispatchReceiverParameter != null) {
dispatchReceiver = qualifiedAccess.findIrDispatchReceiver()
} else if (ownerFunction.extensionReceiverParameter != null) {
}
if (ownerFunction.extensionReceiverParameter != null) {
extensionReceiver = qualifiedAccess.findIrExtensionReceiver()
}
this
@@ -50,8 +50,7 @@ class JvmIrCodegenFactory(private val phaseConfig: PhaseConfig) : CodegenFactory
val stubGenerator = irProviders.filterIsInstance<DeclarationStubGenerator>().first()
for (descriptor in symbolTable.wrappedTopLevelCallableDescriptors()) {
descriptor as WrappedDeclarationDescriptor<*>
val parentClass = stubGenerator.generateOrGetFacadeClass(descriptor)
val parentClass = stubGenerator.generateOrGetFacadeClass(descriptor as WrappedDeclarationDescriptor<*>)
descriptor.owner.parent = parentClass ?: throw AssertionError("Facade class for ${descriptor.name} not found")
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class It {
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class It {
operator fun next() = 5
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JS_IR
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
object A {
fun Int.foo(a: Int = 1): Int {
return a
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class A {
fun Int.foo(a: Int = 1): Int {
return a
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class A {
fun Double.foo(a: Double = 1.0): Double {
return a
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class A {
fun Double.foo(a: Double = 1.0, b: Double = 1.0): Double {
return a + b
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
class A {
private val sb: StringBuilder = StringBuilder()
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class Request(val path: String) {
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class C() {
fun Any.toMyPrefixedString(prefix: String = "", suffix: String="") : String = prefix + " " + suffix
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class A
class B {
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class Outer {
class Nested{
fun foo(s: String) = s.extension()
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
package name
class Test() {
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// KT-6153 java.lang.IllegalStateException while building
object Bug {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
open class A {
open val a = "OK"
}
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class Bob {
fun Bob.bar() = "OK"
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
open class B {
val p = "OK"
}
@@ -57,6 +57,8 @@ FILE fqName:<root> fileName:/destructuring1.kt
VAR name:x type:kotlin.Int [val]
CALL 'public final fun component1 (): kotlin.Int [operator] declared in <root>.B' type=kotlin.Int origin=null
$this: GET_VAR 'val tmp_0: <root>.A [val] declared in <root>.test' type=<root>.A origin=null
$receiver: GET_VAR 'val tmp_0: <root>.A [val] declared in <root>.test' type=<root>.A origin=null
VAR name:y type:kotlin.Int [val]
CALL 'public final fun component2 (): kotlin.Int [operator] declared in <root>.B' type=kotlin.Int origin=null
$this: GET_VAR 'val tmp_0: <root>.A [val] declared in <root>.test' type=<root>.A origin=null
$receiver: GET_VAR 'val tmp_0: <root>.A [val] declared in <root>.test' type=<root>.A origin=null
@@ -34,3 +34,4 @@ FILE fqName:<root> fileName:/nullabilityAssertionOnExtensionReceiver.kt
BLOCK_BODY
CALL 'public final fun memberExtension (): kotlin.Unit declared in <root>.C' type=kotlin.Unit origin=null
$this: GET_VAR '<this>: <root>.C declared in <root>.testMemberExt' type=<root>.C origin=null
$receiver: CALL 'public open fun s (): kotlin.String? declared in <root>.J' type=kotlin.String? origin=null