[FIR] Forbid constructors in processFunctionsByName

This commit is contained in:
simon.ogorodnik
2020-06-29 23:17:13 +03:00
parent 6bc654ee49
commit 6c7a40627f
@@ -30,7 +30,7 @@ class FirClassDeclaredMemberScope(
when (declaration) { when (declaration) {
is FirCallableMemberDeclaration<*> -> { is FirCallableMemberDeclaration<*> -> {
val name = when (declaration) { val name = when (declaration) {
is FirConstructor -> Name.special("<init>") is FirConstructor -> constructorName
is FirVariable<*> -> declaration.name is FirVariable<*> -> declaration.name
is FirSimpleFunction -> declaration.name is FirSimpleFunction -> declaration.name
else -> continue@loop else -> continue@loop
@@ -43,6 +43,7 @@ class FirClassDeclaredMemberScope(
} }
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) { override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
if (name == constructorName) return
val symbols = callablesIndex[name] ?: emptyList() val symbols = callablesIndex[name] ?: emptyList()
for (symbol in symbols) { for (symbol in symbols) {
if (symbol is FirFunctionSymbol<*>) { if (symbol is FirFunctionSymbol<*>) {
@@ -52,7 +53,7 @@ class FirClassDeclaredMemberScope(
} }
override fun processDeclaredConstructors(processor: (FirConstructorSymbol) -> Unit) { override fun processDeclaredConstructors(processor: (FirConstructorSymbol) -> Unit) {
val symbols = callablesIndex[Name.special("<init>")] ?: return val symbols = callablesIndex[constructorName] ?: return
for (symbol in symbols) { for (symbol in symbols) {
if (symbol is FirConstructorSymbol) { if (symbol is FirConstructorSymbol) {
processor(symbol) processor(symbol)
@@ -76,3 +77,6 @@ class FirClassDeclaredMemberScope(
nestedClassifierScope?.processClassifiersByNameWithSubstitution(name, processor) nestedClassifierScope?.processClassifiersByNameWithSubstitution(name, processor)
} }
} }
private val constructorName = Name.special("<init>")