bug with incorrect merge of data flow info (KT-104) fixed

This commit is contained in:
svtk
2011-08-22 19:12:22 +04:00
parent 9ebffafd89
commit 3f4f0c8737
2 changed files with 18 additions and 2 deletions
@@ -163,7 +163,7 @@ public class DataFlowInfo {
builder.put(variableDescriptor, thisFlags.or(otherFlags)); builder.put(variableDescriptor, thisFlags.or(otherFlags));
} }
ListMultimap<VariableDescriptor, JetType> newTypeInfo = copyTypeInfo(); ListMultimap<VariableDescriptor, JetType> newTypeInfo = Multimaps.newListMultimap(Maps.<VariableDescriptor, Collection<JetType>>newHashMap(), ARRAY_LIST_SUPPLIER);
Set<VariableDescriptor> keys = newTypeInfo.keySet(); Set<VariableDescriptor> keys = newTypeInfo.keySet();
keys.retainAll(other.typeInfo.keySet()); keys.retainAll(other.typeInfo.keySet());
+16
View File
@@ -216,3 +216,19 @@ fun returnFunctionLiteral(a: Any?): Function0<Int> =
fun illegalTupleReturnType(a: Any): (Any, String) = (a, <error>a</error>) fun illegalTupleReturnType(a: Any): (Any, String) = (a, <error>a</error>)
fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is String, *) => <info descr="Automatically cast to String">a</info>; else => "something" } fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is String, *) => <info descr="Automatically cast to String">a</info>; else => "something" }
fun mergeAutocasts(a: Any?) {
if (a is String || a is Int) {
a.<error>compareTo</error>("")
a.toString()
}
if (a is Int || a is String) {
a.<error>compareTo</error>("")
}
when (a) {
is String, is Any => a.<error>compareTo</error>("")
}
if (a is String && a is Any) {
val i: Int = <info descr="Automatically cast to String">a</info>.length
}
}