Test for infix resolve
This commit is contained in:
@@ -10,6 +10,7 @@ import org.jetbrains.jet.lang.types.*;
|
||||
public interface BindingContext {
|
||||
NamespaceDescriptor getNamespaceDescriptor(JetNamespace declaration);
|
||||
ClassDescriptor getClassDescriptor(JetClass declaration);
|
||||
TypeParameterDescriptor getTypeParameterDescriptor(JetTypeParameter declaration);
|
||||
FunctionDescriptor getFunctionDescriptor(JetFunction declaration);
|
||||
PropertyDescriptor getPropertyDescriptor(JetProperty declaration);
|
||||
|
||||
|
||||
@@ -57,6 +57,11 @@ public class BindingTraceContext extends BindingTrace implements BindingContext
|
||||
return (ClassDescriptor) declarationsToDescriptors.get(declaration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeParameterDescriptor getTypeParameterDescriptor(JetTypeParameter declaration) {
|
||||
return (TypeParameterDescriptor) declarationsToDescriptors.get(declaration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FunctionDescriptor getFunctionDescriptor(JetFunction declaration) {
|
||||
return (FunctionDescriptor) declarationsToDescriptors.get(declaration);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
~X~class X<~T~T> {
|
||||
fun foo(a : `T`T) : `X`X<`T`T>{}
|
||||
~plus~fun plus(t : `T`T) : Int {}
|
||||
}
|
||||
|
||||
~t~fun <~t.T~T> t(~t.t~t : `t.T`T) : `t.T`T {
|
||||
`t`t<Int>(1)`:std::Int`
|
||||
`t`t<`t.T`T>(`t.t`t)`:t.T`
|
||||
new `X`X<`t.T`T>()
|
||||
1 `std::Int.plus(Int)`+ 1
|
||||
new X<String>() `plus`+ "1"
|
||||
new X<String>() `plus`plus "sadfas"
|
||||
new X<String>().`plus`plus("")
|
||||
}
|
||||
@@ -166,8 +166,18 @@ public class ExpectedResolveData {
|
||||
assertNotNull(declarationPosition);
|
||||
JetDeclaration declaration = getAncestorOfType(JetDeclaration.class, declElement);
|
||||
assertNotNull(declaration);
|
||||
ClassDescriptor classDescriptor = bindingContext.getClassDescriptor((JetClass) declaration);
|
||||
expectedTypeConstructor = classDescriptor.getTypeConstructor();
|
||||
if (declaration instanceof JetClass) {
|
||||
ClassDescriptor classDescriptor = bindingContext.getClassDescriptor((JetClass) declaration);
|
||||
expectedTypeConstructor = classDescriptor.getTypeConstructor();
|
||||
}
|
||||
else if (declaration instanceof JetTypeParameter) {
|
||||
TypeParameterDescriptor typeParameterDescriptor = bindingContext.getTypeParameterDescriptor((JetTypeParameter) declaration);
|
||||
expectedTypeConstructor = typeParameterDescriptor.getTypeConstructor();
|
||||
}
|
||||
else {
|
||||
fail("Unsupported declaration: " + declaration);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
assertSame("At " + position + ": ", expectedTypeConstructor, expressionType.getConstructor());
|
||||
|
||||
@@ -126,4 +126,8 @@ public class JetResolveTest extends ExtensibleResolveTestCase {
|
||||
doTest("/resolve/ResolveToJava.jet", true, true);
|
||||
}
|
||||
|
||||
public void testResolveOfInfixExpressions() throws Exception {
|
||||
doTest("/resolve/ResolveOfInfixExpressions.jet", true, true);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user