substitute upper bounds after creating all substitutions for type parameters
(otherwise it doesn't work for forward references)
This commit is contained in:
@@ -66,7 +66,7 @@ public class DescriptorSubstitutor {
|
||||
return "DescriptorSubstitutor.substituteTypeParameters(" + mutableSubstitution + " / " + originalSubstitutor.getSubstitution() + ")";
|
||||
}
|
||||
});
|
||||
|
||||
Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> substitutedMap = Maps.newHashMap();
|
||||
for (TypeParameterDescriptor descriptor : typeParameters) {
|
||||
TypeParameterDescriptorImpl substituted = TypeParameterDescriptorImpl.createForFurtherModification(
|
||||
newContainingDeclaration,
|
||||
@@ -79,11 +79,15 @@ public class DescriptorSubstitutor {
|
||||
|
||||
mutableSubstitution.put(descriptor.getTypeConstructor(), new TypeProjection(substituted.getDefaultType()));
|
||||
|
||||
substitutedMap.put(descriptor, substituted);
|
||||
result.add(substituted);
|
||||
}
|
||||
|
||||
for (TypeParameterDescriptor descriptor : typeParameters) {
|
||||
TypeParameterDescriptorImpl substituted = substitutedMap.get(descriptor);
|
||||
for (JetType upperBound : descriptor.getUpperBounds()) {
|
||||
substituted.getUpperBounds().add(substitutor.substitute(upperBound, Variance.INVARIANT));
|
||||
}
|
||||
|
||||
result.add(substituted);
|
||||
}
|
||||
|
||||
return substitutor;
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ fun foo<V : U, U>(<!UNUSED_PARAMETER!>v<!>: V, u: U) = u
|
||||
fun bar<U, V : U>(<!UNUSED_PARAMETER!>v<!>: V, u: U) = u
|
||||
|
||||
fun test(a: Any, s: String) {
|
||||
val <!UNUSED_VARIABLE!>b<!>: Any = <!TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>foo<!>(a, s) //depends on type parameter order, will be fixed in next commit
|
||||
val <!UNUSED_VARIABLE!>b<!>: Any = foo(a, s)
|
||||
val <!UNUSED_VARIABLE!>c<!>: Any = bar(a, s)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user