提交 2e8b828e 编写于 作者: A Andrey Breslav

Resolve for "!"

上级 68d60f2b
......@@ -5,39 +5,58 @@ class Array<T> {
fun set(index : Int, value : T) : Unit
}
class Boolean {
virtual class Comparable<in T> {
fun compareTo(other : T) : Int
}
class String {
class Boolean : Comparable<Boolean> {
fun not() : Boolean
}
class String : Comparable<String> {
fun get(index : Int) : Char
val length : Int
fun plus(other : Any?) : String
}
class Double {
class Double : Comparable<Double> {
fun plus(other : Double) : Double
}
class Float {
class Float : Comparable<Float> {
fun compareTo(other : Double) : Int
fun plus(other : Double) : Double
fun plus(other : Float) : Float
}
class Long {
class Long : Comparable<Long> {
fun compareTo(other : Double) : Int
fun compareTo(other : Float) : Int
fun plus(other : Double) : Double
fun plus(other : Float) : Float
fun plus(other : Long) : Long
}
class Int {
class Int : Comparable<Int> {
fun compareTo(other : Double) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun plus(other : Double) : Double
fun plus(other : Float) : Float
fun plus(other : Long) : Long
fun plus(other : Int) : Int
}
class Char {
class Char : Comparable<Char> {
fun compareTo(other : Double) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun compareTo(other : Int) : Int
fun plus(other : Double) : Double
fun plus(other : Float) : Float
fun plus(other : Long) : Long
......@@ -45,7 +64,12 @@ class Char {
fun plus(other : Char) : Char
}
class Short {
class Short : Comparable<Char> {
fun compareTo(other : Double) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun compareTo(other : Int) : Int
fun plus(other : Double) : Double
fun plus(other : Float) : Float
fun plus(other : Long) : Long
......@@ -53,7 +77,13 @@ class Short {
fun plus(other : Short) : Short
}
class Byte {
class Byte : Comparable<Char> {
fun compareTo(other : Double) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Short) : Int
fun plus(other : Double) : Double
fun plus(other : Float) : Float
fun plus(other : Long) : Long
......
......@@ -17,9 +17,9 @@ public class LabelsAnnotator implements Annotator {
element.accept(new JetVisitor() {
@Override
public void visitPrefixExpression(JetPrefixExpression expression) {
ASTNode operationTokenNode = expression.getOperationTokenNode();
if (JetTokens.LABELS.contains(operationTokenNode.getElementType())) {
holder.createInfoAnnotation(operationTokenNode, null).setTextAttributes(JetHighlighter.JET_LABEL_IDENTIFIER);
JetSimpleNameExpression operationSign = expression.getOperationSign();
if (JetTokens.LABELS.contains(operationSign.getReferencedNameElementType())) {
holder.createInfoAnnotation(operationSign, null).setTextAttributes(JetHighlighter.JET_LABEL_IDENTIFIER);
}
}
......
......@@ -263,9 +263,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
while (!myBuilder.newlineBeforeCurrentToken() && atSet(precedence.getOperations())) {
IElementType operation = tt();
PsiBuilder.Marker operationReference = mark();
advance(); // operation
operationReference.done(OPERATION_REFERENCE);
parseOperationReference();
JetNodeType resultType = precedence.parseRightHandSide(operation, this);
expression.done(resultType);
......@@ -291,7 +289,8 @@ public class JetExpressionParsing extends AbstractJetParsing {
}
} else if (atSet(Precedence.PREFIX.getOperations())) {
PsiBuilder.Marker expression = mark();
advance(); // operation
parseOperationReference();
parsePrefixExpression();
expression.done(PREFIX_EXPRESSION);
......@@ -323,7 +322,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
parseArrayAccess();
expression.done(ARRAY_ACCESS_EXPRESSION);
} else if (atSet(Precedence.POSTFIX.getOperations())) {
advance(); // operation
parseOperationReference();
expression.done(POSTFIX_EXPRESSION);
} else if (parseCallWithClosure()) {
parseCallWithClosure();
......@@ -380,6 +379,12 @@ public class JetExpressionParsing extends AbstractJetParsing {
expression.drop();
}
private void parseOperationReference() {
PsiBuilder.Marker operationReference = mark();
advance(); // operation
operationReference.done(OPERATION_REFERENCE);
}
/*
* expression (label? functionLiteral)?
*/
......
......@@ -40,7 +40,9 @@ public abstract class JetNamedDeclaration extends JetDeclaration implements PsiN
@Override
public TextRange getRangeInElement() {
return getElement().getTextRange().shiftRight(getElement().getTextOffset());
PsiElement element = getElement();
if (element == null) return null;
return element.getTextRange().shiftRight(element.getTextOffset());
}
@Override
......
......@@ -2,9 +2,7 @@ package org.jetbrains.jet.lang.psi;
import com.intellij.lang.ASTNode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lexer.JetToken;
import org.jetbrains.jet.lexer.JetTokens;
import org.jetbrains.jet.JetNodeTypes;
/**
* @author max
......@@ -27,14 +25,7 @@ public class JetPostfixExpression extends JetExpression {
}
@NotNull
public ASTNode getOperationTokenNode() {
ASTNode operationNode = getNode().findChildByType(JetTokens.OPERATIONS);
assert operationNode != null;
return operationNode;
}
@Nullable
public JetToken getOperationSign() {
return (JetToken) getOperationTokenNode().getElementType();
public JetSimpleNameExpression getOperationSign() {
return (JetSimpleNameExpression) findChildByType(JetNodeTypes.OPERATION_REFERENCE);
}
}
package org.jetbrains.jet.lang.psi;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lexer.JetToken;
import org.jetbrains.jet.lexer.JetTokens;
import org.jetbrains.jet.JetNodeTypes;
/**
* @author max
......@@ -20,20 +20,16 @@ public class JetPrefixExpression extends JetExpression {
@NotNull
public JetExpression getBaseExpression() {
JetExpression answer = findChildByClass(JetExpression.class);
assert answer != null;
return answer;
PsiElement expression = getOperationSign().getNextSibling();
while (expression != null && false == expression instanceof JetExpression) {
expression = expression.getNextSibling();
}
assert expression != null;
return (JetExpression) expression;
}
@NotNull
public ASTNode getOperationTokenNode() {
ASTNode operationNode = getNode().findChildByType(JetTokens.OPERATIONS);
assert operationNode != null;
return operationNode;
}
@NotNull
public JetToken getOperationSign() {
return (JetToken) getOperationTokenNode().getElementType();
public JetSimpleNameExpression getOperationSign() {
return (JetSimpleNameExpression) findChildByType(JetNodeTypes.OPERATION_REFERENCE);
}
}
......@@ -61,22 +61,33 @@ public class ClassDescriptorResolver {
List<TypeParameterDescriptor> typeParameters
= resolveTypeParameters(descriptor, parameterScope, classElement.getTypeParameters());
boolean open = classElement.hasModifier(JetTokens.OPEN_KEYWORD);
List<JetType> supertypes = new ArrayList<JetType>();
TypeConstructorImpl typeConstructor = new TypeConstructorImpl(
descriptor,
AttributeResolver.INSTANCE.resolveAttributes(classElement.getModifierList()),
!open,
classElement.getName(),
typeParameters,
supertypes);
descriptor.setTypeConstructor(
typeConstructor
);
List<JetDelegationSpecifier> delegationSpecifiers = classElement.getDelegationSpecifiers();
// TODO : assuming that the hierarchy is acyclic
Collection<? extends JetType> superclasses = delegationSpecifiers.isEmpty()
? Collections.singleton(JetStandardClasses.getAnyType())
: resolveTypes(parameterScope, delegationSpecifiers);
boolean open = classElement.hasModifier(JetTokens.OPEN_KEYWORD);
descriptor.setTypeConstructor(
new TypeConstructor(
descriptor,
AttributeResolver.INSTANCE.resolveAttributes(classElement.getModifierList()),
!open,
classElement.getName(),
typeParameters,
superclasses)
);
// TODO : UGLY HACK
supertypes.addAll(superclasses);
// TODO : importing may be a bad idea
for (JetType supertype : superclasses) {
parameterScope.importScope(supertype.getMemberScope());
}
trace.recordDeclarationResolution(classElement, descriptor);
}
......
......@@ -32,7 +32,13 @@ public class JavaClassMembersScope implements JetScope {
@Override
public ClassDescriptor getClass(@NotNull String name) {
throw new UnsupportedOperationException(); // TODO
for (PsiClass innerClass : psiClass.getAllInnerClasses()) {
if (name.equals(innerClass.getName())) {
if (innerClass.hasModifierProperty(PsiModifier.STATIC) != staticMembers) return null;
return semanticServices.getDescriptorResolver().resolveClass(innerClass);
}
}
return null;
}
@Override
......
......@@ -33,7 +33,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements Cl
public final ClassDescriptorImpl initialize(boolean sealed,
List<TypeParameterDescriptor> typeParameters,
Collection<? extends JetType> superclasses, JetScope memberDeclarations) {
this.typeConstructor = new TypeConstructor(this, getAttributes(), sealed, getName(), typeParameters, superclasses);
this.typeConstructor = new TypeConstructorImpl(this, getAttributes(), sealed, getName(), typeParameters, superclasses);
this.memberDeclarations = memberDeclarations;
return this;
}
......
......@@ -63,7 +63,7 @@ public class ErrorType {
}
private static JetType createErrorType(String debugMessage, JetScope memberScope) {
return new ErrorTypeImpl(new TypeConstructor(null, Collections.<Attribute>emptyList(), false, "[ERROR : " + debugMessage + "]", Collections.<TypeParameterDescriptor>emptyList(), Collections.<JetType>emptyList()), memberScope);
return new ErrorTypeImpl(new TypeConstructorImpl(null, Collections.<Attribute>emptyList(), false, "[ERROR : " + debugMessage + "]", Collections.<TypeParameterDescriptor>emptyList(), Collections.<JetType>emptyList()), memberScope);
}
public static JetType createWrongVarianceErrorType(TypeProjection value) {
......
......@@ -3,58 +3,21 @@ package org.jetbrains.jet.lang.types;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* @author abreslav
*/
public class TypeConstructor extends AnnotatedImpl {
private final List<TypeParameterDescriptor> parameters;
private final Collection<? extends JetType> supertypes;
private final String debugName;
private final boolean sealed;
@Nullable
private final DeclarationDescriptor declarationDescriptor;
public TypeConstructor(
@Nullable DeclarationDescriptor declarationDescriptor,
@NotNull List<Attribute> attributes,
boolean sealed,
@NotNull String debugName,
@NotNull List<TypeParameterDescriptor> parameters,
@NotNull Collection<? extends JetType> supertypes) {
super(attributes);
this.declarationDescriptor = declarationDescriptor;
this.sealed = sealed;
this.debugName = debugName;
this.parameters = new ArrayList<TypeParameterDescriptor>(parameters);
this.supertypes = supertypes;
}
public interface TypeConstructor extends Annotated {
@NotNull
public List<TypeParameterDescriptor> getParameters() {
return parameters;
}
List<TypeParameterDescriptor> getParameters();
@NotNull
public Collection<? extends JetType> getSupertypes() {
return supertypes;
}
@Override
public String toString() {
return debugName;
}
Collection<? extends JetType> getSupertypes();
public boolean isSealed() {
return sealed;
}
boolean isSealed();
@Nullable
public DeclarationDescriptor getDeclarationDescriptor() {
return declarationDescriptor;
}
DeclarationDescriptor getDeclarationDescriptor();
}
package org.jetbrains.jet.lang.types;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* @author abreslav
*/
public class TypeConstructorImpl extends AnnotatedImpl implements TypeConstructor {
private final List<TypeParameterDescriptor> parameters;
private Collection<? extends JetType> supertypes;
private final String debugName;
private final boolean sealed;
@Nullable
private final DeclarationDescriptor declarationDescriptor;
public TypeConstructorImpl(
@Nullable DeclarationDescriptor declarationDescriptor,
@NotNull List<Attribute> attributes,
boolean sealed,
@NotNull String debugName,
@NotNull List<TypeParameterDescriptor> parameters,
@NotNull Collection<? extends JetType> supertypes) {
super(attributes);
this.declarationDescriptor = declarationDescriptor;
this.sealed = sealed;
this.debugName = debugName;
this.parameters = new ArrayList<TypeParameterDescriptor>(parameters);
this.supertypes = supertypes;
}
@Override
@NotNull
public List<TypeParameterDescriptor> getParameters() {
return parameters;
}
@Override
@NotNull
public Collection<? extends JetType> getSupertypes() {
return supertypes;
}
@Override
public String toString() {
return debugName;
}
@Override
public boolean isSealed() {
return sealed;
}
@Override
@Nullable
public DeclarationDescriptor getDeclarationDescriptor() {
return declarationDescriptor;
}
}
......@@ -19,7 +19,7 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl {
this.variance = variance;
this.upperBounds = upperBounds;
// TODO: Should we actually pass the attributes on to the type constructor?
this.typeConstructor = new TypeConstructor(
this.typeConstructor = new TypeConstructorImpl(
this,
attributes,
false,
......
......@@ -56,7 +56,7 @@ public class TypeUtils {
}
List<Attribute> noAttributes = Collections.<Attribute>emptyList();
TypeConstructor constructor = new TypeConstructor(null, noAttributes, false, debugName.toString(), Collections.<TypeParameterDescriptor>emptyList(), types);
TypeConstructor constructor = new TypeConstructorImpl(null, noAttributes, false, debugName.toString(), Collections.<TypeParameterDescriptor>emptyList(), types);
return new JetTypeImpl(
noAttributes,
constructor,
......
......@@ -148,7 +148,8 @@ JetFile: CallsInWhen.jet
PsiElement(LBRACE)('{')
BODY
PREFIX_EXPRESSION
PsiElement(EXCL)('!')
OPERATION_REFERENCE
PsiElement(EXCL)('!')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
PsiElement(RBRACE)('}')
......@@ -171,7 +172,8 @@ JetFile: CallsInWhen.jet
PsiWhiteSpace(' ')
BODY
PREFIX_EXPRESSION
PsiElement(EXCL)('!')
OPERATION_REFERENCE
PsiElement(EXCL)('!')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
PsiElement(RBRACE)('}')
......
......@@ -198,7 +198,8 @@ JetFile: ControlStructures.jet
PsiElement(break)('break')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(LABEL_IDENTIFIER)('@la')
OPERATION_REFERENCE
PsiElement(LABEL_IDENTIFIER)('@la')
PsiWhiteSpace('\n ')
BREAK
PsiElement(break)('break')
......@@ -209,7 +210,8 @@ JetFile: ControlStructures.jet
PsiElement(continue)('continue')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(LABEL_IDENTIFIER)('@la')
OPERATION_REFERENCE
PsiElement(LABEL_IDENTIFIER)('@la')
PsiWhiteSpace('\n ')
CONTINUE
PsiElement(continue)('continue')
......
......@@ -17,7 +17,8 @@ JetFile: EOLsInComments.jet
PsiElement(IDENTIFIER)('a')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(PLUS)('+')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
......@@ -27,7 +28,8 @@ JetFile: EOLsInComments.jet
PsiWhiteSpace('\n ')
PsiComment(DOC_COMMENT)('/** */')
PREFIX_EXPRESSION
PsiElement(PLUS)('+')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
......@@ -37,7 +39,8 @@ JetFile: EOLsInComments.jet
PsiWhiteSpace('\n ')
PsiComment(BLOCK_COMMENT)('/* */')
PREFIX_EXPRESSION
PsiElement(PLUS)('+')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
......@@ -60,7 +63,8 @@ JetFile: EOLsInComments.jet
PsiComment(BLOCK_COMMENT)('/*\n */')
PsiWhiteSpace(' ')
PREFIX_EXPRESSION
PsiElement(PLUS)('+')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
......@@ -83,7 +87,8 @@ JetFile: EOLsInComments.jet
PsiComment(EOL_COMMENT)('//')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(PLUS)('+')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
......@@ -94,7 +99,8 @@ JetFile: EOLsInComments.jet
PsiComment(EOL_COMMENT)('//')
PsiWhiteSpace('\n')
PREFIX_EXPRESSION
PsiElement(PLUS)('+')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
......
......@@ -28,7 +28,8 @@ JetFile: Labels.jet
PARENTHESIZED
PsiElement(LPAR)('(')
PREFIX_EXPRESSION
PsiElement(LABEL_IDENTIFIER)('@a')
OPERATION_REFERENCE
PsiElement(LABEL_IDENTIFIER)('@a')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
......@@ -52,7 +53,8 @@ JetFile: Labels.jet
PARENTHESIZED
PsiElement(LPAR)('(')
PREFIX_EXPRESSION
PsiElement(AT)('@')
OPERATION_REFERENCE
PsiElement(AT)('@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
......@@ -63,7 +65,8 @@ JetFile: Labels.jet
PsiElement(AT)('@')
PsiWhiteSpace(' ')
PREFIX_EXPRESSION
PsiElement(AT)('@')
OPERATION_REFERENCE
PsiElement(AT)('@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
......@@ -86,7 +89,8 @@ JetFile: Labels.jet
PARENTHESIZED
PsiElement(LPAR)('(')
PREFIX_EXPRESSION
PsiElement(LABEL_IDENTIFIER)('@a')
OPERATION_REFERENCE
PsiElement(LABEL_IDENTIFIER)('@a')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
......@@ -97,7 +101,8 @@ JetFile: Labels.jet
PsiElement(LABEL_IDENTIFIER)('@a')
PsiWhiteSpace(' ')
PREFIX_EXPRESSION
PsiElement(LABEL_IDENTIFIER)('@a')
OPERATION_REFERENCE
PsiElement(LABEL_IDENTIFIER)('@a')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
......@@ -120,7 +125,8 @@ JetFile: Labels.jet
PARENTHESIZED
PsiElement(LPAR)('(')
PREFIX_EXPRESSION
PsiElement(ATAT)('@@')
OPERATION_REFERENCE
PsiElement(ATAT)('@@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
......@@ -131,20 +137,23 @@ JetFile: Labels.jet
PsiElement(ATAT)('@@')
PsiWhiteSpace(' ')
PREFIX_EXPRESSION
PsiElement(ATAT)('@@')
OPERATION_REFERENCE
PsiElement(ATAT)('@@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiWhiteSpace('\n\n ')
PREFIX_EXPRESSION
PsiElement(LABEL_IDENTIFIER)('@a')
OPERATION_REFERENCE
PsiElement(LABEL_IDENTIFIER)('@a')
PsiWhiteSpace(' ')
RETURN
PsiElement(return)('return')
PsiElement(ATAT)('@@')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(LABEL_IDENTIFIER)('@a')
OPERATION_REFERENCE
PsiElement(LABEL_IDENTIFIER)('@a')
PsiWhiteSpace(' ')
RETURN
PsiElement(return)('return')
......@@ -154,7 +163,8 @@ JetFile: Labels.jet
PsiElement(INTEGER_LITERAL)('1')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(LABEL_IDENTIFIER)('@a')
OPERATION_REFERENCE
PsiElement(LABEL_IDENTIFIER)('@a')
PsiWhiteSpace(' ')
RETURN
PsiElement(return)('return')
......@@ -163,21 +173,24 @@ JetFile: Labels.jet
PARENTHESIZED
PsiElement(LPAR)('(')
PREFIX_EXPRESSION
PsiElement(ATAT)('@@')
OPERATION_REFERENCE
PsiElement(ATAT)('@@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(LABEL_IDENTIFIER)('@a')
OPERATION_REFERENCE
PsiElement(LABEL_IDENTIFIER)('@a')
PsiWhiteSpace(' ')
RETURN
PsiElement(return)('return')
PsiElement(ATAT)('@@')
PsiWhiteSpace(' ')
PREFIX_EXPRESSION
PsiElement(ATAT)('@@')
OPERATION_REFERENCE
PsiElement(ATAT)('@@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
......@@ -221,7 +234,8 @@ JetFile: Labels.jet
PsiElement(IDENTIFIER)('filter')
PsiWhiteSpace(' ')
PREFIX_EXPRESSION
PsiElement(LABEL_IDENTIFIER)('@f')
OPERATION_REFERENCE
PsiElement(LABEL_IDENTIFIER)('@f')
FUNCTION_LITERAL
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
......@@ -257,7 +271,8 @@ JetFile: Labels.jet
PsiElement(IDENTIFIER)('filter')
PsiWhiteSpace(' ')
PREFIX_EXPRESSION
PsiElement(AT)('@')
OPERATION_REFERENCE
PsiElement(AT)('@')
FUNCTION_LITERAL
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
......@@ -293,7 +308,8 @@ JetFile: Labels.jet
PsiElement(IDENTIFIER)('filter')
PsiWhiteSpace(' ')
PREFIX_EXPRESSION
PsiElement(ATAT)('@@')
OPERATION_REFERENCE
PsiElement(ATAT)('@@')
FUNCTION_LITERAL
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
......
......@@ -58,7 +58,8 @@ JetFile: NewlinesInParentheses.jet
PsiElement(IDENTIFIER)('a')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(PLUS)('+')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
......@@ -99,7 +100,8 @@ JetFile: NewlinesInParentheses.jet
PsiElement(IDENTIFIER)('a')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(PLUS)('+')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
......@@ -123,7 +125,8 @@ JetFile: NewlinesInParentheses.jet
PsiElement(IDENTIFIER)('a')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(PLUS)('+')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
......@@ -178,7 +181,8 @@ JetFile: NewlinesInParentheses.jet
PsiElement(IDENTIFIER)('c')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(PLUS)('+')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('d')
......@@ -205,7 +209,8 @@ JetFile: NewlinesInParentheses.jet
PsiElement(IDENTIFIER)('c')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(PLUS)('+')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('d')
......
......@@ -28,7 +28,8 @@ JetFile: Precedence.jet
POSTFIX_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('x')
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
PsiWhiteSpace(' ')
PsiElement(DOT)('.')
PsiWhiteSpace(' ')
......@@ -36,13 +37,16 @@ JetFile: Precedence.jet
PsiElement(INTEGER_LITERAL)('4')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
PsiWhiteSpace(' ')
PREFIX_EXPRESSION
PsiElement(MINUSMINUS)('--')
OPERATION_REFERENCE
PsiElement(MINUSMINUS)('--')
PsiWhiteSpace(' ')
PREFIX_EXPRESSION
PsiElement(EXCL)('!')
OPERATION_REFERENCE
PsiElement(EXCL)('!')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
......@@ -433,10 +437,12 @@ JetFile: Precedence.jet
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(MINUSMINUS)('--')
OPERATION_REFERENCE
PsiElement(MINUSMINUS)('--')
POSTFIX_EXPRESSION
DOT_QIALIFIED_EXPRESSION
REFERENCE_EXPRESSION
......@@ -444,11 +450,13 @@ JetFile: Precedence.jet
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('b')
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
PsiWhiteSpace('\n ')
BINARY_EXPRESSION
PREFIX_EXPRESSION
PsiElement(MINUSMINUS)('--')
OPERATION_REFERENCE
PsiElement(MINUSMINUS)('--')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiWhiteSpace(' ')
......@@ -940,7 +948,8 @@ JetFile: Precedence.jet
BINARY_EXPRESSION
BINARY_WITH_TYPE
PREFIX_EXPRESSION
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('t')
PsiWhiteSpace(' ')
......
......@@ -671,7 +671,8 @@ JetFile: SimpleExpressions.jet
PsiElement(break)('break')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(LABEL_IDENTIFIER)('@la')
OPERATION_REFERENCE
PsiElement(LABEL_IDENTIFIER)('@la')
PsiWhiteSpace('\n ')
BREAK
PsiElement(break)('break')
......@@ -682,7 +683,8 @@ JetFile: SimpleExpressions.jet
PsiElement(continue)('continue')
PsiWhiteSpace('\n ')
PREFIX_EXPRESSION
PsiElement(LABEL_IDENTIFIER)('@la')
OPERATION_REFERENCE
PsiElement(LABEL_IDENTIFIER)('@la')
PsiWhiteSpace('\n ')
CONTINUE
PsiElement(continue)('continue')
......
......@@ -77,7 +77,8 @@ JetFile: AnonymousObjects.jet
POSTFIX_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('clickCount')
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
PsiElement(SEMICOLON)(';')
PsiWhiteSpace('\n ')
IF
......
......@@ -564,12 +564,14 @@ JetFile: BinaryTree.jet
POSTFIX_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('size')
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
PsiWhiteSpace('\n ')
POSTFIX_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('version')
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
PsiWhiteSpace('\n ')
RETURN
PsiElement(return)('return')
......@@ -1168,12 +1170,14 @@ JetFile: BinaryTree.jet
POSTFIX_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('size')
PsiElement(MINUSMINUS)('--')
OPERATION_REFERENCE
PsiElement(MINUSMINUS)('--')
PsiWhiteSpace('\n ')
POSTFIX_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('version')
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
PsiWhiteSpace('\n ')
RETURN
PsiElement(return)('return')
......@@ -2048,7 +2052,8 @@ JetFile: BinaryTree.jet
PsiElement(LPAR)('(')
CONDITION
PREFIX_EXPRESSION
PsiElement(EXCL)('!')
OPERATION_REFERENCE
PsiElement(EXCL)('!')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('hasNext')
PsiElement(RPAR)(')')
......@@ -2140,7 +2145,8 @@ JetFile: BinaryTree.jet
PsiElement(LPAR)('(')
CONDITION
PREFIX_EXPRESSION
PsiElement(EXCL)('!')
OPERATION_REFERENCE
PsiElement(EXCL)('!')
DOT_QIALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('down')
......@@ -2400,7 +2406,8 @@ JetFile: BinaryTree.jet
PsiWhiteSpace(' ')
BINARY_EXPRESSION
PREFIX_EXPRESSION
PsiElement(EXCL)('!')
OPERATION_REFERENCE
PsiElement(EXCL)('!')
DOT_QIALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('down')
......@@ -2412,7 +2419,8 @@ JetFile: BinaryTree.jet
PsiElement(OROR)('||')
PsiWhiteSpace(' ')
PREFIX_EXPRESSION
PsiElement(EXCL)('!')
OPERATION_REFERENCE
PsiElement(EXCL)('!')
DOT_QIALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('up')
......@@ -2486,7 +2494,8 @@ JetFile: BinaryTree.jet
POSTFIX_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('version')
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
PsiWhiteSpace('\n ')
BINARY_EXPRESSION
DOT_QIALIFIED_EXPRESSION
......
......@@ -668,7 +668,8 @@ JetFile: Graph.jet
PsiElement(LPAR)('(')
CONDITION
PREFIX_EXPRESSION
PsiElement(EXCL)('!')
OPERATION_REFERENCE
PsiElement(EXCL)('!')
CALL_EXPRESSION
DOT_QIALIFIED_EXPRESSION
REFERENCE_EXPRESSION
......@@ -852,7 +853,8 @@ JetFile: Graph.jet
PsiElement(LPAR)('(')
CONDITION
PREFIX_EXPRESSION
PsiElement(EXCL)('!')
OPERATION_REFERENCE
PsiElement(EXCL)('!')
CALL_EXPRESSION
DOT_QIALIFIED_EXPRESSION
REFERENCE_EXPRESSION
......@@ -892,7 +894,8 @@ JetFile: Graph.jet
PsiElement(LPAR)('(')
CONDITION
PREFIX_EXPRESSION
PsiElement(EXCL)('!')
OPERATION_REFERENCE
PsiElement(EXCL)('!')
DOT_QIALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('pending')
......
......@@ -211,7 +211,8 @@ JetFile: UpdateOperation.jet
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PREFIX_EXPRESSION
PsiElement(MINUS)('-')
OPERATION_REFERENCE
PsiElement(MINUS)('-')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiElement(RPAR)(')')
......
......@@ -291,7 +291,8 @@ JetFile: ArrayList.jet
POSTFIX_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('index')
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
PsiElement(RBRACKET)(']')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
......@@ -709,7 +710,8 @@ JetFile: ArrayList.jet
POSTFIX_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('used')
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
......@@ -819,7 +821,8 @@ JetFile: ArrayList.jet
POSTFIX_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('used')
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace(' ')
......
......@@ -354,7 +354,8 @@ JetFile: IIterator.jet
PsiElement(LPAR)('(')
CONDITION
PREFIX_EXPRESSION
PsiElement(EXCL)('!')
OPERATION_REFERENCE
PsiElement(EXCL)('!')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('hasNext')
PsiElement(RPAR)(')')
......@@ -389,7 +390,8 @@ JetFile: IIterator.jet
POSTFIX_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('count')
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
......
......@@ -179,7 +179,8 @@ JetFile: LinkedList.jet
POSTFIX_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('size')
PsiElement(PLUSPLUS)('++')
OPERATION_REFERENCE
PsiElement(PLUSPLUS)('++')
PsiWhiteSpace('\n ')
CALL_EXPRESSION
REFERENCE_EXPRESSION
......@@ -682,7 +683,8 @@ JetFile: LinkedList.jet
POSTFIX_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('size')
PsiElement(MINUSMINUS)('--')
OPERATION_REFERENCE
PsiElement(MINUSMINUS)('--')
PsiWhiteSpace('\n ')
RETURN
PsiElement(return)('return')
......
......@@ -355,7 +355,8 @@ JetFile: IOSamples.jet
PsiElement(LPAR)('(')
CONDITION
PREFIX_EXPRESSION
PsiElement(EXCL)('!')
OPERATION_REFERENCE
PsiElement(EXCL)('!')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('nextUsed')
PsiElement(RPAR)(')')
......@@ -435,7 +436,8 @@ JetFile: IOSamples.jet
PsiElement(EXCLEQ)('!=')
PsiWhiteSpace(' ')
PREFIX_EXPRESSION
PsiElement(MINUS)('-')
OPERATION_REFERENCE
PsiElement(MINUS)('-')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiElement(RPAR)(')')
......@@ -488,7 +490,8 @@ JetFile: IOSamples.jet
PsiElement(EXCLEQ)('!=')
PsiWhiteSpace(' ')
PREFIX_EXPRESSION
PsiElement(MINUS)('-')
OPERATION_REFERENCE
PsiElement(MINUS)('-')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiWhiteSpace(' \n ')
......
......@@ -784,7 +784,8 @@ JetFile: BinaryHeap.jet
PsiElement(LPAR)('(')
CONDITION
PREFIX_EXPRESSION
PsiElement(EXCL)('!')
OPERATION_REFERENCE
PsiElement(EXCL)('!')
DOT_QIALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('current')
......
......@@ -23,10 +23,14 @@ import util.*
~get3~fun get(i : Object) : Any {return i }
}
~Bar~class Bar : Foo {
~not~fun not() : String {}
}
fun <T> tt(t : T) : T {
val x : List = 0
x`java::java.util.List.get()`[1]
val foo = new Foo
val foo = new Bar
foo`!`[null, 1]
foo`get2`[1, 1]
foo`get1`[1]
......@@ -36,4 +40,5 @@ fun <T> tt(t : T) : T {
(x`java::java.util.List.set()`[1]) = null
x`!`[null] = null
(x`!`[null, 2]) = null
(`not`!foo)[1]`:std::Char`
}
......@@ -105,25 +105,25 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
assertType("if (true) 1 else null", "Int?");
assertType("if (true) null else null", "Nothing?");
assertType("if (true) 1 else '1'", "Any");
assertType("if (true) 1 else '1'", "Comparable<out Any>");
}
public void testWhen() throws Exception {
assertType("when (1) { is 1 => 2; } ", "Int");
assertType("when (1) { is 1 => 2; is 1 => '2'} ", "Any");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 => null} ", "Any?");
assertType("when (1) { is 1 => 2; is 1 => '2'; else => null} ", "Any?");
assertType("when (1) { is 1 => 2; is 1 => '2'; else continue} ", "Any");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 when(e) {is 1 => null}} ", "Any?");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 => when(e) {is 1 => null}} ", "Any?");
assertType("when (1) { is 1 => 2; is 1 => '2'} ", "Comparable<out Any>");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 => null} ", "Comparable<out Any>?");
assertType("when (1) { is 1 => 2; is 1 => '2'; else => null} ", "Comparable<out Any>?");
assertType("when (1) { is 1 => 2; is 1 => '2'; else continue} ", "Comparable<out Any>");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 when(e) {is 1 => null}} ", "Comparable<out Any>?");
assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 => when(e) {is 1 => null}} ", "Comparable<out Any>?");
}
public void testTry() throws Exception {
assertType("try {1} finally{2}", "Int");
assertType("try {1} catch (e : e) {'a'} finally{2}", "Int");
assertType("try {1} catch (e : e) {'a'} finally{'2'}", "Any");
assertType("try {1} catch (e : e) {'a'}", "Any");
assertType("try {1} catch (e : e) {'a'} catch (e : e) {null}", "Any?");
assertType("try {1} catch (e : e) {'a'} finally{'2'}", "Comparable<out Any>");
assertType("try {1} catch (e : e) {'a'}", "Comparable<out Any>");
assertType("try {1} catch (e : e) {'a'} catch (e : e) {null}", "Comparable<out Any>?");
assertType("try {} catch (e : e) {}", "Unit");
}
......@@ -137,7 +137,7 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
assertCommonSupertype("Int?", "Int", "Nothing?");
assertCommonSupertype("Nothing?", "Nothing?", "Nothing?");
assertCommonSupertype("Any", "Int", "Char");
assertCommonSupertype("Comparable<out Any>", "Int", "Char");
assertCommonSupertype("Base_T<*>", "Base_T<*>", "Derived_T<*>");
assertCommonSupertype("Any", "Base_inT<*>", "Derived_T<*>");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册