From 3a50d2e6660dfc0d491942f4715bbdc8d77733c6 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Mon, 15 Apr 2019 16:51:01 +0300 Subject: [PATCH] FIR: provide constructors from importing scopes --- .../fir/scopes/impl/FirAbstractImportingScope.kt | 14 ++++++++++++++ .../testData/resolve/multifile/Annotations.txt | 2 +- compiler/fir/resolve/testData/resolve/treeSet.txt | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt index e6972b512d7..911d6bc0a22 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol import org.jetbrains.kotlin.fir.symbols.ConeFunctionSymbol import org.jetbrains.kotlin.fir.symbols.ConeVariableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.addToStdlib.cast @@ -53,6 +54,19 @@ abstract class FirAbstractImportingScope(session: FirSession, lookupInFir: Boole return ProcessorAction.STOP } } else { + val matchedClass = provider.getClassLikeSymbolByFqName(ClassId(import.packageFqName, name)) + + if (matchedClass != null && matchedClass is FirClassSymbol) { + //TODO: why don't we use declared member scope at this point? + if (matchedClass.fir.buildUseSiteScope(session, scopeCache).processFunctionsByName( + name, + processor + ) == ProcessorAction.STOP + ) { + return ProcessorAction.STOP + } + } + val symbols = provider.getTopLevelCallableSymbols(callableId.packageName, callableId.callableName) for (symbol in symbols) { diff --git a/compiler/fir/resolve/testData/resolve/multifile/Annotations.txt b/compiler/fir/resolve/testData/resolve/multifile/Annotations.txt index 009862c1a6f..70a937451ae 100644 --- a/compiler/fir/resolve/testData/resolve/multifile/Annotations.txt +++ b/compiler/fir/resolve/testData/resolve/multifile/Annotations.txt @@ -7,7 +7,7 @@ FILE: Annotations.kt @R|annotations/Simple|() public abstract fun foo(@R|annotations/WithString|(String(abc)) arg: @R|annotations/Simple|() R|kotlin/Double|): R|kotlin/Unit| - @R|annotations/Complex|(#(Int(7)), #(String())) public abstract val v: R|kotlin/String| + @R|annotations/Complex|(R|annotations/WithInt.WithInt|(Int(7)), R|annotations/WithString.WithString|(String())) public abstract val v: R|kotlin/String| public get(): R|kotlin/String| } diff --git a/compiler/fir/resolve/testData/resolve/treeSet.txt b/compiler/fir/resolve/testData/resolve/treeSet.txt index 777f9e981bf..098edde6785 100644 --- a/compiler/fir/resolve/testData/resolve/treeSet.txt +++ b/compiler/fir/resolve/testData/resolve/treeSet.txt @@ -1,3 +1,3 @@ FILE: treeSet.kt - public final val x: R|java/util/SortedSet| = #() + public final val x: R|java/util/SortedSet| = R|java/util/TreeSet.TreeSet|() public get(): R|java/util/SortedSet|