diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo.java index 87c6ec23856..74ae0ee5a64 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo.java @@ -201,213 +201,4 @@ public class DataFlowInfo { return !typeInfo.isEmpty(); } -} - -//public class DataFlowInfo { -// -// public static abstract class CompositionOperator { -// -// public abstract DataFlowInfo compose(DataFlowInfo a, DataFlowInfo b); -// } -// public static final CompositionOperator AND = new CompositionOperator() { -// @Override -// public DataFlowInfo compose(DataFlowInfo a, DataFlowInfo b) { -// return a.and(b); -// } -// }; -// -// public static final CompositionOperator OR = new CompositionOperator() { -// @Override -// public DataFlowInfo compose(DataFlowInfo a, DataFlowInfo b) { -// return a.or(b); -// } -// }; -// -// private static DataFlowInfo EMPTY = new DataFlowInfo(ImmutableMap.of(), Multimaps.newListMultimap(Collections.>emptyMap(), CommonSuppliers.getArrayListSupplier())); -// -// public static DataFlowInfo getEmpty() { -// return EMPTY; -// } -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// private final ImmutableMap nullabilityInfo; -// -// private final ListMultimap typeInfo; -// -// private DataFlowInfo(ImmutableMap nullabilityInfo, ListMultimap typeInfo) { -// this.nullabilityInfo = nullabilityInfo; -// this.typeInfo = typeInfo; -// } -// -// @Nullable -// public JetType getType(@NotNull VariableDescriptor variableDescriptor) { -// JetType outType = variableDescriptor.getType(); -// if (outType == null) return null; -// if (!outType.isNullable()) return outType; -// NullabilityFlags nullabilityFlags = nullabilityInfo.get(variableDescriptor); -// if (nullabilityFlags != null && !nullabilityFlags.canBeNull()) { -// return TypeUtils.makeNotNullable(outType); -// } -// return outType; -// } -// -// @NotNull -// private List getPossibleTypes(Object key, @NotNull JetType originalType) { -// List types = typeInfo.get(key); -// NullabilityFlags nullabilityFlags = nullabilityInfo.get(key); -// if (nullabilityFlags == null || nullabilityFlags.canBeNull()) { -// return types; -// } -// List enrichedTypes = Lists.newArrayListWithCapacity(types.size()); -// if (originalType.isNullable()) { -// enrichedTypes.add(TypeUtils.makeNotNullable(originalType)); -// } -// for (JetType type: types) { -// if (type.isNullable()) { -// enrichedTypes.add(TypeUtils.makeNotNullable(type)); -// } -// else { -// enrichedTypes.add(type); -// } -// } -// return enrichedTypes; -// } -// -// @NotNull -// public List getPossibleTypesForVariable(@NotNull VariableDescriptor variableDescriptor) { -// return getPossibleTypes(variableDescriptor, variableDescriptor.getType()); -// } -// -// public List getPossibleTypesForReceiver(@NotNull ReceiverDescriptor receiver) { -// return getPossibleTypes(receiver, receiver.getType()); -// } -// -// public DataFlowInfo establishEqualityToNull(@NotNull VariableDescriptor variableDescriptor, boolean notNull) { -// return new DataFlowInfo(getEqualsToNullMap(variableDescriptor, notNull), typeInfo); -// } -// -// private ImmutableMap getEqualsToNullMap(VariableDescriptor variableDescriptor, boolean notNull) { -// Map builder = Maps.newHashMap(nullabilityInfo); -// NullabilityFlags nullabilityFlags = nullabilityInfo.get(variableDescriptor); -// boolean varNotNull = notNull || (nullabilityFlags != null && !nullabilityFlags.canBeNull); -// builder.put(variableDescriptor, new NullabilityFlags(!varNotNull, varNotNull)); -// return ImmutableMap.copyOf(builder); -// } -// -// private ImmutableMap getEqualsToNullMap(VariableDescriptor[] variableDescriptors, boolean notNull) { -// if (variableDescriptors.length == 0) return nullabilityInfo; -// Map builder = Maps.newHashMap(nullabilityInfo); -// for (VariableDescriptor variableDescriptor : variableDescriptors) { -// if (variableDescriptor != null) { -// NullabilityFlags nullabilityFlags = nullabilityInfo.get(variableDescriptor); -// boolean varNotNull = notNull || (nullabilityFlags != null && !nullabilityFlags.canBeNull); -// builder.put(variableDescriptor, new NullabilityFlags(!varNotNull, varNotNull)); -// } -// } -// return ImmutableMap.copyOf(builder); -// } -// -// public DataFlowInfo isInstanceOf(@NotNull VariableDescriptor variableDescriptor, @NotNull JetType type) { -// ListMultimap newTypeInfo = copyTypeInfo(); -// newTypeInfo.put(variableDescriptor, type); -// return new DataFlowInfo(getEqualsToNullMap(variableDescriptor, !type.isNullable()), newTypeInfo); -// } -// -// public DataFlowInfo isInstanceOf(@NotNull VariableDescriptor[] variableDescriptors, @NotNull JetType type) { -// if (variableDescriptors.length == 0) return this; -// ListMultimap newTypeInfo = copyTypeInfo(); -// for (VariableDescriptor variableDescriptor : variableDescriptors) { -// if (variableDescriptor != null) { -// newTypeInfo.put(variableDescriptor, type); -// } -// } -// return new DataFlowInfo(getEqualsToNullMap(variableDescriptors, !type.isNullable()), newTypeInfo); -// } -// -// public DataFlowInfo and(DataFlowInfo other) { -// Map nullabilityMapBuilder = Maps.newHashMap(); -// nullabilityMapBuilder.putAll(nullabilityInfo); -// for (Map.Entry entry : other.nullabilityInfo.entrySet()) { -// Object key = entry.getKey(); -// NullabilityFlags otherFlags = entry.getValue(); -// NullabilityFlags thisFlags = nullabilityInfo.get(key); -// if (thisFlags != null) { -// nullabilityMapBuilder.put(key, thisFlags.and(otherFlags)); -// } -// else { -// nullabilityMapBuilder.put(key, otherFlags); -// } -// } -// -// ListMultimap newTypeInfo = copyTypeInfo(); -// newTypeInfo.putAll(other.typeInfo); -// return new DataFlowInfo(ImmutableMap.copyOf(nullabilityMapBuilder), newTypeInfo); -// } -// -// private ListMultimap copyTypeInfo() { -// ListMultimap newTypeInfo = Multimaps.newListMultimap(Maps.>newHashMap(), CommonSuppliers.getArrayListSupplier()); -// newTypeInfo.putAll(typeInfo); -// return newTypeInfo; -// } -// -// public DataFlowInfo or(DataFlowInfo other) { -// Map builder = Maps.newHashMap(nullabilityInfo); -// builder.keySet().retainAll(other.nullabilityInfo.keySet()); -// for (Map.Entry entry : builder.entrySet()) { -// Object key = entry.getKey(); -// NullabilityFlags thisFlags = entry.getValue(); -// NullabilityFlags otherFlags = other.nullabilityInfo.get(key); -// assert (otherFlags != null); -// builder.put(key, thisFlags.or(otherFlags)); -// } -// -// ListMultimap newTypeInfo = Multimaps.newListMultimap(Maps.>newHashMap(), CommonSuppliers.getArrayListSupplier()); -// -// Set keys = newTypeInfo.keySet(); -// keys.retainAll(other.typeInfo.keySet()); -// -// for (Object key : keys) { -// Collection thisTypes = typeInfo.get(key); -// Collection otherTypes = other.typeInfo.get(key); -// -// Collection newTypes = Sets.newHashSet(thisTypes); -// newTypes.retainAll(otherTypes); -// -// newTypeInfo.putAll(key, newTypes); -// } -// -// return new DataFlowInfo(ImmutableMap.copyOf(builder), newTypeInfo); -// } -// -// public DataFlowInfo nullabilityOnly() { -// return new DataFlowInfo(nullabilityInfo, EMPTY.copyTypeInfo()); -// } -// -// private static class NullabilityFlags { -// private final boolean canBeNull; -// private final boolean canBeNonNull; -// -// private NullabilityFlags(boolean canBeNull, boolean canBeNonNull) { -// this.canBeNull = canBeNull; -// this.canBeNonNull = canBeNonNull; -// } -// -// public boolean canBeNull() { -// return canBeNull; -// } -// -// public boolean canBeNonNull() { -// return canBeNonNull; -// } -// -// public NullabilityFlags and(NullabilityFlags other) { -// return new NullabilityFlags(this.canBeNull && other.canBeNull, this.canBeNonNull && other.canBeNonNull); -// } -// -// public NullabilityFlags or(NullabilityFlags other) { -// return new NullabilityFlags(this.canBeNull || other.canBeNull, this.canBeNonNull || other.canBeNonNull); -// } -// -// } -//} +} \ No newline at end of file