Add quickfix for usages of javaClass<T>() in annotations loaded from Java

This commit is contained in:
Denis Zharkov
2015-04-17 17:48:20 +03:00
parent 7325a459e5
commit cc9322fbdd
35 changed files with 444 additions and 10 deletions
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.types.isDynamic
import org.jetbrains.kotlin.types.TypeProjection
import org.jetbrains.kotlin.types.TypeProjectionImpl
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.types.DelegatingType
private fun JetType.getContainedTypeParameters(): Collection<TypeParameterDescriptor> {
@@ -83,4 +84,14 @@ fun JetType.replaceAnnotations(newAnnotations: Annotations): JetType {
override fun getAnnotations() = newAnnotations
}
}
}
public fun JetType.isJavaLangClass(): Boolean {
val classifier = getConstructor().getDeclarationDescriptor()
if (classifier !is ClassDescriptor) return false
return DescriptorUtils.isJavaLangClass(classifier)
}
public fun JetType.isArrayOfJavaLangClass(): Boolean =
KotlinBuiltIns.isArray(this) && getArguments().firstOrNull()?.getType()?.isJavaLangClass() ?: false