JET-61 Support class objects

JET-83 Interpret Java static methods as class objects' members
This commit is contained in:
Andrey Breslav
2011-06-03 19:03:33 +04:00
parent 4884af389f
commit 7e2e46ec71
8 changed files with 443 additions and 425 deletions
@@ -6,6 +6,7 @@ import org.jetbrains.jet.lang.resolve.JetScope;
import org.jetbrains.jet.lang.resolve.SubstitutingScope; import org.jetbrains.jet.lang.resolve.SubstitutingScope;
import org.jetbrains.jet.lang.types.*; import org.jetbrains.jet.lang.types.*;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -16,6 +17,7 @@ public class JavaClassDescriptor extends MutableDeclarationDescriptor implements
private TypeConstructor typeConstructor; private TypeConstructor typeConstructor;
private JavaClassMembersScope unsubstitutedMemberScope; private JavaClassMembersScope unsubstitutedMemberScope;
private JetType classObjectType;
private final WritableFunctionGroup constructors = new WritableFunctionGroup("<init>"); private final WritableFunctionGroup constructors = new WritableFunctionGroup("<init>");
public JavaClassDescriptor(DeclarationDescriptor containingDeclaration) { public JavaClassDescriptor(DeclarationDescriptor containingDeclaration) {
@@ -30,6 +32,20 @@ public class JavaClassDescriptor extends MutableDeclarationDescriptor implements
this.unsubstitutedMemberScope = memberScope; this.unsubstitutedMemberScope = memberScope;
} }
public void setClassObjectMemberScope(JavaClassMembersScope memberScope) {
classObjectType = new JetTypeImpl(
new TypeConstructorImpl(
JavaDescriptorResolver.JAVA_CLASS_OBJECT,
Collections.<Annotation>emptyList(),
true,
"Class object emulation for " + getName(),
Collections.<TypeParameterDescriptor>emptyList(),
Collections.<JetType>emptyList()
),
memberScope
);
}
public void addConstructor(ConstructorDescriptor constructorDescriptor) { public void addConstructor(ConstructorDescriptor constructorDescriptor) {
this.constructors.addFunction(constructorDescriptor); this.constructors.addFunction(constructorDescriptor);
} }
@@ -89,7 +105,7 @@ public class JavaClassDescriptor extends MutableDeclarationDescriptor implements
@Override @Override
public JetType getClassObjectType() { public JetType getClassObjectType() {
return null; // TODO : static members as class object members return classObjectType;
} }
@Override @Override
@@ -30,6 +30,19 @@ public class JavaDescriptorResolver {
} }
}; };
/*package*/ static final DeclarationDescriptor JAVA_CLASS_OBJECT = new DeclarationDescriptorImpl(null, Collections.<Annotation>emptyList(), "<java_class_object_emulation>") {
@NotNull
@Override
public DeclarationDescriptor substitute(TypeSubstitutor substitutor) {
throw new UnsupportedOperationException(); // TODO
}
@Override
public <R, D> R accept(DeclarationDescriptorVisitor<R, D> visitor, D data) {
return visitor.visitDeclarationDescriptor(this, data);
}
};
protected final Map<String, ClassDescriptor> classDescriptorCache = new HashMap<String, ClassDescriptor>(); protected final Map<String, ClassDescriptor> classDescriptorCache = new HashMap<String, ClassDescriptor>();
protected final Map<PsiTypeParameter, TypeParameterDescriptor> typeParameterDescriptorCache = Maps.newHashMap(); protected final Map<PsiTypeParameter, TypeParameterDescriptor> typeParameterDescriptorCache = Maps.newHashMap();
protected final Map<PsiMethod, FunctionDescriptor> methodDescriptorCache = Maps.newHashMap(); protected final Map<PsiMethod, FunctionDescriptor> methodDescriptorCache = Maps.newHashMap();
@@ -91,6 +104,7 @@ public class JavaDescriptorResolver {
)); ));
classDescriptorCache.put(psiClass.getQualifiedName(), classDescriptor); classDescriptorCache.put(psiClass.getQualifiedName(), classDescriptor);
classDescriptor.setUnsubstitutedMemberScope(new JavaClassMembersScope(classDescriptor, psiClass, semanticServices, false)); classDescriptor.setUnsubstitutedMemberScope(new JavaClassMembersScope(classDescriptor, psiClass, semanticServices, false));
classDescriptor.setClassObjectMemberScope(new JavaClassMembersScope(classDescriptor, psiClass, semanticServices, true));
// UGLY HACK // UGLY HACK
supertypes.addAll(getSupertypes(psiClass)); supertypes.addAll(getSupertypes(psiClass));
@@ -713,7 +713,7 @@ public class JetTypeInferrer {
result = classObjectType; result = classObjectType;
} }
else { else {
trace.getErrorHandler().genericError(expression.getNode(), "This class does not have a class object"); trace.getErrorHandler().genericError(expression.getNode(), "Classifier " + classifier.getName() + " does not have a class object");
} }
trace.recordReferenceResolution(expression, classifier); trace.recordReferenceResolution(expression, classifier);
return; return;
+275 -285
View File
@@ -171,14 +171,13 @@ JetFile: SimpleClassMembers.jet
CLASS_OBJECT CLASS_OBJECT
PsiElement(class)('class') PsiElement(class)('class')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
OBJECT_LITERAL OBJECT_DECLARATION
OBJECT_DECLARATION PsiElement(object)('object')
PsiElement(object)('object') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') CLASS_BODY
CLASS_BODY PsiElement(LBRACE)('{')
PsiElement(LBRACE)('{') PsiWhiteSpace('\n\n ')
PsiWhiteSpace('\n\n ') PsiElement(RBRACE)('}')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ') PsiWhiteSpace('\n\n ')
CLASS_OBJECT CLASS_OBJECT
MODIFIER_LIST MODIFIER_LIST
@@ -186,14 +185,13 @@ JetFile: SimpleClassMembers.jet
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(class)('class') PsiElement(class)('class')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
OBJECT_LITERAL OBJECT_DECLARATION
OBJECT_DECLARATION PsiElement(object)('object')
PsiElement(object)('object') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') CLASS_BODY
CLASS_BODY PsiElement(LBRACE)('{')
PsiElement(LBRACE)('{') PsiWhiteSpace('\n\n ')
PsiWhiteSpace('\n\n ') PsiElement(RBRACE)('}')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ') PsiWhiteSpace('\n\n ')
CLASS_OBJECT CLASS_OBJECT
MODIFIER_LIST MODIFIER_LIST
@@ -201,23 +199,22 @@ JetFile: SimpleClassMembers.jet
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(class)('class') PsiElement(class)('class')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
OBJECT_LITERAL OBJECT_DECLARATION
OBJECT_DECLARATION PsiElement(object)('object')
PsiElement(object)('object') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') PsiElement(COLON)(':')
PsiElement(COLON)(':') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') DELEGATION_SPECIFIER_LIST
DELEGATION_SPECIFIER_LIST DELEGATOR_SUPER_CLASS
DELEGATOR_SUPER_CLASS TYPE_REFERENCE
TYPE_REFERENCE USER_TYPE
USER_TYPE REFERENCE_EXPRESSION
REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Fooo')
PsiElement(IDENTIFIER)('Fooo') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') CLASS_BODY
CLASS_BODY PsiElement(LBRACE)('{')
PsiElement(LBRACE)('{') PsiWhiteSpace('\n\n ')
PsiWhiteSpace('\n\n ') PsiElement(RBRACE)('}')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ') PsiWhiteSpace('\n\n ')
CLASS_OBJECT CLASS_OBJECT
MODIFIER_LIST MODIFIER_LIST
@@ -225,35 +222,34 @@ JetFile: SimpleClassMembers.jet
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(class)('class') PsiElement(class)('class')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
OBJECT_LITERAL OBJECT_DECLARATION
OBJECT_DECLARATION PsiElement(object)('object')
PsiElement(object)('object') PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
DELEGATION_SPECIFIER_LIST
DELEGATOR_SUPER_CLASS
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Fooo')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(COLON)(':') DELEGATOR_BY
PsiWhiteSpace(' ') TYPE_REFERENCE
DELEGATION_SPECIFIER_LIST USER_TYPE
DELEGATOR_SUPER_CLASS REFERENCE_EXPRESSION
TYPE_REFERENCE PsiElement(IDENTIFIER)('Bar')
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Fooo')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
DELEGATOR_BY PsiElement(by)('by')
TYPE_REFERENCE PsiWhiteSpace(' ')
USER_TYPE REFERENCE_EXPRESSION
REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo')
PsiElement(IDENTIFIER)('Bar') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') CLASS_BODY
PsiElement(by)('by') PsiElement(LBRACE)('{')
PsiWhiteSpace(' ') PsiWhiteSpace('\n\n ')
REFERENCE_EXPRESSION PsiElement(RBRACE)('}')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
CLASS_BODY
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ') PsiWhiteSpace('\n\n ')
CLASS_OBJECT CLASS_OBJECT
MODIFIER_LIST MODIFIER_LIST
@@ -261,139 +257,138 @@ JetFile: SimpleClassMembers.jet
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(class)('class') PsiElement(class)('class')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
OBJECT_LITERAL OBJECT_DECLARATION
OBJECT_DECLARATION PsiElement(object)('object')
PsiElement(object)('object') PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
DELEGATION_SPECIFIER_LIST
DELEGATOR_SUPER_CLASS
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Fooo')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(COLON)(':') DELEGATOR_BY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Bar')
PsiWhiteSpace(' ')
PsiElement(by)('by')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
DELEGATION_SPECIFIER_LIST DELEGATOR_SUPER_CALL
DELEGATOR_SUPER_CLASS TYPE_REFERENCE
TYPE_REFERENCE USER_TYPE
USER_TYPE REFERENCE_EXPRESSION
REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Goo')
PsiElement(IDENTIFIER)('Fooo') VALUE_ARGUMENT_LIST
PsiElement(COMMA)(',') PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n ')
CLASS_BODY
PsiErrorElement:Expecting a class body
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
DELEGATOR_BY PsiElement(IDENTIFIER)('Bar')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Bar')
PsiWhiteSpace(' ')
PsiElement(by)('by')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
DELEGATOR_SUPER_CALL TYPE_PARAMETER_LIST
TYPE_REFERENCE <empty list>
USER_TYPE CLASS_BODY
REFERENCE_EXPRESSION PsiElement(LBRACE)('{')
PsiElement(IDENTIFIER)('Goo')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n ')
CLASS_BODY
PsiErrorElement:Expecting a class body
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ') PsiWhiteSpace('\n\n ')
CLASS FUN
PsiElement(class)('class') PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('x')
PsiWhiteSpace('\n\n ')
PROPERTY
PsiElement(var)('var')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f')
PsiWhiteSpace('\n\n ')
TYPEDEF
PsiElement(type)('type')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
TYPE_PARAMETER_LIST
<empty list>
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace('\n\n ')
CONSTRUCTOR
PsiElement(this)('this')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
INITIALIZER_LIST
THIS_CALL
THIS_CONSTRUCTOR_REFERENCE
PsiElement(this)('this')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
VALUE_ARGUMENT
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
VALUE_ARGUMENT
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('c')
PsiElement(RPAR)(')')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('Bar') DELEGATOR_SUPER_CALL
PsiWhiteSpace(' ') TYPE_REFERENCE
TYPE_PARAMETER_LIST USER_TYPE
<empty list> REFERENCE_EXPRESSION
CLASS_BODY PsiElement(IDENTIFIER)('Foo')
PsiElement(LBRACE)('{') TYPE_ARGUMENT_LIST
PsiElement(RBRACE)('}') PsiElement(LT)('<')
PsiWhiteSpace('\n\n ') TYPE_PROJECTION
FUN TYPE_REFERENCE
PsiElement(fun)('fun') USER_TYPE
PsiWhiteSpace(' ') REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo') PsiElement(IDENTIFIER)('T')
VALUE_PARAMETER_LIST PsiElement(GT)('>')
PsiElement(LPAR)('(') VALUE_ARGUMENT_LIST
PsiElement(RPAR)(')') PsiElement(LPAR)('(')
PsiWhiteSpace('\n\n ') VALUE_ARGUMENT
PROPERTY REFERENCE_EXPRESSION
PsiElement(val)('val') PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace(' ') PsiElement(RPAR)(')')
PsiElement(IDENTIFIER)('x') PsiWhiteSpace('\n ')
PsiWhiteSpace('\n\n ') PsiElement(RBRACE)('}')
PROPERTY
PsiElement(var)('var')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f')
PsiWhiteSpace('\n\n ')
TYPEDEF
PsiElement(type)('type')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
TYPE_PARAMETER_LIST
<empty list>
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace('\n\n ')
CONSTRUCTOR
PsiElement(this)('this')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
INITIALIZER_LIST
THIS_CALL
THIS_CONSTRUCTOR_REFERENCE
PsiElement(this)('this')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
VALUE_ARGUMENT
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
VALUE_ARGUMENT
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('c')
PsiElement(RPAR)(')')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
DELEGATOR_SUPER_CALL
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Foo')
TYPE_ARGUMENT_LIST
PsiElement(LT)('<')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ') PsiWhiteSpace('\n\n ')
FUN FUN
PsiElement(fun)('fun') PsiElement(fun)('fun')
@@ -535,14 +530,13 @@ JetFile: SimpleClassMembers.jet
CLASS_OBJECT CLASS_OBJECT
PsiElement(class)('class') PsiElement(class)('class')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
OBJECT_LITERAL OBJECT_DECLARATION
OBJECT_DECLARATION PsiElement(object)('object')
PsiElement(object)('object') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') CLASS_BODY
CLASS_BODY PsiElement(LBRACE)('{')
PsiElement(LBRACE)('{') PsiWhiteSpace('\n\n ')
PsiWhiteSpace('\n\n ') PsiElement(RBRACE)('}')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ') PsiWhiteSpace('\n\n ')
CLASS_OBJECT CLASS_OBJECT
MODIFIER_LIST MODIFIER_LIST
@@ -550,14 +544,13 @@ JetFile: SimpleClassMembers.jet
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(class)('class') PsiElement(class)('class')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
OBJECT_LITERAL OBJECT_DECLARATION
OBJECT_DECLARATION PsiElement(object)('object')
PsiElement(object)('object') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') CLASS_BODY
CLASS_BODY PsiElement(LBRACE)('{')
PsiElement(LBRACE)('{') PsiWhiteSpace('\n\n ')
PsiWhiteSpace('\n\n ') PsiElement(RBRACE)('}')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ') PsiWhiteSpace('\n\n ')
CLASS_OBJECT CLASS_OBJECT
MODIFIER_LIST MODIFIER_LIST
@@ -565,23 +558,22 @@ JetFile: SimpleClassMembers.jet
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(class)('class') PsiElement(class)('class')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
OBJECT_LITERAL OBJECT_DECLARATION
OBJECT_DECLARATION PsiElement(object)('object')
PsiElement(object)('object') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') PsiElement(COLON)(':')
PsiElement(COLON)(':') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') DELEGATION_SPECIFIER_LIST
DELEGATION_SPECIFIER_LIST DELEGATOR_SUPER_CLASS
DELEGATOR_SUPER_CLASS TYPE_REFERENCE
TYPE_REFERENCE USER_TYPE
USER_TYPE REFERENCE_EXPRESSION
REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Fooo')
PsiElement(IDENTIFIER)('Fooo') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') CLASS_BODY
CLASS_BODY PsiElement(LBRACE)('{')
PsiElement(LBRACE)('{') PsiWhiteSpace('\n\n ')
PsiWhiteSpace('\n\n ') PsiElement(RBRACE)('}')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ') PsiWhiteSpace('\n\n ')
CLASS_OBJECT CLASS_OBJECT
MODIFIER_LIST MODIFIER_LIST
@@ -589,35 +581,34 @@ JetFile: SimpleClassMembers.jet
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(class)('class') PsiElement(class)('class')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
OBJECT_LITERAL OBJECT_DECLARATION
OBJECT_DECLARATION PsiElement(object)('object')
PsiElement(object)('object') PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
DELEGATION_SPECIFIER_LIST
DELEGATOR_SUPER_CLASS
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Fooo')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(COLON)(':') DELEGATOR_BY
PsiWhiteSpace(' ') TYPE_REFERENCE
DELEGATION_SPECIFIER_LIST USER_TYPE
DELEGATOR_SUPER_CLASS REFERENCE_EXPRESSION
TYPE_REFERENCE PsiElement(IDENTIFIER)('Bar')
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Fooo')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
DELEGATOR_BY PsiElement(by)('by')
TYPE_REFERENCE PsiWhiteSpace(' ')
USER_TYPE REFERENCE_EXPRESSION
REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo')
PsiElement(IDENTIFIER)('Bar') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') CLASS_BODY
PsiElement(by)('by') PsiElement(LBRACE)('{')
PsiWhiteSpace(' ') PsiWhiteSpace('\n\n ')
REFERENCE_EXPRESSION PsiElement(RBRACE)('}')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
CLASS_BODY
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ') PsiWhiteSpace('\n\n ')
CLASS_OBJECT CLASS_OBJECT
MODIFIER_LIST MODIFIER_LIST
@@ -625,43 +616,42 @@ JetFile: SimpleClassMembers.jet
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(class)('class') PsiElement(class)('class')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
OBJECT_LITERAL OBJECT_DECLARATION
OBJECT_DECLARATION PsiElement(object)('object')
PsiElement(object)('object') PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
DELEGATION_SPECIFIER_LIST
DELEGATOR_SUPER_CLASS
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Fooo')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(COLON)(':') DELEGATOR_BY
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Bar')
PsiWhiteSpace(' ')
PsiElement(by)('by')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
DELEGATION_SPECIFIER_LIST DELEGATOR_SUPER_CALL
DELEGATOR_SUPER_CLASS TYPE_REFERENCE
TYPE_REFERENCE USER_TYPE
USER_TYPE REFERENCE_EXPRESSION
REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Goo')
PsiElement(IDENTIFIER)('Fooo') VALUE_ARGUMENT_LIST
PsiElement(COMMA)(',') PsiElement(LPAR)('(')
PsiWhiteSpace(' ') PsiElement(RPAR)(')')
DELEGATOR_BY PsiWhiteSpace('\n\n\n')
TYPE_REFERENCE CLASS_BODY
USER_TYPE PsiErrorElement:Expecting a class body
REFERENCE_EXPRESSION PsiElement(RBRACE)('}')
PsiElement(IDENTIFIER)('Bar') PsiErrorElement:Missing '}
PsiWhiteSpace(' ') <empty list>
PsiElement(by)('by')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
DELEGATOR_SUPER_CALL
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Goo')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n\n')
CLASS_BODY
PsiErrorElement:Expecting a class body
PsiElement(RBRACE)('}')
PsiErrorElement:Missing '}
<empty list>
@@ -134,65 +134,64 @@ JetFile: PolymorphicClassObjects.jet
CLASS_OBJECT CLASS_OBJECT
PsiElement(class)('class') PsiElement(class)('class')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
OBJECT_LITERAL OBJECT_DECLARATION
OBJECT_DECLARATION PsiElement(object)('object')
PsiElement(object)('object') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') PsiElement(COLON)(':')
PsiElement(COLON)(':') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') DELEGATION_SPECIFIER_LIST
DELEGATION_SPECIFIER_LIST DELEGATOR_SUPER_CLASS
DELEGATOR_SUPER_CLASS TYPE_REFERENCE
TYPE_REFERENCE USER_TYPE
USER_TYPE REFERENCE_EXPRESSION
REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Buildable')
PsiElement(IDENTIFIER)('Buildable') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') CLASS_BODY
CLASS_BODY PsiElement(LBRACE)('{')
PsiElement(LBRACE)('{') PsiWhiteSpace('\n ')
PsiWhiteSpace('\n ') FUN
FUN MODIFIER_LIST
MODIFIER_LIST PsiElement(override)('override')
PsiElement(override)('override') PsiWhiteSpace(' ')
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('newBuilder')
TYPE_PARAMETER_LIST
PsiElement(LT)('<')
TYPE_PARAMETER
PsiElement(IDENTIFIER)('E')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(fun)('fun') TYPE_PARAMETER
PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('R')
PsiElement(IDENTIFIER)('newBuilder') PsiElement(GT)('>')
TYPE_PARAMETER_LIST VALUE_PARAMETER_LIST
PsiElement(LT)('<') PsiElement(LPAR)('(')
TYPE_PARAMETER PsiElement(RPAR)(')')
PsiElement(IDENTIFIER)('E') PsiWhiteSpace(' ')
PsiElement(COMMA)(',') PsiElement(COLON)(':')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
TYPE_PARAMETER TYPE_REFERENCE
PsiElement(IDENTIFIER)('R') USER_TYPE
PsiElement(GT)('>') REFERENCE_EXPRESSION
VALUE_PARAMETER_LIST PsiElement(IDENTIFIER)('Builder')
PsiElement(LPAR)('(') TYPE_ARGUMENT_LIST
PsiElement(RPAR)(')') PsiElement(LT)('<')
PsiWhiteSpace(' ') TYPE_PROJECTION
PsiElement(COLON)(':') TYPE_REFERENCE
PsiWhiteSpace(' ') USER_TYPE
TYPE_REFERENCE REFERENCE_EXPRESSION
USER_TYPE PsiElement(IDENTIFIER)('E')
REFERENCE_EXPRESSION PsiElement(COMMA)(',')
PsiElement(IDENTIFIER)('Builder') PsiWhiteSpace(' ')
TYPE_ARGUMENT_LIST TYPE_PROJECTION
PsiElement(LT)('<') TYPE_REFERENCE
TYPE_PROJECTION USER_TYPE
TYPE_REFERENCE REFERENCE_EXPRESSION
USER_TYPE PsiElement(IDENTIFIER)('R')
REFERENCE_EXPRESSION PsiElement(GT)('>')
PsiElement(IDENTIFIER)('E') PsiWhiteSpace('\n\n ')
PsiElement(COMMA)(',') PsiElement(RBRACE)('}')
PsiWhiteSpace(' ')
TYPE_PROJECTION
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('R')
PsiElement(GT)('>')
PsiWhiteSpace('\n\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n') PsiWhiteSpace('\n\n')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n') PsiWhiteSpace('\n\n')
+77 -78
View File
@@ -36,92 +36,91 @@ JetFile: UpdateOperation.jet
CLASS_OBJECT CLASS_OBJECT
PsiElement(class)('class') PsiElement(class)('class')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
OBJECT_LITERAL OBJECT_DECLARATION
OBJECT_DECLARATION PsiElement(object)('object')
PsiElement(object)('object') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') CLASS_BODY
CLASS_BODY PsiElement(LBRACE)('{')
PsiElement(LBRACE)('{') PsiWhiteSpace('\n ')
PsiWhiteSpace('\n ') FUN
FUN PsiElement(fun)('fun')
PsiElement(fun)('fun') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('copy')
PsiElement(IDENTIFIER)('copy') VALUE_PARAMETER_LIST
VALUE_PARAMETER_LIST PsiElement(LPAR)('(')
PsiElement(LPAR)('(') VALUE_PARAMETER
VALUE_PARAMETER PsiElement(IDENTIFIER)('from')
PsiElement(IDENTIFIER)('from')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Pair')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
VALUE_PARAMETER PsiElement(COLON)(':')
PsiElement(IDENTIFIER)('x')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
DOT_QUALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('from')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('x')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('y')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
DOT_QUALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('from')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('y')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
NEW
PsiElement(new)('new')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
TYPE_REFERENCE TYPE_REFERENCE
USER_TYPE USER_TYPE
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Pair') PsiElement(IDENTIFIER)('Pair')
VALUE_ARGUMENT_LIST PsiElement(COMMA)(',')
PsiElement(LPAR)('(') PsiWhiteSpace(' ')
VALUE_ARGUMENT VALUE_PARAMETER
PsiElement(IDENTIFIER)('x')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('x') PsiElement(IDENTIFIER)('Int')
PsiElement(COMMA)(',') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') PsiElement(EQ)('=')
VALUE_ARGUMENT PsiWhiteSpace(' ')
DOT_QUALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('from')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('x')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('y')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('y') PsiElement(IDENTIFIER)('Int')
PsiElement(RPAR)(')') PsiWhiteSpace(' ')
PsiWhiteSpace('\n ') PsiElement(EQ)('=')
PsiElement(RBRACE)('}') PsiWhiteSpace(' ')
DOT_QUALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('from')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('y')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
NEW
PsiElement(new)('new')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Pair')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('x')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
VALUE_ARGUMENT
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('y')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n') PsiWhiteSpace('\n\n')
@@ -70,7 +70,7 @@ public class ControlStructuresTest extends CodegenTestCase {
} }
public void testCondJumpOnStack() throws Exception { public void testCondJumpOnStack() throws Exception {
loadText("fun foo(a: String): Int = if (Boolean.parseBoolean(a)) 5 else 10"); loadText("fun foo(a: String): Int = if (java.lang.Boolean.parseBoolean(a)) 5 else 10");
final Method main = generateFunction(); final Method main = generateFunction();
assertEquals(5, main.invoke(null, "true")); assertEquals(5, main.invoke(null, "true"));
assertEquals(10, main.invoke(null, "false")); assertEquals(10, main.invoke(null, "false"));
@@ -123,7 +123,7 @@ public class PrimitiveTypesTest extends CodegenTestCase {
} }
public void testDoubleToJava() throws Exception { public void testDoubleToJava() throws Exception {
loadText("fun foo(d: Double): String? = Double.toString(d)"); loadText("fun foo(d: Double): String? = java.lang.Double.toString(d)");
final Method main = generateFunction(); final Method main = generateFunction();
assertEquals("1.0", main.invoke(null, 1.0)); assertEquals("1.0", main.invoke(null, 1.0));
} }