FIR: introduce callable member symbols & initial member scopes
Initial member scopes cover top-level, class-level, and supers Ad-hock version of call resolve was introduced to test them NB: after this commit, total Kotlin resolve test cannot finish because of scope problems in type resolve transformer Related to KT-24078 #KT-24083 Fixed
This commit is contained in:
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.service
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -15,6 +16,8 @@ interface FirSymbolProvider {
|
||||
|
||||
fun getSymbolByFqName(classId: ClassId): ConeSymbol?
|
||||
|
||||
fun getCallableSymbols(callableId: CallableId): List<ConeSymbol>
|
||||
|
||||
fun getPackage(fqName: FqName): FqName? // TODO: Replace to symbol sometime
|
||||
|
||||
companion object {
|
||||
|
||||
+8
@@ -6,12 +6,20 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
|
||||
|
||||
class FirCompositeSymbolProvider(val providers: List<FirSymbolProvider>) : FirSymbolProvider {
|
||||
override fun getCallableSymbols(callableId: CallableId): List<ConeSymbol> {
|
||||
for (provider in providers) {
|
||||
val symbols = provider.getCallableSymbols(callableId)
|
||||
if (symbols.isNotEmpty()) return symbols
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
override fun getPackage(fqName: FqName): FqName? {
|
||||
return providers.firstNotNullResult { it.getPackage(fqName) }
|
||||
|
||||
+5
@@ -10,11 +10,16 @@ import org.jetbrains.kotlin.fir.dependenciesWithoutSelf
|
||||
import org.jetbrains.kotlin.fir.resolve.AbstractFirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.service
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
class FirDependenciesSymbolProviderImpl(val session: FirSession) : AbstractFirSymbolProvider() {
|
||||
override fun getCallableSymbols(callableId: CallableId): List<ConeSymbol> {
|
||||
// TODO
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
private val dependencyProviders by lazy {
|
||||
val moduleInfo = session.moduleInfo ?: return@lazy emptyList()
|
||||
|
||||
+5
-1
@@ -11,10 +11,10 @@ import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.deserialization.FirTypeDeserializer
|
||||
import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.LibraryClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FictitiousFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.builtins.BuiltInsBinaryVersion
|
||||
import org.jetbrains.kotlin.metadata.deserialization.NameResolverImpl
|
||||
@@ -27,6 +27,10 @@ import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
|
||||
import java.io.InputStream
|
||||
|
||||
class FirLibrarySymbolProviderImpl(val session: FirSession) : FirSymbolProvider {
|
||||
override fun getCallableSymbols(callableId: CallableId): List<ConeSymbol> {
|
||||
// TODO
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
private class BuiltInsPackageFragment(stream: InputStream, val fqName: FqName) {
|
||||
lateinit var version: BuiltInsBinaryVersion
|
||||
|
||||
@@ -9,10 +9,7 @@ import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.FirSymbolOwner
|
||||
import org.jetbrains.kotlin.fir.symbols.*
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -31,6 +28,10 @@ class FirProviderImpl(val session: FirSession) : FirProvider {
|
||||
return (getFirClassifierByFqName(classId) as? FirSymbolOwner<*>)?.symbol
|
||||
}
|
||||
|
||||
override fun getCallableSymbols(callableId: CallableId): List<ConeSymbol> {
|
||||
return (callableMap[callableId] ?: emptyList()).filterIsInstance<FirSymbolOwner<*>>().map { it.symbol }
|
||||
}
|
||||
|
||||
override fun getFirClassifierContainerFile(fqName: ClassId): FirFile {
|
||||
return classifierContainerFileMap[fqName] ?: error("Couldn't find container for $fqName")
|
||||
}
|
||||
@@ -61,12 +62,29 @@ class FirProviderImpl(val session: FirSession) : FirProvider {
|
||||
classifierMap[classId] = typeAlias
|
||||
classifierContainerFileMap[classId] = file
|
||||
}
|
||||
|
||||
override fun visitCallableMember(callableMember: FirCallableMember) {
|
||||
val callableId = when (containerFqName) {
|
||||
FqName.ROOT -> CallableId(packageName, callableMember.name)
|
||||
else -> CallableId(packageName, containerFqName, callableMember.name)
|
||||
}
|
||||
callableMap.merge(callableId, listOf(callableMember)) { a, b -> a + b }
|
||||
}
|
||||
|
||||
override fun visitNamedFunction(namedFunction: FirNamedFunction) {
|
||||
visitCallableMember(namedFunction)
|
||||
}
|
||||
|
||||
override fun visitProperty(property: FirProperty) {
|
||||
visitCallableMember(property)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private val fileMap = mutableMapOf<FqName, List<FirFile>>()
|
||||
private val classifierMap = mutableMapOf<ClassId, FirMemberDeclaration>()
|
||||
private val classifierContainerFileMap = mutableMapOf<ClassId, FirFile>()
|
||||
private val callableMap = mutableMapOf<CallableId, List<FirNamedDeclaration>>()
|
||||
|
||||
override fun getFirFilesByPackage(fqName: FqName): List<FirFile> {
|
||||
return fileMap[fqName].orEmpty()
|
||||
|
||||
+7
-7
@@ -16,16 +16,16 @@ import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
|
||||
abstract class FirAbstractTreeTransformerWithSuperTypes(reversedScopePriority: Boolean) : FirAbstractTreeTransformer() {
|
||||
protected var towerScope = FirCompositeScope(mutableListOf(), reversedPriority = reversedScopePriority)
|
||||
protected val towerScope = FirCompositeScope(mutableListOf(), reversedPriority = reversedScopePriority)
|
||||
|
||||
protected inline fun <T> withScopeCleanup(crossinline l: () -> T): T {
|
||||
val scopeBefore = towerScope
|
||||
val scopes = towerScope.scopes
|
||||
val sizeBefore = scopes.size
|
||||
val sizeBefore = towerScope.scopes.size
|
||||
val result = l()
|
||||
towerScope = scopeBefore
|
||||
assert(scopes.size >= sizeBefore)
|
||||
scopes.subList(sizeBefore + 1, scopes.size).clear()
|
||||
val size = towerScope.scopes.size
|
||||
assert(size >= sizeBefore)
|
||||
repeat(size - sizeBefore) {
|
||||
towerScope.scopes.let { it.removeAt(it.size - 1) }
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirNamedReference
|
||||
import org.jetbrains.kotlin.fir.FirResolvedCallableReference
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.scopes.FirPosition
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirClassDeclaredMemberScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirTopLevelDeclaredMemberScope
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||
import org.jetbrains.kotlin.fir.visitors.compose
|
||||
|
||||
class FirAccessResolveTransformer : FirAbstractTreeTransformerWithSuperTypes(reversedScopePriority = true) {
|
||||
|
||||
override fun transformFile(file: FirFile, data: Nothing?): CompositeTransformResult<FirFile> {
|
||||
return withScopeCleanup {
|
||||
towerScope.scopes += FirTopLevelDeclaredMemberScope(file, file.session)
|
||||
super.transformFile(file, data)
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformRegularClass(regularClass: FirRegularClass, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
return withScopeCleanup {
|
||||
lookupSuperTypes(regularClass).asReversed().mapNotNullTo(towerScope.scopes) {
|
||||
val symbol = it.symbol
|
||||
if (symbol is FirClassSymbol) {
|
||||
FirClassDeclaredMemberScope(symbol.fir, symbol.fir.session)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
towerScope.scopes += FirClassDeclaredMemberScope(regularClass, regularClass.session)
|
||||
super.transformRegularClass(regularClass, data)
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformNamedReference(namedReference: FirNamedReference, data: Nothing?): CompositeTransformResult<FirNamedReference> {
|
||||
if (namedReference is FirResolvedCallableReference) return namedReference.compose()
|
||||
val name = namedReference.name
|
||||
var symbol: ConeCallableSymbol? = null
|
||||
towerScope.processClassifiersByName(name, FirPosition.OTHER) {
|
||||
symbol = it as? ConeCallableSymbol
|
||||
// I'm lucky today!!! (the first symbol we have found is the one we need)
|
||||
it is ConeCallableSymbol
|
||||
}
|
||||
val callableSymbol = symbol ?: return FirErrorNamedReference(
|
||||
namedReference.session, namedReference.psi, "Unresolved name: $name"
|
||||
).compose()
|
||||
return FirResolvedCallableReferenceImpl(
|
||||
namedReference.session, namedReference.psi,
|
||||
name, callableSymbol
|
||||
).compose()
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -13,7 +13,8 @@ class FirTotalResolveTransformer {
|
||||
val transformers: List<FirTransformer<Nothing?>> = listOf(
|
||||
FirImportResolveTransformer(),
|
||||
FirTypeResolveTransformer(),
|
||||
FirStatusResolveTransformer()
|
||||
FirStatusResolveTransformer(),
|
||||
FirAccessResolveTransformer()
|
||||
)
|
||||
|
||||
fun processFile(firFile: FirFile) {
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.scopes.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.scopes.FirPosition
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class FirClassDeclaredMemberScope(
|
||||
klass: FirRegularClass,
|
||||
session: FirSession,
|
||||
lookupInFir: Boolean = true
|
||||
) : FirAbstractProviderBasedScope(session, lookupInFir) {
|
||||
private val classId = klass.symbol.classId
|
||||
|
||||
override fun processClassifiersByName(
|
||||
name: Name,
|
||||
position: FirPosition,
|
||||
processor: (ConeSymbol) -> Boolean
|
||||
): Boolean {
|
||||
val symbols = provider.getCallableSymbols(CallableId(classId.packageFqName, classId.relativeClassName, name))
|
||||
for (symbol in symbols) {
|
||||
if (!processor(symbol)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.scopes.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.scopes.FirPosition
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class FirTopLevelDeclaredMemberScope(
|
||||
file: FirFile,
|
||||
session: FirSession,
|
||||
lookupInFir: Boolean = true
|
||||
) : FirAbstractProviderBasedScope(session, lookupInFir) {
|
||||
private val packageFqName = file.packageFqName
|
||||
|
||||
override fun processClassifiersByName(
|
||||
name: Name,
|
||||
position: FirPosition,
|
||||
processor: (ConeSymbol) -> Boolean
|
||||
): Boolean {
|
||||
val symbols = provider.getCallableSymbols(CallableId(packageFqName, name))
|
||||
for (symbol in symbols) {
|
||||
if (!processor(symbol)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@ FILE: lists.kt
|
||||
|
||||
}
|
||||
public final function convert R|kotlin/collections/List<kotlin/String>|.(): R|MyStringList| {
|
||||
return@@@convert STUB
|
||||
return@@@convert as/R|MyStringList|(this#)
|
||||
}
|
||||
public final function ret(l: R|kotlin/collections/MutableList<kotlin/String>|): R|MyMutableStringList| {
|
||||
return@@@ret STUB
|
||||
return@@@ret as/R|MyMutableStringList|(this#)
|
||||
}
|
||||
|
||||
+2
-2
@@ -7,9 +7,9 @@ FILE: derivedClass.kt
|
||||
|
||||
}
|
||||
<T : R|kotlin/Any|> public final class Derived : R|Base<T>| {
|
||||
public constructor(x: R|T|): super<R|Base<T>|>()
|
||||
public constructor(x: R|T|): super<R|Base<T>|>(R|/Base.x|)
|
||||
|
||||
}
|
||||
<T : R|kotlin/Any|> public final function create(x: R|T|): R|Derived<T>| {
|
||||
return@@@create STUB
|
||||
return@@@create <Unresolved name: Derived>#(<Unresolved name: x>#)
|
||||
}
|
||||
|
||||
+4
-4
@@ -16,19 +16,19 @@ FILE: enum.kt
|
||||
public get(): R|Some|
|
||||
|
||||
public final enum entry FIRST : R|SomeEnum| {
|
||||
public constructor(): super<R|SomeEnum|>()
|
||||
public constructor(): super<R|SomeEnum|>(<Unresolved name: O1>#)
|
||||
|
||||
public final override function check(y: R|Some|): R|kotlin/Boolean| {
|
||||
return@@@check STUB
|
||||
return@@@check Boolean(true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final enum entry SECOND : R|SomeEnum| {
|
||||
public constructor(): super<R|SomeEnum|>()
|
||||
public constructor(): super<R|SomeEnum|>(<Unresolved name: O2>#)
|
||||
|
||||
public final override function check(y: R|Some|): R|kotlin/Boolean| {
|
||||
return@@@check STUB
|
||||
return@@@check ==(<Unresolved name: y>#, <Unresolved name: O2>#)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,33 +28,33 @@ FILE: enums.kt
|
||||
internal get(): R|kotlin/Double|
|
||||
|
||||
public final enum entry MERCURY : R|Planet| {
|
||||
public constructor(): super<R|Planet|>()
|
||||
public constructor(): super<R|Planet|>(Double(1.0), Double(2.0))
|
||||
|
||||
public final override function sayHello(): R|kotlin/Unit| {
|
||||
return@@@sayHello STUB
|
||||
<Unresolved name: println>#(String(Hello!!!))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final enum entry VENERA : R|Planet| {
|
||||
public constructor(): super<R|Planet|>()
|
||||
public constructor(): super<R|Planet|>(Double(3.0), Double(4.0))
|
||||
|
||||
public final override function sayHello(): R|kotlin/Unit| {
|
||||
return@@@sayHello STUB
|
||||
<Unresolved name: println>#(String(Ola!!!))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final enum entry EARTH : R|Planet| {
|
||||
public constructor(): super<R|Planet|>()
|
||||
public constructor(): super<R|Planet|>(Double(5.0), Double(6.0))
|
||||
|
||||
public final override function sayHello(): R|kotlin/Unit| {
|
||||
return@@@sayHello STUB
|
||||
<Unresolved name: println>#(String(Privet!!!))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final property g(val): R|kotlin/Double| = STUB
|
||||
public final property g(val): R|kotlin/Double| = <Unresolved name: div>#(<Unresolved name: times>#(<Unresolved name: G>#, R|/Planet.m|), <Unresolved name: times>#(R|/Planet.r|, R|/Planet.r|))
|
||||
public get(): R|kotlin/Double|
|
||||
|
||||
public abstract function sayHello(): R|kotlin/Unit|
|
||||
@@ -62,7 +62,7 @@ FILE: enums.kt
|
||||
public final companion object Companion {
|
||||
public constructor(): super<R|kotlin/Any|>()
|
||||
|
||||
public final const property G(val): R|error: Not supported: FirImplicitTypeImpl| = STUB
|
||||
public final const property G(val): R|error: Not supported: FirImplicitTypeImpl| = Double(6.67E-11)
|
||||
public get(): R|error: Not supported: FirImplicitTypeImpl|
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ FILE: noPrimaryConstructor.kt
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
public constructor(x: R|kotlin/String|): super<R|kotlin/Any|>() {
|
||||
return STUB
|
||||
this#.R|/NoPrimary.x| = R|/NoPrimary.x|
|
||||
}
|
||||
|
||||
public constructor(): this<R|NoPrimary|>()
|
||||
public constructor(): this<R|NoPrimary|>(String())
|
||||
|
||||
}
|
||||
|
||||
@@ -9,19 +9,18 @@ FILE: simpleClass.kt
|
||||
public final class SomeClass : R|SomeInterface| {
|
||||
public constructor(): super<R|kotlin/Any|>()
|
||||
|
||||
private final property baz(val): R|error: Not supported: FirImplicitTypeImpl| = STUB
|
||||
private final property baz(val): R|error: Not supported: FirImplicitTypeImpl| = Int(42)
|
||||
private get(): R|error: Not supported: FirImplicitTypeImpl|
|
||||
|
||||
public final override function foo(x: R|kotlin/Int|, y: R|kotlin/String|): R|kotlin/String| {
|
||||
return@@@foo STUB
|
||||
return@@@foo <Unresolved name: plus>#(<Unresolved name: plus>#(<Unresolved name: y>#, <Unresolved name: x>#), R|/SomeClass.baz|)
|
||||
}
|
||||
|
||||
public final override property bar(var): R|kotlin/Boolean|
|
||||
public get(): R|kotlin/Boolean| {
|
||||
return STUB
|
||||
return Boolean(true)
|
||||
}
|
||||
public set(value: R|kotlin/Boolean|): R|kotlin/Unit| {
|
||||
return STUB
|
||||
}
|
||||
|
||||
public final lateinit property fau(var): R|kotlin/Double|
|
||||
|
||||
@@ -15,11 +15,11 @@ FILE: typeParameters.kt
|
||||
public constructor(): super<R|AbstractList<kotlin/Int>|>()
|
||||
|
||||
public final override function get(index: R|kotlin/Int|): R|kotlin/Int| {
|
||||
return@@@get STUB
|
||||
return@@@get Int(42)
|
||||
}
|
||||
|
||||
public final override function concat(other: R|List<kotlin/Int>|): R|List<kotlin/Int>| {
|
||||
return@@@concat STUB
|
||||
return@@@concat this#
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -1,12 +1,11 @@
|
||||
FILE: functionTypes.kt
|
||||
<T> public final function simpleRun(f: R|(T) -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
return@@@simpleRun STUB
|
||||
return@@@simpleRun <Unresolved name: f>#()
|
||||
}
|
||||
<T, R> public final function simpleMap R|kotlin/collections/List<T>|.(f: R|(T) -> R|): R|R| {
|
||||
return@@@simpleMap STUB
|
||||
}
|
||||
<T> public final function simpleWith(t: R|T|, f: R|T.() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
return@@@simpleWith STUB
|
||||
return@@@simpleWith <Unresolved name: t>#.<Unresolved name: f>#()
|
||||
}
|
||||
<T, R> public abstract interface KMutableProperty1 : R|KProperty1<T, R>|, R|KMutableProperty<R>| {
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ FILE: genericFunctions.kt
|
||||
public abstract interface Any {
|
||||
}
|
||||
<reified T : R|Any|> public final inline function safeAs R|Any|.(): R|T| {
|
||||
return@@@safeAs STUB
|
||||
return@@@safeAs as?/R|T|(this#)
|
||||
}
|
||||
public abstract class Summator {
|
||||
public constructor(): super<R|Any|>()
|
||||
|
||||
@@ -5,7 +5,7 @@ FILE: Annotations.kt
|
||||
|
||||
@R|annotations/Simple|() public abstract function foo(@R|annotations/WithString|(String(abc)) arg: @R|annotations/Simple|() R|kotlin/Double|): R|kotlin/Unit|
|
||||
|
||||
@R|annotations/Complex|(STUB, STUB) public abstract property v(val): R|kotlin/String|
|
||||
@R|annotations/Complex|(<Unresolved name: WithInt>#(Int(7)), <Unresolved name: WithString>#(String())) public abstract property v(val): R|kotlin/String|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
@@ -16,15 +16,15 @@ FILE: Annotations.kt
|
||||
public get(): R|kotlin/Char|
|
||||
|
||||
public final override function foo(arg: R|kotlin/Double|): R|kotlin/Unit| {
|
||||
return@@@foo STUB
|
||||
}
|
||||
|
||||
public final override property v(val): R|kotlin/String|
|
||||
@R|annotations/Simple|() public get(): R|kotlin/String| {
|
||||
return STUB
|
||||
return String()
|
||||
}
|
||||
|
||||
@R|annotations/WithString|(String(constructor)) public constructor(): this<R|test/Second|>()
|
||||
@R|annotations/WithString|(String(constructor)) public constructor(): this<R|test/Second|>(Char(
|
||||
))
|
||||
|
||||
}
|
||||
@R|annotations/WithInt|(Int(24)) @R|annotations/VeryComplex|(Float(3.14), Double(6.67E-11), Boolean(false), Long(123456789012345), Null(null)) @R|annotations/WithInt|(Int(24)) @R|annotations/VeryComplex|(Float(3.14), Double(6.67E-11), Boolean(false), Long(123456789012345), Null(null)) public final typealias Third = @R|annotations/Simple|() R|test/Second|
|
||||
|
||||
+2
-2
@@ -10,12 +10,12 @@ FILE: nestedClass.kt
|
||||
public constructor(): super<R|kotlin/Any|>()
|
||||
|
||||
public final class Derived : R|Base| {
|
||||
public constructor(s: R|kotlin/String|): super<R|Base|>()
|
||||
public constructor(s: R|kotlin/String|): super<R|Base|>(R|/Base.s|)
|
||||
|
||||
}
|
||||
|
||||
public final object Obj : R|Base| {
|
||||
public constructor(): super<R|Base|>()
|
||||
public constructor(): super<R|Base|>(String())
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo() = 1
|
||||
|
||||
fun bar() = foo()
|
||||
@@ -0,0 +1,7 @@
|
||||
FILE: simple.kt
|
||||
public final function foo(): R|error: Not supported: FirImplicitTypeImpl| {
|
||||
return@@@foo Int(1)
|
||||
}
|
||||
public final function bar(): R|error: Not supported: FirImplicitTypeImpl| {
|
||||
return@@@bar R|/foo|()
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
open class A {
|
||||
open fun foo() {}
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
fun bar() {
|
||||
foo()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
FILE: superMember.kt
|
||||
public open class A {
|
||||
public constructor(): super<R|kotlin/Any|>()
|
||||
|
||||
public open function foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
public final class B : R|A| {
|
||||
public constructor(): super<R|A|>()
|
||||
|
||||
public final function bar(): R|kotlin/Unit| {
|
||||
R|/A.foo|()
|
||||
}
|
||||
|
||||
}
|
||||
+3
-4
@@ -9,19 +9,18 @@ FILE: simpleClass.kt
|
||||
public final class SomeClass : R|SomeInterface| {
|
||||
public constructor(): super<R|kotlin/Any|>()
|
||||
|
||||
private final property baz(val): R|error: Not supported: FirImplicitTypeImpl| = STUB
|
||||
private final property baz(val): R|error: Not supported: FirImplicitTypeImpl| = Int(42)
|
||||
private get(): R|error: Not supported: FirImplicitTypeImpl|
|
||||
|
||||
public final override function foo(x: R|kotlin/Int|, y: R|kotlin/String|): R|kotlin/String| {
|
||||
return@@@foo STUB
|
||||
return@@@foo <Unresolved name: plus>#(<Unresolved name: plus>#(<Unresolved name: y>#, <Unresolved name: x>#), R|/SomeClass.baz|)
|
||||
}
|
||||
|
||||
public final override property bar(var): R|kotlin/Boolean|
|
||||
public get(): R|kotlin/Boolean| {
|
||||
return STUB
|
||||
return Boolean(true)
|
||||
}
|
||||
public set(value: R|kotlin/Boolean|): R|kotlin/Unit| {
|
||||
return STUB
|
||||
}
|
||||
|
||||
public final property fau(var): R|kotlin/Double|
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
FILE: concurrent.kt
|
||||
@R|kotlin/jvm/Volatile|() public final property xx(var): R|kotlin/Int| = STUB
|
||||
@R|kotlin/jvm/Volatile|() public final property xx(var): R|kotlin/Int| = Int(2)
|
||||
public get(): R|kotlin/Int|
|
||||
public set(value: R|kotlin/Int|): R|kotlin/Unit|
|
||||
@R|kotlin/jvm/Synchronized|() public final function foo(): R|kotlin/Unit| {
|
||||
return@@@foo STUB
|
||||
}
|
||||
|
||||
+14
-3
@@ -1,13 +1,24 @@
|
||||
FILE: functionX.kt
|
||||
public final property x(val): R|kotlin/jvm/functions/Function0<kotlin/Int>| = STUB
|
||||
public final property x(val): R|kotlin/jvm/functions/Function0<kotlin/Int>| = function R|error: Not supported: FirImplicitTypeImpl|.<anonymous>(): R|error: Not supported: FirImplicitTypeImpl| {
|
||||
return {
|
||||
Int(42)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get(): R|kotlin/jvm/functions/Function0<kotlin/Int>|
|
||||
public final property y(val): R|kotlin/Function1<kotlin/String, kotlin/String>| = STUB
|
||||
public final property y(val): R|kotlin/Function1<kotlin/String, kotlin/String>| = function R|error: Not supported: FirImplicitTypeImpl|.<anonymous>(): R|error: Not supported: FirImplicitTypeImpl| {
|
||||
return {
|
||||
<Unresolved name: it>#
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get(): R|kotlin/Function1<kotlin/String, kotlin/String>|
|
||||
public final class MyFunction : R|kotlin/Function2<kotlin/Int, kotlin/String, kotlin/Unit>| {
|
||||
public constructor(): super<R|kotlin/Any|>()
|
||||
|
||||
public final override function invoke(p1: R|kotlin/Int|, p2: R|kotlin/String|): R|kotlin/Unit| {
|
||||
return@@@invoke STUB
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FILE: reflectionClass.kt
|
||||
public final property javaClass(val): R|java/lang/Class<kotlin/String>| = STUB
|
||||
public final property javaClass(val): R|java/lang/Class<kotlin/String>| = <getClass>(<Unresolved name: String>#).<Unresolved name: java>#
|
||||
public get(): R|java/lang/Class<kotlin/String>|
|
||||
public final property kotlinClass(val): R|kotlin/reflect/KClass<kotlin/String>| = STUB
|
||||
public final property kotlinClass(val): R|kotlin/reflect/KClass<kotlin/String>| = <getClass>(<Unresolved name: String>#)
|
||||
public get(): R|kotlin/reflect/KClass<kotlin/String>|
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
FILE: treeSet.kt
|
||||
public final property x(val): R|java/util/SortedSet<kotlin/Int>| = STUB
|
||||
public final property x(val): R|java/util/SortedSet<kotlin/Int>| = <Unresolved name: TreeSet>#()
|
||||
public get(): R|java/util/SortedSet<kotlin/Int>|
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FILE: typeParameterInPropertyReceiver.kt
|
||||
<T : R|kotlin/Any|> public final property self R|T|.(val): R|T|
|
||||
public get(): R|T| {
|
||||
return STUB
|
||||
return this#
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ abstract class AbstractFirResolveTestCase : AbstractFirResolveWithSessionTestCas
|
||||
.uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(project))
|
||||
val session = createSession(scope)
|
||||
|
||||
val builder = RawFirBuilder(session, stubMode = true)
|
||||
val builder = RawFirBuilder(session, stubMode = false)
|
||||
|
||||
val transformer = FirTotalResolveTransformer()
|
||||
return ktFiles.map {
|
||||
|
||||
+23
@@ -242,4 +242,27 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase {
|
||||
runTest("compiler/fir/resolve/testData/resolve/multifile/TypeAliasExpansion.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/resolve/testData/resolve/references")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class References extends AbstractFirResolveTestCase {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInReferences() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/references"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/references/simple.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("superMember.kt")
|
||||
public void testSuperMember() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/references/superMember.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user