Do not report "no reflection" inspection where reflection is not used

#KT-7059 Fixed
This commit is contained in:
Alexander Udalov
2015-03-23 13:12:47 +03:00
parent d569ea5974
commit 3335752462
6 changed files with 71 additions and 9 deletions
@@ -22,6 +22,8 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.isSubpackageOf
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.TypeUtils.makeStarProjection
@@ -125,4 +127,12 @@ public class ReflectionTypes(private val module: ModuleDescriptor) {
arguments.add(TypeProjectionImpl(returnType))
return JetTypeImpl(annotations, classDescriptor.getTypeConstructor(), false, arguments, classDescriptor.getMemberScope(arguments))
}
companion object {
public fun isReflectionType(type: JetType): Boolean {
val descriptor = type.getConstructor().getDeclarationDescriptor() ?: return false
val fqName = DescriptorUtils.getFqName(descriptor)
return fqName.isSafe() && fqName.toSafe().isSubpackageOf(KOTLIN_REFLECT_FQ_NAME)
}
}
}