[JS IR DCE] Improve handling overrides

Introduce the notion of contagious for overridable declarations.
So, now overriding uncontagious declaration will not lead to becoming a declaration reachable.
By default, all declarations treated as contagious, it's not the most efficient, but it's safest.
In case when we access a declaration through a fake-override declaration,
the original (real) one will not be marked as contagious, so, later,
other overrides will not be processed unconditionally only because
it overrides a reachable declaration.
This commit is contained in:
Zalim Bashorov
2020-01-21 17:45:47 +03:00
parent f60d0b2c7c
commit d22e4495de
2 changed files with 45 additions and 20 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -106,6 +106,12 @@ val IrSimpleFunction.isOverridable: Boolean
val IrSimpleFunction.isOverridableOrOverrides: Boolean get() = isOverridable || overriddenSymbols.isNotEmpty()
val IrDeclaration.isMemberOfOpenClass: Boolean
get() {
val parentClass = this.parent as? IrClass ?: return false
return !parentClass.isFinalClass
}
fun IrReturnTarget.returnType(context: CommonBackendContext) =
when (this) {
is IrConstructor -> context.irBuiltIns.unitType