KT-11588 Type aliases
Type alias stubs indexing (required for index-based declaration providers)
This commit is contained in:
+5
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.psi.stubs.elements
|
||||
|
||||
import com.intellij.psi.stubs.IndexSink
|
||||
import com.intellij.psi.stubs.StubElement
|
||||
import com.intellij.psi.stubs.StubInputStream
|
||||
import com.intellij.psi.stubs.StubOutputStream
|
||||
@@ -47,4 +48,8 @@ class KtTypeAliasElementType(debugName: String) :
|
||||
val isTopLevel = dataStream.readBoolean()
|
||||
return KotlinTypeAliasStubImpl(KtStubElementTypes.TYPEALIAS, parentStub, name, fqName, isTopLevel)
|
||||
}
|
||||
|
||||
override fun indexStub(stub: KotlinTypeAliasStub, sink: IndexSink) {
|
||||
StubIndexService.getInstance().indexTypeAlias(stub, sink)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ open class StubIndexService protected constructor() {
|
||||
open fun indexFunction(stub: KotlinFunctionStub, sink: IndexSink) {
|
||||
}
|
||||
|
||||
open fun indexTypeAlias(stub: KotlinTypeAliasStub, sink: IndexSink) {
|
||||
}
|
||||
|
||||
open fun indexObject(stub: KotlinObjectStub, sink: IndexSink) {
|
||||
}
|
||||
|
||||
|
||||
@@ -480,7 +480,7 @@ class TypeResolver(
|
||||
}
|
||||
|
||||
override fun boundsViolationInSubstitution(bound: KotlinType, argument: KotlinType, typeParameter: TypeParameterDescriptor) {
|
||||
TODO()
|
||||
TODO("boundsViolationInSubstitution")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,9 +529,11 @@ class TypeResolver(
|
||||
"Type alias expansion: result for ${typeAliasExpansion.descriptor} is ${expandedProjection.projectionKind}, should be invariant"
|
||||
}
|
||||
|
||||
val abbreviatedType = KotlinTypeImpl.create(annotations, typeAliasExpansion.descriptor.typeConstructor,
|
||||
val abbreviatedType = KotlinTypeImpl.create(annotations,
|
||||
typeAliasExpansion.descriptor.typeConstructor,
|
||||
originalProjection.type.isMarkedNullable,
|
||||
typeAliasExpansion.arguments, MemberScope.Empty)
|
||||
typeAliasExpansion.arguments,
|
||||
MemberScope.Empty)
|
||||
|
||||
return expandedType.withAbbreviatedType(abbreviatedType)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
typealias S = String
|
||||
typealias SS = S
|
||||
typealias SSS = SS
|
||||
|
||||
val x1: S = ""
|
||||
val x2: SS = ""
|
||||
val x3: SSS = ""
|
||||
|
||||
val x4: S? = ""
|
||||
val x5: SS? = ""
|
||||
val x6: SSS? = ""
|
||||
@@ -0,0 +1,17 @@
|
||||
package test
|
||||
|
||||
public typealias S = kotlin.String
|
||||
public typealias SS = test.S
|
||||
public typealias SSS = test.SS
|
||||
public val x1: test.S [= kotlin.String] = ""
|
||||
public fun <get-x1>(): test.S [= kotlin.String]
|
||||
public val x2: test.SS [= kotlin.String] = ""
|
||||
public fun <get-x2>(): test.SS [= kotlin.String]
|
||||
public val x3: test.SSS [= kotlin.String] = ""
|
||||
public fun <get-x3>(): test.SSS [= kotlin.String]
|
||||
public val x4: test.S? [= kotlin.String?] = ""
|
||||
public fun <get-x4>(): test.S? [= kotlin.String?]
|
||||
public val x5: test.SS? [= kotlin.String?] = ""
|
||||
public fun <get-x5>(): test.SS? [= kotlin.String?]
|
||||
public val x6: test.SSS? [= kotlin.String?] = ""
|
||||
public fun <get-x6>(): test.SSS? [= kotlin.String?]
|
||||
@@ -0,0 +1,13 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
typealias L<T> = List<T>
|
||||
typealias LL<T> = L<T>
|
||||
typealias LLL<T> = LL<T>
|
||||
|
||||
fun test1(x: L<String>) {}
|
||||
fun test2(x: LL<String>) {}
|
||||
fun test3(x: LLL<String>) {}
|
||||
fun test4(x: L<L<String>>) {}
|
||||
fun test5(x: LL<LL<String>>) {}
|
||||
fun test6(x: LLL<LLL<String>>) {}
|
||||
@@ -0,0 +1,11 @@
|
||||
package test
|
||||
|
||||
public typealias L</*0*/ T> = kotlin.collections.List<T>
|
||||
public typealias LL</*0*/ T> = test.L<T>
|
||||
public typealias LLL</*0*/ T> = test.LL<T>
|
||||
public fun test1(/*0*/ x: test.L<kotlin.String> [= kotlin.collections.List<out kotlin.String>]): kotlin.Unit
|
||||
public fun test2(/*0*/ x: test.LL<kotlin.String> [= kotlin.collections.List<out kotlin.String>]): kotlin.Unit
|
||||
public fun test3(/*0*/ x: test.LLL<kotlin.String> [= kotlin.collections.List<out kotlin.String>]): kotlin.Unit
|
||||
public fun test4(/*0*/ x: test.L<test.L<kotlin.String> [= kotlin.collections.List<out kotlin.String>]> [= kotlin.collections.List<out test.L<kotlin.String> [= kotlin.collections.List<out kotlin.String>]>]): kotlin.Unit
|
||||
public fun test5(/*0*/ x: test.LL<test.LL<kotlin.String> [= kotlin.collections.List<out kotlin.String>]> [= kotlin.collections.List<out test.LL<kotlin.String> [= kotlin.collections.List<out kotlin.String>]>]): kotlin.Unit
|
||||
public fun test6(/*0*/ x: test.LLL<test.LLL<kotlin.String> [= kotlin.collections.List<out kotlin.String>]> [= kotlin.collections.List<out test.LLL<kotlin.String> [= kotlin.collections.List<out kotlin.String>]>]): kotlin.Unit
|
||||
+2
-2
@@ -111,8 +111,8 @@ public class RecursiveDescriptorProcessor {
|
||||
|
||||
@Override
|
||||
public Boolean visitTypeAliasDescriptor(TypeAliasDescriptor descriptor, D data) {
|
||||
// TODO typealias
|
||||
return true;
|
||||
return applyWorker(descriptor, data)
|
||||
&& visitChildren(descriptor.getDeclaredTypeParameters(), data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4796,6 +4796,27 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledKotlin/typealias")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Typealias extends AbstractLoadJavaTest {
|
||||
public void testAllFilesPresentInTypealias() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/loadJava/compiledKotlin/typealias"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("Basic.kt")
|
||||
public void testBasic() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/typealias/Basic.kt");
|
||||
doTestCompiledKotlin(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Generic.kt")
|
||||
public void testGeneric() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/typealias/Generic.kt");
|
||||
doTestCompiledKotlin(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledKotlin/visibility")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+21
@@ -3029,6 +3029,27 @@ public class LoadKotlinWithTypeTableTestGenerated extends AbstractLoadKotlinWith
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledKotlin/typealias")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Typealias extends AbstractLoadKotlinWithTypeTableTest {
|
||||
public void testAllFilesPresentInTypealias() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/loadJava/compiledKotlin/typealias"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("Basic.kt")
|
||||
public void testBasic() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/typealias/Basic.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Generic.kt")
|
||||
public void testGeneric() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/typealias/Generic.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledKotlin/visibility")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+21
@@ -3031,6 +3031,27 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledKotlin/typealias")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Typealias extends AbstractJvmRuntimeDescriptorLoaderTest {
|
||||
public void testAllFilesPresentInTypealias() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/loadJava/compiledKotlin/typealias"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("Basic.kt")
|
||||
public void testBasic() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/typealias/Basic.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Generic.kt")
|
||||
public void testGeneric() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/typealias/Generic.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledKotlin/visibility")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user