Made vararg parameters have Array<out T> type

instead of simply Array<T>
  #KT-1638 Fixed
  #KT-2163 Fixed
  #KT-3213 Fixed
  #KT-4172 Fixed
  #KT-5534 Fixed
This commit is contained in:
Svetlana Isakova
2014-12-09 14:11:11 +03:00
parent d893e8283e
commit 5b4f10e698
42 changed files with 266 additions and 65 deletions
@@ -73,8 +73,7 @@ class LazyJavaTypeResolver(
}
}
val howArgumentTypeIsUsed = if (isVararg) MEMBER_SIGNATURE_CONTRAVARIANT else TYPE_ARGUMENT
val componentType = transformJavaType(javaComponentType, howArgumentTypeIsUsed.toAttributes(attr.allowFlexible))
val componentType = transformJavaType(javaComponentType, TYPE_ARGUMENT.toAttributes(attr.allowFlexible))
if (PLATFORM_TYPES && attr.allowFlexible) {
return FlexibleJavaClassifierTypeCapabilities.create(
@@ -82,7 +81,7 @@ class LazyJavaTypeResolver(
TypeUtils.makeNullable(KotlinBuiltIns.getInstance().getArrayType(OUT_VARIANCE, componentType)))
}
val projectionKind = if (attr.howThisTypeIsUsed == MEMBER_SIGNATURE_CONTRAVARIANT && !isVararg) OUT_VARIANCE else INVARIANT
val projectionKind = if (attr.howThisTypeIsUsed == MEMBER_SIGNATURE_CONTRAVARIANT || isVararg) OUT_VARIANCE else INVARIANT
val result = KotlinBuiltIns.getInstance().getArrayType(projectionKind, componentType)
return TypeUtils.makeNullableAsSpecified(result, !attr.isMarkedNotNull)
}