Support reified extension properties
This commit is contained in:
+1
-1
@@ -233,7 +233,7 @@ class ReifiedTypeParameterAnnotationChecker : SimpleDeclarationChecker {
|
|||||||
diagnosticHolder: DiagnosticSink,
|
diagnosticHolder: DiagnosticSink,
|
||||||
bindingContext: BindingContext
|
bindingContext: BindingContext
|
||||||
) {
|
) {
|
||||||
if (descriptor is CallableDescriptor && !InlineUtil.isInline(descriptor)) {
|
if (descriptor is CallableDescriptor && !InlineUtil.isInlineFunctionOrProperty(descriptor)) {
|
||||||
checkTypeParameterDescriptorsAreNotReified(descriptor.typeParameters, diagnosticHolder)
|
checkTypeParameterDescriptorsAreNotReified(descriptor.typeParameters, diagnosticHolder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,28 @@ public class InlineUtil {
|
|||||||
FunctionTypesKt.isFunctionType(valueParameterOrReceiver.getOriginal().getType());
|
FunctionTypesKt.isFunctionType(valueParameterOrReceiver.getOriginal().getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isInlineFunctionOrProperty(@Nullable DeclarationDescriptor descriptor) {
|
||||||
|
return isInline(descriptor) || isInlineProperty(descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isInline(@Nullable DeclarationDescriptor descriptor) {
|
public static boolean isInline(@Nullable DeclarationDescriptor descriptor) {
|
||||||
return descriptor instanceof FunctionDescriptor && getInlineStrategy((FunctionDescriptor) descriptor).isInline();
|
return descriptor instanceof FunctionDescriptor && getInlineStrategy((FunctionDescriptor) descriptor).isInline();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isInlineProperty(@Nullable DeclarationDescriptor descriptor) {
|
||||||
|
if (!(descriptor instanceof PropertyDescriptor)) return false;
|
||||||
|
|
||||||
|
PropertyGetterDescriptor getter = ((PropertyDescriptor) descriptor).getGetter();
|
||||||
|
if (getter == null || !getter.isInline()) return false;
|
||||||
|
|
||||||
|
if (((PropertyDescriptor) descriptor).isVar()) {
|
||||||
|
PropertySetterDescriptor setter = ((PropertyDescriptor) descriptor).getSetter();
|
||||||
|
return setter != null && setter.isInline();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isInlineOrContainingInline(@Nullable DeclarationDescriptor descriptor) {
|
public static boolean isInlineOrContainingInline(@Nullable DeclarationDescriptor descriptor) {
|
||||||
if (isInline(descriptor)) return true;
|
if (isInline(descriptor)) return true;
|
||||||
if (descriptor == null) return false;
|
if (descriptor == null) return false;
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// FILE: 1.kt
|
||||||
|
package test
|
||||||
|
|
||||||
|
inline val <reified T: Any> T.value: String
|
||||||
|
get() = T::class.java.name
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
class OK
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return OK().value
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// FILE: 1.kt
|
||||||
|
package test
|
||||||
|
|
||||||
|
var bvalue: String = ""
|
||||||
|
|
||||||
|
inline var <reified T : Any> T.value: String
|
||||||
|
get() = T::class.java.name + bvalue
|
||||||
|
set(p: String) {
|
||||||
|
bvalue = p
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
class O
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val o = O()
|
||||||
|
val value1 = o.value
|
||||||
|
if (value1 != "O") return "fail 1: $value1"
|
||||||
|
|
||||||
|
o.value = "K"
|
||||||
|
return o.value
|
||||||
|
}
|
||||||
@@ -1522,6 +1522,18 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/property"), Pattern.compile("^(.+)\\.kt$"), true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/property"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reifiedVal.kt")
|
||||||
|
public void testReifiedVal() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/property/reifiedVal.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reifiedVar.kt")
|
||||||
|
public void testReifiedVar() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/property/reifiedVar.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("simple.kt")
|
@TestMetadata("simple.kt")
|
||||||
public void testSimple() throws Exception {
|
public void testSimple() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/property/simple.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/property/simple.kt");
|
||||||
|
|||||||
+12
@@ -1522,6 +1522,18 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/property"), Pattern.compile("^(.+)\\.kt$"), true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/property"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reifiedVal.kt")
|
||||||
|
public void testReifiedVal() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/property/reifiedVal.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reifiedVar.kt")
|
||||||
|
public void testReifiedVar() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/property/reifiedVar.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("simple.kt")
|
@TestMetadata("simple.kt")
|
||||||
public void testSimple() throws Exception {
|
public void testSimple() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/property/simple.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/property/simple.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user