FIR: Support top-level constructors
This commit is contained in:
@@ -57,13 +57,14 @@ class FirProviderImpl(val session: FirSession) : FirProvider {
|
||||
}
|
||||
|
||||
override fun visitCallableMemberDeclaration(callableMemberDeclaration: FirCallableMemberDeclaration) {
|
||||
val callableId = when (containerFqName) {
|
||||
FqName.ROOT -> CallableId(packageName, callableMemberDeclaration.name)
|
||||
else -> CallableId(packageName, containerFqName, callableMemberDeclaration.name)
|
||||
}
|
||||
val callableId = (callableMemberDeclaration.symbol as ConeCallableSymbol).callableId
|
||||
callableMap.merge(callableId, listOf(callableMemberDeclaration)) { a, b -> a + b }
|
||||
}
|
||||
|
||||
override fun visitConstructor(constructor: FirConstructor) {
|
||||
visitCallableMemberDeclaration(constructor)
|
||||
}
|
||||
|
||||
override fun visitNamedFunction(namedFunction: FirNamedFunction) {
|
||||
visitCallableMemberDeclaration(namedFunction)
|
||||
}
|
||||
|
||||
+7
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.ConePropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeVariableSymbol
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class FirTopLevelDeclaredMemberScope(
|
||||
@@ -24,6 +25,12 @@ class FirTopLevelDeclaredMemberScope(
|
||||
private val packageFqName = file.packageFqName
|
||||
|
||||
override fun processFunctionsByName(name: Name, processor: (ConeFunctionSymbol) -> ProcessorAction): ProcessorAction {
|
||||
val constructors = provider.getCallableSymbols(CallableId(packageFqName, FqName.topLevel(name), name))
|
||||
for (symbol in constructors) {
|
||||
if (symbol is ConeFunctionSymbol && !processor(symbol)) {
|
||||
return STOP
|
||||
}
|
||||
}
|
||||
val symbols = provider.getCallableSymbols(CallableId(packageFqName, name))
|
||||
for (symbol in symbols) {
|
||||
if (symbol is ConeFunctionSymbol && !processor(symbol)) {
|
||||
|
||||
+1
-1
@@ -11,5 +11,5 @@ FILE: derivedClass.kt
|
||||
|
||||
}
|
||||
<T : R|kotlin/Any|> public final function create(x: R|T|): R|Derived<T>| {
|
||||
return@@@create <Unresolved name: Derived>#(R|<local>/x|)
|
||||
return@@@create R|/Derived.Derived|(R|<local>/x|)
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ FILE: explicitReceiver.kt
|
||||
public final class Foo {
|
||||
public constructor(): super<R|kotlin/Any|>()
|
||||
|
||||
public final property x(val): R|Foo| = <Unresolved name: Foo>#()
|
||||
public final property x(val): R|Foo| = R|/Foo.Foo|()
|
||||
public get(): R|Foo|
|
||||
|
||||
public final operator function invoke(): R|Foo| {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ FILE: explicitReceiver2.kt
|
||||
return@@@invoke this#
|
||||
}
|
||||
|
||||
public final property x(val): R|Bar| = <Unresolved name: Bar>#()
|
||||
public final property x(val): R|Bar| = R|/Bar.Bar|()
|
||||
public get(): R|Bar|
|
||||
|
||||
public final function bar(): R|Foo| {
|
||||
|
||||
@@ -15,7 +15,7 @@ FILE: simpleFakeOverride.kt
|
||||
public constructor(): super<R|A<Some>|>()
|
||||
|
||||
public final function test(): R|kotlin/Unit| {
|
||||
R|FakeOverride</A.foo: R|Some|>|(<Unresolved name: Some>#())
|
||||
R|FakeOverride</A.foo: R|Some|>|(R|/Some.Some|())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user