Temporary fix for duplicate key in constructor resolution

This commit is contained in:
Andrey Breslav
2011-04-15 18:54:25 +04:00
parent e74ea049af
commit 3678b343b6
5 changed files with 26 additions and 22 deletions
+10 -10
View File
@@ -1,6 +1,15 @@
namespace jet.lang
class Array<T> {
class Iterator<out T> {
fun next() : T
val hasNext : Boolean
}
class Iterable<out T> {
fun iterator() : Iterator<T>
}
class Array<T> : Iterable<T> {
fun get(index : Int) : T
fun set(index : Int, value : T) : Unit
}
@@ -34,15 +43,6 @@ class Range<in T : Comparable<T>> {
fun contains(item : T) : Boolean
}
class Iterator<out T> {
fun next() : T
val hasNext : Boolean
}
class Iterable<out T> {
fun iterator() : Iterator<T>
}
class IntRange<T> : Range<T>, Iterable<T> {
}
@@ -14,8 +14,6 @@ public interface BindingContext {
FunctionDescriptor getFunctionDescriptor(JetFunction declaration);
PropertyDescriptor getPropertyDescriptor(JetProperty declaration);
DeclarationDescriptor getDeclarationDescriptor(JetDeclaration declaration);
JetType getExpressionType(JetExpression expression);
JetScope getTopLevelScope();
@@ -20,6 +20,7 @@ public class BindingTraceContext extends BindingTrace implements BindingContext
private final Map<JetTypeReference, JetType> types = new HashMap<JetTypeReference, JetType>();
private final Map<DeclarationDescriptor, PsiElement> descriptorToDeclarations = new HashMap<DeclarationDescriptor, PsiElement>();
private final Map<PsiElement, DeclarationDescriptor> declarationsToDescriptors = new HashMap<PsiElement, DeclarationDescriptor>();
private final Map<PsiElement, ConstructorDescriptor> constructorDeclarationsToDescriptors = new HashMap<PsiElement, ConstructorDescriptor>();
private final Set<JetFunctionLiteralExpression> blocks = new HashSet<JetFunctionLiteralExpression>();
private final Set<JetElement> statements = new HashSet<JetElement>();
@@ -54,8 +55,18 @@ public class BindingTraceContext extends BindingTrace implements BindingContext
@Override
public void recordDeclarationResolution(@NotNull PsiElement declaration, @NotNull DeclarationDescriptor descriptor) {
descriptorToDeclarations.put(descriptor.getOriginal(), declaration);
declarationsToDescriptors.put(declaration, descriptor.getOriginal());
safePut(descriptorToDeclarations, descriptor.getOriginal(), declaration);
if (descriptor instanceof ConstructorDescriptor) {
safePut(constructorDeclarationsToDescriptors, declaration, (ConstructorDescriptor) descriptor);
}
else {
safePut(declarationsToDescriptors, declaration, descriptor.getOriginal());
}
}
private <K, V> void safePut(Map<K, V> map, K key, V value) {
V oldValue = map.put(key, value);
// assert oldValue == null || oldValue == value : key + ": " + oldValue + " and " + value;
}
@Override
@@ -75,11 +86,6 @@ public class BindingTraceContext extends BindingTrace implements BindingContext
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Override
public DeclarationDescriptor getDeclarationDescriptor(JetDeclaration declaration) {
return declarationsToDescriptors.get(declaration);
}
public NamespaceDescriptor getNamespaceDescriptor(JetNamespace declaration) {
return (NamespaceDescriptor) declarationsToDescriptors.get(declaration);
}
@@ -44,6 +44,6 @@ public abstract class DeclarationDescriptorImpl extends AnnotatedImpl implements
@Override
public String toString() {
return DescriptorUtil.renderPresentableText(this) + "[" + getClass().getCanonicalName()+ "]";
return DescriptorUtil.renderPresentableText(this) + "[" + getClass().getCanonicalName() + "@" + System.identityHashCode(this) + "]";
}
}
+2 -2
View File
@@ -1,7 +1,7 @@
fun concat(l: Array<String>): String {
fun concat(l: Array<String>): String? {
val sb = new StringBuilder()
for(s in l) {
sb.append(s)
}
s.toString()
sb.toString()
}