Frontend changes for reified type parameters

Allowing reified only for inline functions and Intrinsics
This commit is contained in:
Denis Zharkov
2014-10-20 14:19:42 +04:00
committed by Andrey Breslav
parent 79c6f2b91b
commit b3691b7358
28 changed files with 822 additions and 414 deletions
@@ -381,6 +381,7 @@ public interface Errors {
DiagnosticFactory0<JetExpression> DANGLING_FUNCTION_LITERAL_ARGUMENT_SUSPECTED = DiagnosticFactory0.create(WARNING);
DiagnosticFactory1<PsiElement, TypeParameterDescriptor> TYPE_PARAMETER_AS_REIFIED = DiagnosticFactory1.create(ERROR);
DiagnosticFactory0<PsiElement> REIFIED_TYPE_PARAMETER_NO_INLINE = DiagnosticFactory0.create(ERROR);
// Type inference
@@ -479,6 +479,7 @@ public class DefaultErrorMessages {
"Separate it with a semicolon (;) if it is not intended to be an argument.");
MAP.put(TYPE_PARAMETER_AS_REIFIED, "Cannot use ''{0}'' as reified type parameter. Use a class instead.", NAME);
MAP.put(REIFIED_TYPE_PARAMETER_NO_INLINE, "Only type parameters of inline functions can be reified");
MAP.put(SUPERTYPES_FOR_ANNOTATION_CLASS, "Annotation class cannot have supertypes");
MAP.put(MISSING_VAL_ON_ANNOTATION_PARAMETER, "'val' keyword is missing on annotation parameter");
@@ -30,6 +30,10 @@ public fun DeclarationDescriptor.hasPlatformStaticAnnotation(): Boolean {
return getAnnotations().findAnnotation(FqName("kotlin.platform.platformStatic")) != null
}
public fun DeclarationDescriptor.hasIntrinsicAnnotation(): Boolean {
return getAnnotations().findAnnotation(FqName("kotlin.jvm.internal.Intrinsic")) != null
}
public fun CallableDescriptor.isPlatformStaticInObject(): Boolean =
DescriptorUtils.isObject(getContainingDeclaration()) && hasPlatformStaticAnnotation()