[FIR] Forbid constructors in processFunctionsByName
This commit is contained in:
+6
-2
@@ -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>")
|
||||||
Reference in New Issue
Block a user