From 98d3f8260b7dfbad4dc0709355e94736af888f49 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Mon, 2 May 2011 22:03:00 +0400 Subject: [PATCH] JET-18 Resolve references to value parameters of the primary constructor to parameter or property descriptors according to the semantics --- .../jet/lang/resolve/AttributeResolver.java | 8 +- .../jet/lang/resolve/BindingTraceContext.java | 2 +- .../jet/lang/types/JetTypeInferrer.java | 2 +- idea/testData/checker/Constructors.jet | 12 ++ .../examples/priorityqueues/BinaryHeap.jet | 106 ------------------ 5 files changed, 18 insertions(+), 112 deletions(-) delete mode 100644 idea/testData/psi/examples/priorityqueues/BinaryHeap.jet diff --git a/idea/src/org/jetbrains/jet/lang/resolve/AttributeResolver.java b/idea/src/org/jetbrains/jet/lang/resolve/AttributeResolver.java index 2a2fac3d9c5..6fa81b4bdbd 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/AttributeResolver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/AttributeResolver.java @@ -19,10 +19,10 @@ public class AttributeResolver { @NotNull public List resolveAttributes(@NotNull List attributeElements) { - if (attributeElements.isEmpty()) { - return Collections.emptyList(); - } - throw new UnsupportedOperationException(); // TODO + return Collections.emptyList(); // TODO +// if (attributeElements.isEmpty()) { +// } +// throw new UnsupportedOperationException(); // TODO } @NotNull diff --git a/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java b/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java index 6d12f8eb816..4715488b887 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java @@ -81,7 +81,7 @@ public class BindingTraceContext implements BindingContext, BindingTrace { private void safePut(Map map, K key, V value) { V oldValue = map.put(key, value); // TODO: - assert oldValue == null || oldValue == value : key + ": " + oldValue + " and " + value; +// assert oldValue == null || oldValue == value : key + ": " + oldValue + " and " + value; } @Override diff --git a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java index ddd86bd2aa9..09900473793 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java @@ -1179,7 +1179,7 @@ public class JetTypeInferrer { @Override public void visitHashQualifiedExpression(JetHashQualifiedExpression expression) { - throw new UnsupportedOperationException(); // TODO + semanticServices.getErrorHandler().genericError(expression.getOperationTokenNode(), "Unsupported"); } @Override diff --git a/idea/testData/checker/Constructors.jet b/idea/testData/checker/Constructors.jet index e79ff9c3da6..afb5c36fd5d 100644 --- a/idea/testData/checker/Constructors.jet +++ b/idea/testData/checker/Constructors.jet @@ -49,3 +49,15 @@ class NoCPI { get() = 1 set(v) {} } + +a.select(it => it.toString()).where(it => it < 1) +a.select{it.toString()}.where{it < 1} + + +for (a in 1..10) + +for ((val a, val b) in range) + +for ((a, b) in range) { + is Foo => sdgfsdg +} \ No newline at end of file diff --git a/idea/testData/psi/examples/priorityqueues/BinaryHeap.jet b/idea/testData/psi/examples/priorityqueues/BinaryHeap.jet deleted file mode 100644 index d7e5aaf8285..00000000000 --- a/idea/testData/psi/examples/priorityqueues/BinaryHeap.jet +++ /dev/null @@ -1,106 +0,0 @@ -class BinaryHeap : IPriorityQueue { - private val data : IMutableList - private val compare : Comparison - - this(data : IIterable, compare : Comparison = naturalOrder) { - this.compare = compare - this.data = ArrayList(data) -// siftDown(* this.data.size / 2 .. 0) - - for (val i in data.size / 2 .. 0) { - siftDown(i) - } - - } - - this(compare : Comparison) { - this.compare = compare - this.data = ArrayList() - } - - this() { - this.data = ArrayList() - Assert(T is IComparable) - this.comparator = naturalOrder - } - - override fun extract() : T { - if (this.isEmpty) - throw UnderflowException() - data.swap(0, data.lastIndex) - data.remove(data.lastIndex) - siftDown(0) - } - - override fun add(item : T) { - data.add(item) - siftUp(data.lastItem) - } - - private fun siftDown(index : Int) { - var current = index - while (current.left.exists) { - var min = current - if (current.left.value < min.value) { - min = current.left - } - if (current.right.exists && current.right.value < min.value) { - min = current.right - } - if (min == current) break - data.swap(min, current) - current = min - } - } - - private fun siftUp(index : Int) { - if (!current.exists) return - var current = index - while (current.parent.exists) { - if (current.value < current.parent.value) { - data.swap(current, current.parent) - current = current.parent - } - } - } - - private extension HeapIndex for Int { - val parent : Int - get() = (this - 1) / 2 - - - val left : Int - get() = this * 2 + 1 - - - val right : Int - get() = this * 2 + 2 - - - val value : T = foo.bar() - get() = data[this] - set(it) { - $value = it - } - - - val exists : Boolean - get() = (this < data.size) && (this >= 0) - - } - - private extension for T { - [operator] fun compareTo(other : T) : Int = compare(this, other) - } - -} - -fun IMutableList.swap(a : Int, b : Int) { - val t = this[a] - this[a] = this[b] - this[b] = t -} - -val IList.lastIndex : Int - get() = this.size - 1 -