Rename Extension annotation to ExtensionFunctionType

This commit is contained in:
Alexander Udalov
2015-11-25 19:29:20 +03:00
parent 0a47d1cac2
commit 460dad135c
35 changed files with 81 additions and 67 deletions
+5
View File
@@ -69,6 +69,11 @@ public enum class DeprecationLevel {
*/
@Target(TYPE)
@MustBeDocumented
public annotation class ExtensionFunctionType
@Target(TYPE)
@MustBeDocumented
@Deprecated("Use @ExtensionFunctionType instead.", replaceWith = ReplaceWith("@ExtensionFunctionType"))
public annotation class Extension
/**
@@ -139,8 +139,7 @@ public abstract class KotlinBuiltIns {
public final FqName throwable = fqName("Throwable");
public final FqName deprecated = fqName("Deprecated");
public final FqName tailRecursive = fqName("tailrec");
public final FqName extension = fqName("Extension");
public final FqName extensionFunctionType = fqName("ExtensionFunctionType");
public final FqName target = annotationName("Target");
public final FqName annotationTarget = annotationName("AnnotationTarget");
public final FqName annotationRetention = annotationName("AnnotationRetention");
@@ -157,6 +156,9 @@ public abstract class KotlinBuiltIns {
public final FqNameUnsafe kCallable = reflect("KCallable");
public final ClassId kProperty = ClassId.topLevel(reflect("KProperty").toSafe());
// TODO: remove in 1.0
public final FqName deprecatedExtensionAnnotation = fqName("Extension");
public final Map<FqNameUnsafe, PrimitiveType> fqNameToPrimitiveType;
public final Map<FqNameUnsafe, PrimitiveType> arrayClassFqNameToPrimitiveType;
{
@@ -697,12 +699,13 @@ public abstract class KotlinBuiltIns {
@NotNull
public AnnotationDescriptor createExtensionAnnotation() {
return new AnnotationDescriptorImpl(getBuiltInClassByName(FQ_NAMES.extension.shortName()).getDefaultType(),
return new AnnotationDescriptorImpl(getBuiltInClassByName(FQ_NAMES.extensionFunctionType.shortName()).getDefaultType(),
Collections.<ValueParameterDescriptor, ConstantValue<?>>emptyMap(), SourceElement.NO_SOURCE);
}
private static boolean isTypeAnnotatedWithExtension(@NotNull KotlinType type) {
return type.getAnnotations().findAnnotation(FQ_NAMES.extension) != null;
return type.getAnnotations().findAnnotation(FQ_NAMES.extensionFunctionType) != null ||
type.getAnnotations().findAnnotation(FQ_NAMES.deprecatedExtensionAnnotation) != null;
}
@NotNull
@@ -716,14 +719,14 @@ public abstract class KotlinBuiltIns {
int size = parameterTypes.size();
ClassDescriptor classDescriptor = receiverType == null ? getFunction(size) : getExtensionFunction(size);
Annotations typeAnnotations = receiverType == null ? annotations : addExtensionAnnotation(annotations);
Annotations typeAnnotations = receiverType == null ? annotations : addExtensionFunctionTypeAnnotation(annotations);
return KotlinTypeImpl.create(typeAnnotations, classDescriptor, false, arguments);
}
@NotNull
private Annotations addExtensionAnnotation(@NotNull Annotations annotations) {
if (annotations.findAnnotation(FQ_NAMES.extension) != null) return annotations;
private Annotations addExtensionFunctionTypeAnnotation(@NotNull Annotations annotations) {
if (annotations.findAnnotation(FQ_NAMES.extensionFunctionType) != null) return annotations;
// TODO: preserve laziness of given annotations
return new AnnotationsImpl(plus(annotations, listOf(createExtensionAnnotation())));