Fix generic class literals, substitute type parameters with stars
This commit is contained in:
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.name.FqName
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
|
import org.jetbrains.kotlin.types.TypeUtils.makeStarProjection
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
|
|
||||||
@@ -59,8 +60,13 @@ public class ReflectionTypes(private val module: ModuleDescriptor) {
|
|||||||
public val kMutableTopLevelExtensionProperty: ClassDescriptor by ClassLookup
|
public val kMutableTopLevelExtensionProperty: ClassDescriptor by ClassLookup
|
||||||
|
|
||||||
public fun getKClassType(annotations: Annotations, classDescriptor: ClassDescriptor): JetType {
|
public fun getKClassType(annotations: Annotations, classDescriptor: ClassDescriptor): JetType {
|
||||||
val arguments = listOf(TypeProjectionImpl(Variance.INVARIANT, classDescriptor.getDefaultType()))
|
val typeConstructor = classDescriptor.getTypeConstructor()
|
||||||
return JetTypeImpl(annotations, kClass.getTypeConstructor(), false, arguments, kClass.getMemberScope(arguments))
|
val arguments = typeConstructor.getParameters().map(TypeUtils::makeStarProjection)
|
||||||
|
val kClassArguments = listOf(TypeProjectionImpl(
|
||||||
|
Variance.INVARIANT,
|
||||||
|
JetTypeImpl(Annotations.EMPTY, typeConstructor, false, arguments, classDescriptor.getMemberScope(arguments))
|
||||||
|
))
|
||||||
|
return JetTypeImpl(annotations, kClass.getTypeConstructor(), false, kClassArguments, kClass.getMemberScope(kClassArguments))
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun getKFunctionType(
|
public fun getKFunctionType(
|
||||||
|
|||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
import kotlin.reflect.KMemberProperty
|
||||||
|
|
||||||
|
class A<T> {
|
||||||
|
val result = "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val k = A::class.getProperties().single()
|
||||||
|
k : KMemberProperty<A<*>, *>
|
||||||
|
return k.get(A<String>()) as String
|
||||||
|
}
|
||||||
+6
@@ -2848,6 +2848,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
|||||||
doTestWithStdlib(fileName);
|
doTestWithStdlib(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericClassLiteralPropertyReceiverIsStar.kt")
|
||||||
|
public void testGenericClassLiteralPropertyReceiverIsStar() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/genericClassLiteralPropertyReceiverIsStar.kt");
|
||||||
|
doTestWithStdlib(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("getExtensionPropertiesMutableVsReadonly.kt")
|
@TestMetadata("getExtensionPropertiesMutableVsReadonly.kt")
|
||||||
public void testGetExtensionPropertiesMutableVsReadonly() throws Exception {
|
public void testGetExtensionPropertiesMutableVsReadonly() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/getExtensionPropertiesMutableVsReadonly.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/getExtensionPropertiesMutableVsReadonly.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user