From 3f4f0c8737eb0921fb24539e71fc90d996791aef Mon Sep 17 00:00:00 2001 From: svtk Date: Mon, 22 Aug 2011 19:12:22 +0400 Subject: [PATCH] bug with incorrect merge of data flow info (KT-104) fixed --- .../jetbrains/jet/lang/types/DataFlowInfo.java | 2 +- idea/testData/checker/infos/Autocasts.jet | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/idea/src/org/jetbrains/jet/lang/types/DataFlowInfo.java b/idea/src/org/jetbrains/jet/lang/types/DataFlowInfo.java index 43df5303f56..0e38372f48d 100644 --- a/idea/src/org/jetbrains/jet/lang/types/DataFlowInfo.java +++ b/idea/src/org/jetbrains/jet/lang/types/DataFlowInfo.java @@ -163,7 +163,7 @@ public class DataFlowInfo { builder.put(variableDescriptor, thisFlags.or(otherFlags)); } - ListMultimap newTypeInfo = copyTypeInfo(); + ListMultimap newTypeInfo = Multimaps.newListMultimap(Maps.>newHashMap(), ARRAY_LIST_SUPPLIER); Set keys = newTypeInfo.keySet(); keys.retainAll(other.typeInfo.keySet()); diff --git a/idea/testData/checker/infos/Autocasts.jet b/idea/testData/checker/infos/Autocasts.jet index 48ef4191b47..caf2ce8bcbf 100644 --- a/idea/testData/checker/infos/Autocasts.jet +++ b/idea/testData/checker/infos/Autocasts.jet @@ -215,4 +215,20 @@ fun returnFunctionLiteral(a: Any?): Function0 = fun illegalTupleReturnType(a: Any): (Any, String) = (a, a) -fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is String, *) => a; else => "something" } \ No newline at end of file +fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is String, *) => a; else => "something" } + +fun mergeAutocasts(a: Any?) { + if (a is String || a is Int) { + a.compareTo("") + a.toString() + } + if (a is Int || a is String) { + a.compareTo("") + } + when (a) { + is String, is Any => a.compareTo("") + } + if (a is String && a is Any) { + val i: Int = a.length + } +} \ No newline at end of file