diff --git a/idea/src/org/jetbrains/jet/plugin/quickfix/CreateMethodFromUsageFix.java b/idea/src/org/jetbrains/jet/plugin/quickfix/CreateMethodFromUsageFix.java index 9e05f4fc930..61083bad78d 100644 --- a/idea/src/org/jetbrains/jet/plugin/quickfix/CreateMethodFromUsageFix.java +++ b/idea/src/org/jetbrains/jet/plugin/quickfix/CreateMethodFromUsageFix.java @@ -174,8 +174,8 @@ public class CreateMethodFromUsageFix extends CreateFromUsageFixBase { } @NotNull - private Collection getPossibleTypes(BindingContext context) { - Collection types = new ArrayList(); + private List getPossibleTypes(BindingContext context) { + List types = new ArrayList(); if (isType()) { assert type != null : "!isType() means type == null && expressionOfType != null"; types.add(type); @@ -208,7 +208,8 @@ public class CreateMethodFromUsageFix extends CreateFromUsageFixBase { @NotNull TypeSubstitution[] substitutions, @NotNull JetScope scope ) { - Collection types = getPossibleTypes(context); + List types = getPossibleTypes(context); + Collections.reverse(types); // reverse and reverse back later, so that things added below are added at the front Set newTypes = new LinkedHashSet(types); for (TypeSubstitution substitution : substitutions) { // each substitution can be applied or not, so we offer all options @@ -229,13 +230,11 @@ public class CreateMethodFromUsageFix extends CreateFromUsageFixBase { newTypes.add(KotlinBuiltIns.getInstance().getAnyType()); } - types = newTypes; - - typeCandidates = new TypeCandidate[types.size()]; - int i = 0; - for (JetType type : types) { + typeCandidates = new TypeCandidate[newTypes.size()]; + int i = typeCandidates.length - 1; // reverse order (see explanation above) + for (JetType type : newTypes) { typeCandidates[i] = new TypeCandidate(type, scope); - i++; + i--; } }