From 7e2e46ec7155f5c0f921596dbab17714f29afd20 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Fri, 3 Jun 2011 19:03:33 +0400 Subject: [PATCH] JET-61 Support class objects JET-83 Interpret Java static methods as class objects' members --- .../resolve/java/JavaClassDescriptor.java | 18 +- .../resolve/java/JavaDescriptorResolver.java | 14 + .../jet/lang/types/JetTypeInferrer.java | 2 +- idea/testData/psi/SimpleClassMembers.txt | 560 +++++++++--------- .../psi/examples/PolymorphicClassObjects.txt | 115 ++-- .../testData/psi/examples/UpdateOperation.txt | 155 +++-- .../jet/codegen/ControlStructuresTest.java | 2 +- .../jet/codegen/PrimitiveTypesTest.java | 2 +- 8 files changed, 443 insertions(+), 425 deletions(-) diff --git a/idea/src/org/jetbrains/jet/lang/resolve/java/JavaClassDescriptor.java b/idea/src/org/jetbrains/jet/lang/resolve/java/JavaClassDescriptor.java index 1e7092c3ecb..245216bac1a 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/java/JavaClassDescriptor.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/java/JavaClassDescriptor.java @@ -6,6 +6,7 @@ import org.jetbrains.jet.lang.resolve.JetScope; import org.jetbrains.jet.lang.resolve.SubstitutingScope; import org.jetbrains.jet.lang.types.*; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -16,6 +17,7 @@ public class JavaClassDescriptor extends MutableDeclarationDescriptor implements private TypeConstructor typeConstructor; private JavaClassMembersScope unsubstitutedMemberScope; + private JetType classObjectType; private final WritableFunctionGroup constructors = new WritableFunctionGroup(""); public JavaClassDescriptor(DeclarationDescriptor containingDeclaration) { @@ -30,6 +32,20 @@ public class JavaClassDescriptor extends MutableDeclarationDescriptor implements this.unsubstitutedMemberScope = memberScope; } + public void setClassObjectMemberScope(JavaClassMembersScope memberScope) { + classObjectType = new JetTypeImpl( + new TypeConstructorImpl( + JavaDescriptorResolver.JAVA_CLASS_OBJECT, + Collections.emptyList(), + true, + "Class object emulation for " + getName(), + Collections.emptyList(), + Collections.emptyList() + ), + memberScope + ); + } + public void addConstructor(ConstructorDescriptor constructorDescriptor) { this.constructors.addFunction(constructorDescriptor); } @@ -89,7 +105,7 @@ public class JavaClassDescriptor extends MutableDeclarationDescriptor implements @Override public JetType getClassObjectType() { - return null; // TODO : static members as class object members + return classObjectType; } @Override diff --git a/idea/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java b/idea/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java index e3b6f444be7..63c0ea900ca 100644 --- a/idea/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java +++ b/idea/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java @@ -30,6 +30,19 @@ public class JavaDescriptorResolver { } }; + /*package*/ static final DeclarationDescriptor JAVA_CLASS_OBJECT = new DeclarationDescriptorImpl(null, Collections.emptyList(), "") { + @NotNull + @Override + public DeclarationDescriptor substitute(TypeSubstitutor substitutor) { + throw new UnsupportedOperationException(); // TODO + } + + @Override + public R accept(DeclarationDescriptorVisitor visitor, D data) { + return visitor.visitDeclarationDescriptor(this, data); + } + }; + protected final Map classDescriptorCache = new HashMap(); protected final Map typeParameterDescriptorCache = Maps.newHashMap(); protected final Map methodDescriptorCache = Maps.newHashMap(); @@ -91,6 +104,7 @@ public class JavaDescriptorResolver { )); classDescriptorCache.put(psiClass.getQualifiedName(), classDescriptor); classDescriptor.setUnsubstitutedMemberScope(new JavaClassMembersScope(classDescriptor, psiClass, semanticServices, false)); + classDescriptor.setClassObjectMemberScope(new JavaClassMembersScope(classDescriptor, psiClass, semanticServices, true)); // UGLY HACK supertypes.addAll(getSupertypes(psiClass)); diff --git a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java index 3991cd4c595..4c1dc329db4 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java @@ -713,7 +713,7 @@ public class JetTypeInferrer { result = classObjectType; } 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); return; diff --git a/idea/testData/psi/SimpleClassMembers.txt b/idea/testData/psi/SimpleClassMembers.txt index 8b290d778d4..c76ec036370 100644 --- a/idea/testData/psi/SimpleClassMembers.txt +++ b/idea/testData/psi/SimpleClassMembers.txt @@ -171,14 +171,13 @@ JetFile: SimpleClassMembers.jet CLASS_OBJECT PsiElement(class)('class') PsiWhiteSpace(' ') - OBJECT_LITERAL - OBJECT_DECLARATION - PsiElement(object)('object') - PsiWhiteSpace(' ') - CLASS_BODY - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n\n ') - PsiElement(RBRACE)('}') + OBJECT_DECLARATION + PsiElement(object)('object') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') CLASS_OBJECT MODIFIER_LIST @@ -186,14 +185,13 @@ JetFile: SimpleClassMembers.jet PsiWhiteSpace(' ') PsiElement(class)('class') PsiWhiteSpace(' ') - OBJECT_LITERAL - OBJECT_DECLARATION - PsiElement(object)('object') - PsiWhiteSpace(' ') - CLASS_BODY - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n\n ') - PsiElement(RBRACE)('}') + OBJECT_DECLARATION + PsiElement(object)('object') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') CLASS_OBJECT MODIFIER_LIST @@ -201,23 +199,22 @@ JetFile: SimpleClassMembers.jet PsiWhiteSpace(' ') PsiElement(class)('class') PsiWhiteSpace(' ') - OBJECT_LITERAL - OBJECT_DECLARATION - PsiElement(object)('object') - PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - DELEGATION_SPECIFIER_LIST - DELEGATOR_SUPER_CLASS - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Fooo') - PsiWhiteSpace(' ') - CLASS_BODY - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n\n ') - PsiElement(RBRACE)('}') + OBJECT_DECLARATION + PsiElement(object)('object') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Fooo') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') CLASS_OBJECT MODIFIER_LIST @@ -225,35 +222,34 @@ JetFile: SimpleClassMembers.jet PsiWhiteSpace(' ') PsiElement(class)('class') PsiWhiteSpace(' ') - OBJECT_LITERAL - OBJECT_DECLARATION - PsiElement(object)('object') + OBJECT_DECLARATION + 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(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - DELEGATION_SPECIFIER_LIST - DELEGATOR_SUPER_CLASS - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Fooo') - PsiElement(COMMA)(',') + DELEGATOR_BY + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Bar') PsiWhiteSpace(' ') - DELEGATOR_BY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Bar') - PsiWhiteSpace(' ') - PsiElement(by)('by') - PsiWhiteSpace(' ') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiWhiteSpace(' ') - CLASS_BODY - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n\n ') - PsiElement(RBRACE)('}') + PsiElement(by)('by') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') CLASS_OBJECT MODIFIER_LIST @@ -261,139 +257,138 @@ JetFile: SimpleClassMembers.jet PsiWhiteSpace(' ') PsiElement(class)('class') PsiWhiteSpace(' ') - OBJECT_LITERAL - OBJECT_DECLARATION - PsiElement(object)('object') + OBJECT_DECLARATION + 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(' ') - 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(' ') - DELEGATION_SPECIFIER_LIST - DELEGATOR_SUPER_CLASS - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Fooo') - PsiElement(COMMA)(',') + DELEGATOR_SUPER_CALL + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Goo') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + CLASS_BODY + PsiErrorElement:Expecting a class body + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + CLASS + PsiElement(class)('class') PsiWhiteSpace(' ') - DELEGATOR_BY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Bar') - PsiWhiteSpace(' ') - PsiElement(by)('by') - PsiWhiteSpace(' ') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiElement(COMMA)(',') + PsiElement(IDENTIFIER)('Bar') PsiWhiteSpace(' ') - DELEGATOR_SUPER_CALL - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Goo') - VALUE_ARGUMENT_LIST - PsiElement(LPAR)('(') - PsiElement(RPAR)(')') - PsiWhiteSpace('\n ') - CLASS_BODY - PsiErrorElement:Expecting a class body + TYPE_PARAMETER_LIST + + CLASS_BODY + PsiElement(LBRACE)('{') PsiElement(RBRACE)('}') - PsiWhiteSpace('\n\n ') - CLASS - PsiElement(class)('class') + PsiWhiteSpace('\n\n ') + FUN + 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 + + 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(' ') - PsiElement(IDENTIFIER)('Bar') - PsiWhiteSpace(' ') - TYPE_PARAMETER_LIST - - CLASS_BODY - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n\n ') - FUN - 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 - - 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)('}') + 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 ') FUN PsiElement(fun)('fun') @@ -535,14 +530,13 @@ JetFile: SimpleClassMembers.jet CLASS_OBJECT PsiElement(class)('class') PsiWhiteSpace(' ') - OBJECT_LITERAL - OBJECT_DECLARATION - PsiElement(object)('object') - PsiWhiteSpace(' ') - CLASS_BODY - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n\n ') - PsiElement(RBRACE)('}') + OBJECT_DECLARATION + PsiElement(object)('object') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') CLASS_OBJECT MODIFIER_LIST @@ -550,14 +544,13 @@ JetFile: SimpleClassMembers.jet PsiWhiteSpace(' ') PsiElement(class)('class') PsiWhiteSpace(' ') - OBJECT_LITERAL - OBJECT_DECLARATION - PsiElement(object)('object') - PsiWhiteSpace(' ') - CLASS_BODY - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n\n ') - PsiElement(RBRACE)('}') + OBJECT_DECLARATION + PsiElement(object)('object') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') CLASS_OBJECT MODIFIER_LIST @@ -565,23 +558,22 @@ JetFile: SimpleClassMembers.jet PsiWhiteSpace(' ') PsiElement(class)('class') PsiWhiteSpace(' ') - OBJECT_LITERAL - OBJECT_DECLARATION - PsiElement(object)('object') - PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - DELEGATION_SPECIFIER_LIST - DELEGATOR_SUPER_CLASS - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Fooo') - PsiWhiteSpace(' ') - CLASS_BODY - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n\n ') - PsiElement(RBRACE)('}') + OBJECT_DECLARATION + PsiElement(object)('object') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Fooo') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') CLASS_OBJECT MODIFIER_LIST @@ -589,35 +581,34 @@ JetFile: SimpleClassMembers.jet PsiWhiteSpace(' ') PsiElement(class)('class') PsiWhiteSpace(' ') - OBJECT_LITERAL - OBJECT_DECLARATION - PsiElement(object)('object') + OBJECT_DECLARATION + 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(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - DELEGATION_SPECIFIER_LIST - DELEGATOR_SUPER_CLASS - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Fooo') - PsiElement(COMMA)(',') + DELEGATOR_BY + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Bar') PsiWhiteSpace(' ') - DELEGATOR_BY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Bar') - PsiWhiteSpace(' ') - PsiElement(by)('by') - PsiWhiteSpace(' ') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiWhiteSpace(' ') - CLASS_BODY - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n\n ') - PsiElement(RBRACE)('}') + PsiElement(by)('by') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') CLASS_OBJECT MODIFIER_LIST @@ -625,43 +616,42 @@ JetFile: SimpleClassMembers.jet PsiWhiteSpace(' ') PsiElement(class)('class') PsiWhiteSpace(' ') - OBJECT_LITERAL - OBJECT_DECLARATION - PsiElement(object)('object') + OBJECT_DECLARATION + 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(' ') - 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(' ') - DELEGATION_SPECIFIER_LIST - DELEGATOR_SUPER_CLASS - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Fooo') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DELEGATOR_BY - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Bar') - PsiWhiteSpace(' ') - 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 '} - \ No newline at end of file + 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 '} + \ No newline at end of file diff --git a/idea/testData/psi/examples/PolymorphicClassObjects.txt b/idea/testData/psi/examples/PolymorphicClassObjects.txt index af5f85cf9a9..fd390c9840d 100644 --- a/idea/testData/psi/examples/PolymorphicClassObjects.txt +++ b/idea/testData/psi/examples/PolymorphicClassObjects.txt @@ -134,65 +134,64 @@ JetFile: PolymorphicClassObjects.jet CLASS_OBJECT PsiElement(class)('class') PsiWhiteSpace(' ') - OBJECT_LITERAL - OBJECT_DECLARATION - PsiElement(object)('object') - PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - DELEGATION_SPECIFIER_LIST - DELEGATOR_SUPER_CLASS - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Buildable') - PsiWhiteSpace(' ') - CLASS_BODY - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n ') - FUN - MODIFIER_LIST - PsiElement(override)('override') + OBJECT_DECLARATION + PsiElement(object)('object') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Buildable') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('newBuilder') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('E') + PsiElement(COMMA)(',') PsiWhiteSpace(' ') - PsiElement(fun)('fun') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('newBuilder') - TYPE_PARAMETER_LIST - PsiElement(LT)('<') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('E') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PARAMETER - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') - VALUE_PARAMETER_LIST - PsiElement(LPAR)('(') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Builder') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('E') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('R') - PsiElement(GT)('>') - PsiWhiteSpace('\n\n ') - PsiElement(RBRACE)('}') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Builder') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('E') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n') PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n') diff --git a/idea/testData/psi/examples/UpdateOperation.txt b/idea/testData/psi/examples/UpdateOperation.txt index 43e07ab12ea..c44384ac6be 100644 --- a/idea/testData/psi/examples/UpdateOperation.txt +++ b/idea/testData/psi/examples/UpdateOperation.txt @@ -36,92 +36,91 @@ JetFile: UpdateOperation.jet CLASS_OBJECT PsiElement(class)('class') PsiWhiteSpace(' ') - OBJECT_LITERAL - OBJECT_DECLARATION - PsiElement(object)('object') - PsiWhiteSpace(' ') - CLASS_BODY - PsiElement(LBRACE)('{') - PsiWhiteSpace('\n ') - FUN - PsiElement(fun)('fun') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('copy') - VALUE_PARAMETER_LIST - PsiElement(LPAR)('(') - VALUE_PARAMETER - PsiElement(IDENTIFIER)('from') - PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Pair') - PsiElement(COMMA)(',') + OBJECT_DECLARATION + PsiElement(object)('object') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('copy') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('from') PsiWhiteSpace(' ') - VALUE_PARAMETER - 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') + PsiElement(COLON)(':') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Pair') - VALUE_ARGUMENT_LIST - PsiElement(LPAR)('(') - VALUE_ARGUMENT + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('x') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - VALUE_ARGUMENT + 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)('y') - PsiElement(RPAR)(')') - PsiWhiteSpace('\n ') - PsiElement(RBRACE)('}') + 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(' ') + 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') PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n') diff --git a/idea/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java b/idea/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java index 41949f40385..063a39bfa95 100644 --- a/idea/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java +++ b/idea/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java @@ -70,7 +70,7 @@ public class ControlStructuresTest extends CodegenTestCase { } 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(); assertEquals(5, main.invoke(null, "true")); assertEquals(10, main.invoke(null, "false")); diff --git a/idea/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java b/idea/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java index 786fb584c8a..accd5b6b767 100644 --- a/idea/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java +++ b/idea/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java @@ -123,7 +123,7 @@ public class PrimitiveTypesTest extends CodegenTestCase { } 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(); assertEquals("1.0", main.invoke(null, 1.0)); }