KT-13822 Exception in the compiler for start-projection of a type alias
Use ClassifierWithTypeParameters in StarProjectionImpl.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
typealias A<T> = Map<T, T>
|
||||
typealias B = A<*>
|
||||
|
||||
fun check(x: B) = x
|
||||
|
||||
fun test1(x: Map<Int, Int>) = check(x)
|
||||
|
||||
fun test2(x: Map<String, Int>) = check(x)
|
||||
|
||||
fun test3(x: Map<Int, String>) = check(x).size
|
||||
|
||||
fun test4(x: Map<Int, String>) = <!MEMBER_PROJECTED_OUT!>check(x)["42"]<!>
|
||||
|
||||
fun test5(x: Map<Int, String>) = <!MEMBER_PROJECTED_OUT!>check(x)[42]<!>
|
||||
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
public fun check(/*0*/ x: B /* = kotlin.collections.Map<*, *> */): B /* = kotlin.collections.Map<*, *> */
|
||||
public fun test1(/*0*/ x: kotlin.collections.Map<kotlin.Int, kotlin.Int>): B /* = kotlin.collections.Map<*, *> */
|
||||
public fun test2(/*0*/ x: kotlin.collections.Map<kotlin.String, kotlin.Int>): B /* = kotlin.collections.Map<*, *> */
|
||||
public fun test3(/*0*/ x: kotlin.collections.Map<kotlin.Int, kotlin.String>): kotlin.Int
|
||||
public fun test4(/*0*/ x: kotlin.collections.Map<kotlin.Int, kotlin.String>): kotlin.Any?
|
||||
public fun test5(/*0*/ x: kotlin.collections.Map<kotlin.Int, kotlin.String>): kotlin.Any?
|
||||
public typealias A</*0*/ T> = kotlin.collections.Map<T, T>
|
||||
public typealias B = A<*>
|
||||
@@ -20262,6 +20262,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("starProjection.kt")
|
||||
public void testStarProjection() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/starProjection.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("starProjectionInTypeAliasArgument.kt")
|
||||
public void testStarProjectionInTypeAliasArgument() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/starProjectionInTypeAliasArgument.kt");
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.types
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
|
||||
@@ -36,7 +37,7 @@ class StarProjectionImpl(
|
||||
}
|
||||
|
||||
fun TypeParameterDescriptor.starProjectionType(): KotlinType {
|
||||
val classDescriptor = this.containingDeclaration as ClassDescriptor
|
||||
val classDescriptor = this.containingDeclaration as ClassifierDescriptorWithTypeParameters
|
||||
val typeParameters = classDescriptor.typeConstructor.parameters.map { it.typeConstructor }
|
||||
return TypeSubstitutor.create(
|
||||
object : TypeConstructorSubstitution() {
|
||||
|
||||
Reference in New Issue
Block a user