Introduce builder-like inference with an explicit opt-in for it

- Add marker for the experimental type inference features
 - Add annotation that will control builder-like inference
 - Require that annotation on corresponding parameters and extensions
 - Allow to use builder inference without suspendability

 Changes in tests and refactorings (rename mainly) are going to be
 introduced in further commits
This commit is contained in:
Mikhail Zarechenskiy
2018-09-18 10:33:14 +03:00
parent 5e9b31ca2c
commit a293aded5d
12 changed files with 205 additions and 12 deletions
@@ -145,6 +145,11 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD
runTest("compiler/testData/loadJava/compiledKotlin/annotations/classMembers/PropertyField.kt");
}
@TestMetadata("PublishedApiAnnotationOnInlineClassCosntructor.kt")
public void testPublishedApiAnnotationOnInlineClassCosntructor() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/classMembers/PublishedApiAnnotationOnInlineClassCosntructor.kt");
}
@TestMetadata("Setter.kt")
public void testSetter() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Setter.kt");
@@ -19,6 +19,7 @@ private val LOW_PRIORITY_IN_OVERLOAD_RESOLUTION_FQ_NAME = FqName("kotlin.interna
private val HIDES_MEMBERS_ANNOTATION_FQ_NAME = FqName("kotlin.internal.HidesMembers")
private val ONLY_INPUT_TYPES_FQ_NAME = FqName("kotlin.internal.OnlyInputTypes")
private val DYNAMIC_EXTENSION_FQ_NAME = FqName("kotlin.internal.DynamicExtension")
private val BUILDER_INFERENCE_ANNOTATION_FQ_NAME = FqName("kotlin.BuilderInference")
// @HidesMembers annotation only has effect for members with these names
val HIDES_MEMBERS_NAME_LIST = setOf(Name.identifier("forEach"))
@@ -39,6 +40,9 @@ fun CallableDescriptor.hasDynamicExtensionAnnotation(): Boolean = annotations.ha
fun TypeParameterDescriptor.hasOnlyInputTypesAnnotation(): Boolean = annotations.hasAnnotation(ONLY_INPUT_TYPES_FQ_NAME)
fun CallableDescriptor.hasBuilderInferenceAnnotation(): Boolean =
annotations.hasAnnotation(BUILDER_INFERENCE_ANNOTATION_FQ_NAME)
fun getExactInAnnotations(): Annotations = AnnotationsWithOnly(EXACT_ANNOTATION_FQ_NAME)
private class AnnotationsWithOnly(val presentAnnotation: FqName): Annotations {