Avoid creating SimpleType instances for default type

This commit is contained in:
Denis Zharkov
2017-05-24 13:54:31 +03:00
parent 8576054788
commit 59f2ba98a6
8 changed files with 95 additions and 81 deletions
@@ -34,13 +34,27 @@ object KotlinTypeFactory {
}
}
@JvmStatic
fun simpleType(
annotations: Annotations,
constructor: TypeConstructor,
arguments: List<TypeProjection>,
nullable: Boolean
): SimpleType {
if (annotations.isEmpty() && arguments.isEmpty() && !nullable && constructor.declarationDescriptor != null) {
return constructor.declarationDescriptor!!.defaultType
}
return SimpleTypeImpl(annotations, constructor, arguments, nullable, computeMemberScope(constructor, arguments))
}
@JvmStatic
fun simpleType(
annotations: Annotations,
constructor: TypeConstructor,
arguments: List<TypeProjection>,
nullable: Boolean,
memberScope: MemberScope = computeMemberScope(constructor, arguments)
memberScope: MemberScope
): SimpleType = SimpleTypeImpl(annotations, constructor, arguments, nullable, memberScope)
@JvmStatic