KTIJ-27050 [Analysis API] Correctly handle type parameters in KtFirReferenceShortener
Make `FirShorteningContext` correctly return symbols for type parameters, so they are not ignored when scopes are inspected Add additional type of `PartialOrderOfScope` - `TypeParameter`, because otherwise it would have been classified as `Unclassified`, and that breaks scopes comparison Add missing type parameters to the scope of class header in `ContextCollector`, add testdata for that There is a bug in the compiler with type parameters leaking to nested classes headers (KT-61959). After it's fixed, the testData with incorrect expected shortenings/scopes should be adjusted and fixed too ^KTIJ-27050 Fixed
This commit is contained in:
+13
-9
@@ -51,11 +51,11 @@ import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.PackageResolutionResult
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.resolveToPackageOrClass
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.FirTypeParameterScope
|
||||
import org.jetbrains.kotlin.fir.scopes.getFunctions
|
||||
import org.jetbrains.kotlin.fir.scopes.getProperties
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.*
|
||||
import org.jetbrains.kotlin.fir.scopes.processClassifiersByName
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
@@ -262,9 +262,9 @@ private class FirShorteningContext(val analysisSession: KtFirAnalysisSession) {
|
||||
private val firSession: FirSession
|
||||
get() = firResolveSession.useSiteFirSession
|
||||
|
||||
class ClassifierCandidate(val scope: FirScope, val availableSymbol: AvailableSymbol<FirClassLikeSymbol<*>>)
|
||||
class ClassifierCandidate(val scope: FirScope, val availableSymbol: AvailableSymbol<FirClassifierSymbol<*>>)
|
||||
|
||||
fun findFirstClassifierInScopesByName(positionScopes: List<FirScope>, targetClassName: Name): AvailableSymbol<FirClassLikeSymbol<*>>? =
|
||||
fun findFirstClassifierInScopesByName(positionScopes: List<FirScope>, targetClassName: Name): AvailableSymbol<FirClassifierSymbol<*>>? =
|
||||
positionScopes.firstNotNullOfOrNull { scope -> findFirstClassifierSymbolByName(scope, targetClassName) }
|
||||
|
||||
fun findClassifiersInScopesByName(scopes: List<FirScope>, targetClassName: Name): List<ClassifierCandidate> =
|
||||
@@ -274,8 +274,8 @@ private class FirShorteningContext(val analysisSession: KtFirAnalysisSession) {
|
||||
ClassifierCandidate(scope, classifierSymbol)
|
||||
}
|
||||
|
||||
private fun findFirstClassifierSymbolByName(scope: FirScope, targetClassName: Name): AvailableSymbol<FirClassLikeSymbol<*>>? {
|
||||
val classifierSymbol = scope.findFirstClassifierByName(targetClassName) as? FirClassLikeSymbol<*> ?: return null
|
||||
private fun findFirstClassifierSymbolByName(scope: FirScope, targetClassName: Name): AvailableSymbol<FirClassifierSymbol<*>>? {
|
||||
val classifierSymbol = scope.findFirstClassifierByName(targetClassName) ?: return null
|
||||
|
||||
return AvailableSymbol(classifierSymbol, ImportKind.fromScope(scope))
|
||||
}
|
||||
@@ -560,6 +560,8 @@ private class ElementsToShortenCollector(
|
||||
)
|
||||
}
|
||||
|
||||
private val FirClassifierSymbol<*>.classIdIfExists: ClassId? get() = (this as? FirClassLikeSymbol<*>)?.classId
|
||||
|
||||
/**
|
||||
* Returns true if the class symbol has a type parameter that is supposed to be provided for its parent class.
|
||||
*
|
||||
@@ -670,6 +672,7 @@ private class ElementsToShortenCollector(
|
||||
Local(1),
|
||||
ClassUseSite(2),
|
||||
NestedClassifier(2),
|
||||
TypeParameter(2),
|
||||
ExplicitSimpleImporting(3),
|
||||
PackageMember(4),
|
||||
Unclassified(5),
|
||||
@@ -681,6 +684,7 @@ private class ElementsToShortenCollector(
|
||||
is FirLocalScope -> Local
|
||||
is FirClassUseSiteMemberScope -> ClassUseSite
|
||||
is FirNestedClassifierScope -> NestedClassifier
|
||||
is FirTypeParameterScope -> TypeParameter
|
||||
is FirNestedClassifierScopeWithSubstitution -> originalScope.toPartialOrder()
|
||||
is FirExplicitSimpleImportingScope -> ExplicitSimpleImporting
|
||||
is FirPackageMemberScope -> PackageMember
|
||||
@@ -746,7 +750,7 @@ private class ElementsToShortenCollector(
|
||||
|
||||
val name = classId.shortClassName
|
||||
val availableClassifiers = shorteningContext.findClassifiersInScopesByName(scopes, name)
|
||||
val matchingAvailableSymbol = availableClassifiers.firstOrNull { it.availableSymbol.symbol.classId == classId }
|
||||
val matchingAvailableSymbol = availableClassifiers.firstOrNull { it.availableSymbol.symbol.classIdIfExists == classId }
|
||||
val scopeForClass = matchingAvailableSymbol?.scope ?: return false
|
||||
|
||||
if (availableClassifiers.map { it.scope }.hasScopeCloserThan(scopeForClass, element)) return false
|
||||
@@ -803,7 +807,7 @@ private class ElementsToShortenCollector(
|
||||
)
|
||||
}
|
||||
// The class with name `classId.shortClassName` happens to be the same class referenced by this qualified access.
|
||||
availableClassifier.symbol.classId == classId -> {
|
||||
availableClassifier.symbol.classIdIfExists == classId -> {
|
||||
// Respect caller's request to use star import, if it's not already star-imported.
|
||||
return when {
|
||||
availableClassifier.importKind == ImportKind.EXPLICIT && importAllInParent -> {
|
||||
@@ -838,7 +842,7 @@ private class ElementsToShortenCollector(
|
||||
}
|
||||
|
||||
private fun importedClassifierOverwritesAvailableClassifier(
|
||||
availableClassifier: AvailableSymbol<FirClassLikeSymbol<*>>,
|
||||
availableClassifier: AvailableSymbol<FirClassifierSymbol<*>>,
|
||||
importAllInParent: Boolean
|
||||
): Boolean {
|
||||
val importKindFromOption = if (importAllInParent) ImportKind.STAR else ImportKind.EXPLICIT
|
||||
@@ -868,7 +872,7 @@ private class ElementsToShortenCollector(
|
||||
val positionScopes = shorteningContext.findScopesAtPosition(expression, getNamesToImport(), contextProvider) ?: return
|
||||
val availableClassifier = shorteningContext.findFirstClassifierInScopesByName(positionScopes, shortClassName) ?: return
|
||||
when {
|
||||
availableClassifier.symbol.classId == classToImport -> return
|
||||
availableClassifier.symbol.classIdIfExists == classToImport -> return
|
||||
importedClassifierOverwritesAvailableClassifier(availableClassifier, importAllInParent) -> {
|
||||
importAffectsUsages = true
|
||||
}
|
||||
|
||||
+10
@@ -71,4 +71,14 @@ public class FirIdeNormalAnalysisScriptSourceModuleReferenceShortenerTestGenerat
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class TypeParameters {
|
||||
@Test
|
||||
public void testAllFilesPresentInTypeParameters() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters"), Pattern.compile("^(.+)\\.kts$"), null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+34
@@ -755,4 +755,38 @@ public class FirIdeNormalAnalysisSourceModuleReferenceShortenerTestGenerated ext
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class TypeParameters {
|
||||
@Test
|
||||
public void testAllFilesPresentInTypeParameters() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionTypeParameterVsType.kt")
|
||||
public void testFunctionTypeParameterVsType() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters/functionTypeParameterVsType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterVsNestedType.kt")
|
||||
public void testTypeParameterVsNestedType() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters/typeParameterVsNestedType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterVsType_conflict.kt")
|
||||
public void testTypeParameterVsType_conflict() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters/typeParameterVsType_conflict.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterVsType_noConflict.kt")
|
||||
public void testTypeParameterVsType_noConflict() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters/typeParameterVsType_noConflict.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+34
@@ -755,4 +755,38 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceShortenerTestGenera
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class TypeParameters {
|
||||
@Test
|
||||
public void testAllFilesPresentInTypeParameters() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionTypeParameterVsType.kt")
|
||||
public void testFunctionTypeParameterVsType() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters/functionTypeParameterVsType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterVsNestedType.kt")
|
||||
public void testTypeParameterVsNestedType() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters/typeParameterVsNestedType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterVsType_conflict.kt")
|
||||
public void testTypeParameterVsType_conflict() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters/typeParameterVsType_conflict.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeParameterVsType_noConflict.kt")
|
||||
public void testTypeParameterVsType_noConflict() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters/typeParameterVsType_noConflict.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package test
|
||||
|
||||
interface MyType
|
||||
|
||||
<expr>
|
||||
context(test.MyType)
|
||||
fun <MyType> test.MyType.test(p: test.MyType) {
|
||||
val a: test.MyType
|
||||
}
|
||||
</expr>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
Before shortening: context(test.MyType)
|
||||
fun <MyType> test.MyType.test(p: test.MyType) {
|
||||
val a: test.MyType
|
||||
}
|
||||
with DO_NOT_SHORTEN:
|
||||
with SHORTEN_IF_ALREADY_IMPORTED:
|
||||
with SHORTEN_AND_IMPORT:
|
||||
with SHORTEN_AND_STAR_IMPORT:
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package test
|
||||
|
||||
|
||||
open class Base<T>()
|
||||
|
||||
class MyClass<MyType> {
|
||||
|
||||
interface MyType
|
||||
|
||||
<expr>
|
||||
context(MyClass.MyType)
|
||||
class Nested<Other : MyClass.MyType> : Base<MyClass.MyType>()
|
||||
</expr>
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
Before shortening: context(MyClass.MyType)
|
||||
class Nested<Other : MyClass.MyType> : Base<MyClass.MyType>()
|
||||
with DO_NOT_SHORTEN:
|
||||
with SHORTEN_IF_ALREADY_IMPORTED:
|
||||
[type] MyClass.MyType
|
||||
[type] MyClass.MyType
|
||||
[type] MyClass.MyType
|
||||
with SHORTEN_AND_IMPORT:
|
||||
[type] MyClass.MyType
|
||||
[type] MyClass.MyType
|
||||
[type] MyClass.MyType
|
||||
with SHORTEN_AND_STAR_IMPORT:
|
||||
[type] MyClass.MyType
|
||||
[type] MyClass.MyType
|
||||
[type] MyClass.MyType
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package test
|
||||
|
||||
interface MyType
|
||||
|
||||
open class Base<T>()
|
||||
|
||||
<expr>
|
||||
context(test.MyType)
|
||||
class MyClass<MyType, Other : test.MyType> : Base<test.MyType>()
|
||||
</expr>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
Before shortening: context(test.MyType)
|
||||
class MyClass<MyType, Other : test.MyType> : Base<test.MyType>()
|
||||
with DO_NOT_SHORTEN:
|
||||
with SHORTEN_IF_ALREADY_IMPORTED:
|
||||
with SHORTEN_AND_IMPORT:
|
||||
with SHORTEN_AND_STAR_IMPORT:
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package test
|
||||
|
||||
interface MyType
|
||||
|
||||
open class Base<T>()
|
||||
|
||||
class MyClass<MyType> {
|
||||
// TODO this test has an error, MyType should not be resolved here. See KT-61959
|
||||
<expr>
|
||||
context(test.MyType)
|
||||
class Nested<Other : test.MyType> : Base<test.MyType>()
|
||||
</expr>
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
Before shortening: context(test.MyType)
|
||||
class Nested<Other : test.MyType> : Base<test.MyType>()
|
||||
with DO_NOT_SHORTEN:
|
||||
with SHORTEN_IF_ALREADY_IMPORTED:
|
||||
with SHORTEN_AND_IMPORT:
|
||||
with SHORTEN_AND_STAR_IMPORT:
|
||||
+7
-3
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.fir.types.typeContext
|
||||
import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitorVoid
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
||||
import org.jetbrains.kotlin.util.PrivateForInline
|
||||
import org.jetbrains.kotlin.utils.yieldIfNotNull
|
||||
|
||||
object ContextCollector {
|
||||
@@ -358,10 +359,13 @@ private class ContextCollectorVisitor(
|
||||
* Processing those parts before adding the implicit receiver of the class
|
||||
* to the [context] allows to not collect incorrect contexts for them later on.
|
||||
*/
|
||||
@OptIn(PrivateForInline::class)
|
||||
private fun Processor.processClassHeader(regularClass: FirRegularClass) {
|
||||
processList(regularClass.contextReceivers)
|
||||
processList(regularClass.typeParameters)
|
||||
processList(regularClass.superTypeRefs)
|
||||
context.withTypeParametersOf(regularClass) {
|
||||
processList(regularClass.contextReceivers)
|
||||
processList(regularClass.typeParameters)
|
||||
processList(regularClass.superTypeRefs)
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitConstructor(constructor: FirConstructor) = withProcessor {
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package test
|
||||
|
||||
context(<expr>MyParam</expr>)
|
||||
class Outer<MyParam>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
Tower Data Context:
|
||||
Element 0
|
||||
Scope: FirDefaultStarImportingScope
|
||||
Element 1
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 2
|
||||
Scope: FirExplicitStarImportingScope
|
||||
Element 3
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 4
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 5
|
||||
Scope: FirPackageMemberScope
|
||||
Element 6
|
||||
Scope: FirExplicitSimpleImportingScope
|
||||
Element 7
|
||||
Scope: FirMemberTypeParameterScope
|
||||
Classifiers:
|
||||
FirTypeParameterSymbol MyParam
|
||||
|
||||
FILE: [ResolvedTo(IMPORTS)] declaredInClass_fromContextReceiver.kt
|
||||
context(R|MyParam|)
|
||||
public final [ResolvedTo(STATUS)] class Outer<[ResolvedTo(STATUS)] MyParam> : R|kotlin/Any| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] constructor<[ResolvedTo(STATUS)] MyParam>(): R|test/Outer<MyParam>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
class Outer<MyParam> {
|
||||
inner class Inner<T : <expr>MyParam</expr>>
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
Tower Data Context:
|
||||
Element 0
|
||||
Scope: FirDefaultStarImportingScope
|
||||
Element 1
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 2
|
||||
Scope: FirExplicitStarImportingScope
|
||||
Element 3
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 4
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 5
|
||||
Scope: FirPackageMemberScope
|
||||
Element 6
|
||||
Scope: FirExplicitSimpleImportingScope
|
||||
Element 7
|
||||
Scope: FirMemberTypeParameterScope
|
||||
Classifiers:
|
||||
FirTypeParameterSymbol MyParam
|
||||
Element 8
|
||||
Scope: FirNestedClassifierScopeImpl
|
||||
Classifiers:
|
||||
FirRegularClassSymbol public final inner class Inner<T : R|MyParam|, Outer(MyParam)> : R|kotlin/Any|
|
||||
Element 9
|
||||
Implicit receiver:
|
||||
FirRegularClassSymbol public final class Outer<MyParam> : R|kotlin/Any|
|
||||
Type: test/Outer<MyParam>
|
||||
Element 10
|
||||
Scope: FirMemberTypeParameterScope
|
||||
Classifiers:
|
||||
FirTypeParameterSymbol T : R|MyParam|
|
||||
|
||||
FILE: [ResolvedTo(IMPORTS)] declaredInClass_fromInner_typeBound.kt
|
||||
public final [ResolvedTo(STATUS)] class Outer<[ResolvedTo(STATUS)] MyParam> : R|kotlin/Any| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] constructor<[ResolvedTo(STATUS)] MyParam>(): R|test/Outer<MyParam>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final inner [ResolvedTo(STATUS)] class Inner<[ResolvedTo(STATUS)] T : R|MyParam|, [ResolvedTo(STATUS)] Outer(MyParam)> : R|kotlin/Any| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] test/Outer<MyParam>.constructor<[ResolvedTo(STATUS)] T : R|MyParam|>(): R|test/Outer.Inner<T, MyParam>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
class Outer<MyParam> {
|
||||
inner class Inner {
|
||||
fun member(p: <expr>MyParam</expr>) {}
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
Tower Data Context:
|
||||
Element 0
|
||||
Scope: FirDefaultStarImportingScope
|
||||
Element 1
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 2
|
||||
Scope: FirExplicitStarImportingScope
|
||||
Element 3
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 4
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 5
|
||||
Scope: FirPackageMemberScope
|
||||
Element 6
|
||||
Scope: FirExplicitSimpleImportingScope
|
||||
Element 7
|
||||
Scope: FirMemberTypeParameterScope
|
||||
Classifiers:
|
||||
FirTypeParameterSymbol MyParam
|
||||
Element 8
|
||||
Scope: FirNestedClassifierScopeImpl
|
||||
Classifiers:
|
||||
FirRegularClassSymbol public final inner class Inner<Outer(MyParam)> : R|kotlin/Any|
|
||||
Element 9
|
||||
Implicit receiver:
|
||||
FirRegularClassSymbol public final class Outer<MyParam> : R|kotlin/Any|
|
||||
Type: test/Outer<MyParam>
|
||||
Element 10
|
||||
Scope: FirMemberTypeParameterScope
|
||||
Element 11
|
||||
Implicit receiver:
|
||||
FirRegularClassSymbol public final inner class Inner<Outer(MyParam)> : R|kotlin/Any|
|
||||
Type: test/Outer.Inner<MyParam>
|
||||
Element 12
|
||||
Scope: FirLocalScope
|
||||
Properties:
|
||||
FirValueParameterSymbol p: R|MyParam|
|
||||
|
||||
FILE: [ResolvedTo(IMPORTS)] declaredInClass_fromInner_typeRefInMember.kt
|
||||
public final [ResolvedTo(STATUS)] class Outer<[ResolvedTo(STATUS)] MyParam> : R|kotlin/Any| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] constructor<[ResolvedTo(STATUS)] MyParam>(): R|test/Outer<MyParam>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final inner [ResolvedTo(STATUS)] class Inner<[ResolvedTo(STATUS)] Outer(MyParam)> : R|kotlin/Any| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] test/Outer<MyParam>.constructor(): R|test/Outer.Inner<MyParam>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final [ResolvedTo(BODY_RESOLVE)] fun member([ResolvedTo(BODY_RESOLVE)] p: R|MyParam|): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package test
|
||||
|
||||
class Outer<MyParam> {
|
||||
// TODO this test has an error, MyParam should not be resolved here. See KT-61959
|
||||
class Nested<T : <expr>MyParam</expr>>
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
Tower Data Context:
|
||||
Element 0
|
||||
Scope: FirDefaultStarImportingScope
|
||||
Element 1
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 2
|
||||
Scope: FirExplicitStarImportingScope
|
||||
Element 3
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 4
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 5
|
||||
Scope: FirPackageMemberScope
|
||||
Element 6
|
||||
Scope: FirExplicitSimpleImportingScope
|
||||
Element 7
|
||||
Scope: FirMemberTypeParameterScope
|
||||
Classifiers:
|
||||
FirTypeParameterSymbol MyParam
|
||||
Element 8
|
||||
Scope: FirNestedClassifierScopeImpl
|
||||
Classifiers:
|
||||
FirRegularClassSymbol public final class Nested<T : R|MyParam|> : R|kotlin/Any|
|
||||
Element 9
|
||||
Implicit receiver:
|
||||
FirRegularClassSymbol public final class Outer<MyParam> : R|kotlin/Any|
|
||||
Type: test/Outer<MyParam>
|
||||
Element 10
|
||||
Scope: FirMemberTypeParameterScope
|
||||
Classifiers:
|
||||
FirTypeParameterSymbol T : R|MyParam|
|
||||
|
||||
FILE: [ResolvedTo(IMPORTS)] declaredInClass_fromNested_typeBound.kt
|
||||
public final [ResolvedTo(STATUS)] class Outer<[ResolvedTo(STATUS)] MyParam> : R|kotlin/Any| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] constructor<[ResolvedTo(STATUS)] MyParam>(): R|test/Outer<MyParam>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final [ResolvedTo(STATUS)] class Nested<[ResolvedTo(STATUS)] T : R|MyParam|> : R|kotlin/Any| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] constructor<[ResolvedTo(STATUS)] T : R|MyParam|>(): R|test/Outer.Nested<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
class Outer<MyParam> {
|
||||
class Nested {
|
||||
fun member(p: <expr>MyParam</expr>) {}
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
Tower Data Context:
|
||||
Element 0
|
||||
Scope: FirDefaultStarImportingScope
|
||||
Element 1
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 2
|
||||
Scope: FirExplicitStarImportingScope
|
||||
Element 3
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 4
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 5
|
||||
Scope: FirPackageMemberScope
|
||||
Element 6
|
||||
Scope: FirExplicitSimpleImportingScope
|
||||
Element 7
|
||||
Scope: FirNestedClassifierScopeImpl
|
||||
Classifiers:
|
||||
FirRegularClassSymbol public final class Nested : R|kotlin/Any|
|
||||
Element 8
|
||||
Implicit receiver:
|
||||
FirRegularClassSymbol public final class Nested : R|kotlin/Any|
|
||||
Type: test/Outer.Nested
|
||||
Element 9
|
||||
Scope: FirLocalScope
|
||||
Properties:
|
||||
FirValueParameterSymbol p: <ERROR TYPE REF: Symbol not found for MyParam>
|
||||
|
||||
FILE: [ResolvedTo(IMPORTS)] declaredInClass_fromNested_typeRefInMember.kt
|
||||
public final [ResolvedTo(STATUS)] class Outer<[ResolvedTo(STATUS)] MyParam> : R|kotlin/Any| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] constructor<[ResolvedTo(STATUS)] MyParam>(): R|test/Outer<MyParam>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final [ResolvedTo(STATUS)] class Nested : R|kotlin/Any| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] constructor(): R|test/Outer.Nested| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final [ResolvedTo(BODY_RESOLVE)] fun member([ResolvedTo(BODY_RESOLVE)] p: <ERROR TYPE REF: Symbol not found for MyParam>): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
analysis/low-level-api-fir/testdata/contextCollector/typeParameters/declaredInClass_fromSuperType.kt
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
open class Base<T>
|
||||
|
||||
class Outer<MyParam> : Base<<expr>MyParam</expr>>()
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
Tower Data Context:
|
||||
Element 0
|
||||
Scope: FirDefaultStarImportingScope
|
||||
Element 1
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 2
|
||||
Scope: FirExplicitStarImportingScope
|
||||
Element 3
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 4
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 5
|
||||
Scope: FirPackageMemberScope
|
||||
Element 6
|
||||
Scope: FirExplicitSimpleImportingScope
|
||||
Element 7
|
||||
Scope: FirMemberTypeParameterScope
|
||||
Classifiers:
|
||||
FirTypeParameterSymbol MyParam
|
||||
|
||||
FILE: [ResolvedTo(IMPORTS)] declaredInClass_fromSuperType.kt
|
||||
public open [ResolvedTo(STATUS)] class Base<[ResolvedTo(STATUS)] T> : R|kotlin/Any| {
|
||||
public [ResolvedTo(STATUS)] constructor<[ResolvedTo(STATUS)] T>(): R|test/Base<T>| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
}
|
||||
public final [ResolvedTo(STATUS)] class Outer<[ResolvedTo(STATUS)] MyParam> : R|test/Base<MyParam>| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] constructor<[ResolvedTo(STATUS)] MyParam>(): R|test/Outer<MyParam>| {
|
||||
super<R|test/Base<MyParam>|>()
|
||||
}
|
||||
|
||||
}
|
||||
analysis/low-level-api-fir/testdata/contextCollector/typeParameters/declaredInClass_fromTypeBound.kt
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
package test
|
||||
|
||||
class Outer<MyParam, Other : <expr>MyParam</expr>>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
Tower Data Context:
|
||||
Element 0
|
||||
Scope: FirDefaultStarImportingScope
|
||||
Element 1
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 2
|
||||
Scope: FirExplicitStarImportingScope
|
||||
Element 3
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 4
|
||||
Scope: FirDefaultSimpleImportingScope
|
||||
Element 5
|
||||
Scope: FirPackageMemberScope
|
||||
Element 6
|
||||
Scope: FirExplicitSimpleImportingScope
|
||||
Element 7
|
||||
Scope: FirMemberTypeParameterScope
|
||||
Classifiers:
|
||||
FirTypeParameterSymbol MyParam
|
||||
FirTypeParameterSymbol Other : R|MyParam|
|
||||
|
||||
FILE: [ResolvedTo(IMPORTS)] declaredInClass_fromTypeBound.kt
|
||||
public final [ResolvedTo(STATUS)] class Outer<[ResolvedTo(STATUS)] MyParam, [ResolvedTo(STATUS)] Other : R|MyParam|> : R|kotlin/Any| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] constructor<[ResolvedTo(STATUS)] MyParam, [ResolvedTo(STATUS)] Other : R|MyParam|>(): R|test/Outer<MyParam, Other>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -71,4 +71,14 @@ public class ContextCollectorScriptTestGenerated extends AbstractContextCollecto
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testdata/contextCollector/smartCasts"), Pattern.compile("^(.+)\\.(kts)$"), null, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("analysis/low-level-api-fir/testdata/contextCollector/typeParameters")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class TypeParameters {
|
||||
@Test
|
||||
public void testAllFilesPresentInTypeParameters() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testdata/contextCollector/typeParameters"), Pattern.compile("^(.+)\\.(kts)$"), null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+52
@@ -293,4 +293,56 @@ public class ContextCollectorSourceTestGenerated extends AbstractContextCollecto
|
||||
runTest("analysis/low-level-api-fir/testdata/contextCollector/smartCasts/when.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("analysis/low-level-api-fir/testdata/contextCollector/typeParameters")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class TypeParameters {
|
||||
@Test
|
||||
public void testAllFilesPresentInTypeParameters() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testdata/contextCollector/typeParameters"), Pattern.compile("^(.+)\\.(kt)$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("declaredInClass_fromContextReceiver.kt")
|
||||
public void testDeclaredInClass_fromContextReceiver() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testdata/contextCollector/typeParameters/declaredInClass_fromContextReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("declaredInClass_fromInner_typeBound.kt")
|
||||
public void testDeclaredInClass_fromInner_typeBound() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testdata/contextCollector/typeParameters/declaredInClass_fromInner_typeBound.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("declaredInClass_fromInner_typeRefInMember.kt")
|
||||
public void testDeclaredInClass_fromInner_typeRefInMember() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testdata/contextCollector/typeParameters/declaredInClass_fromInner_typeRefInMember.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("declaredInClass_fromNested_typeBound.kt")
|
||||
public void testDeclaredInClass_fromNested_typeBound() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testdata/contextCollector/typeParameters/declaredInClass_fromNested_typeBound.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("declaredInClass_fromNested_typeRefInMember.kt")
|
||||
public void testDeclaredInClass_fromNested_typeRefInMember() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testdata/contextCollector/typeParameters/declaredInClass_fromNested_typeRefInMember.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("declaredInClass_fromSuperType.kt")
|
||||
public void testDeclaredInClass_fromSuperType() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testdata/contextCollector/typeParameters/declaredInClass_fromSuperType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("declaredInClass_fromTypeBound.kt")
|
||||
public void testDeclaredInClass_fromTypeBound() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testdata/contextCollector/typeParameters/declaredInClass_fromTypeBound.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user