Filter annotations while substituting compound type

This commit is contained in:
Svetlana Isakova
2015-10-21 19:34:11 +03:00
parent f00af72e0f
commit c167a77c8a
4 changed files with 25 additions and 4 deletions
@@ -240,7 +240,7 @@ public class TypeSubstitutor {
return containedOrCapturedTypeParameters.contains(key.getConstructor()) ? substitution.get(key) : null;
}
};
KotlinType substitutedType = KotlinTypeImpl.create(type.getAnnotations(), // Old annotations. This is questionable
KotlinType substitutedType = KotlinTypeImpl.create(substitution.filterAnnotations(type.getAnnotations()), // Old annotations. This is questionable
type.getConstructor(), // The same constructor
type.isMarkedNullable(), // Same nullability
substitutedArguments,
@@ -101,7 +101,7 @@ fun TypeProjection.substitute(doSubstitute: (KotlinType) -> KotlinType): TypePro
}
fun KotlinType.replaceAnnotations(newAnnotations: Annotations): KotlinType {
if (newAnnotations.isEmpty()) return this
if (annotations.isEmpty() && newAnnotations.isEmpty()) return this
return object : DelegatingType() {
override fun getDelegate() = this@replaceAnnotations