Merge remote branch 'origin/master'
This commit is contained in:
@@ -69,6 +69,7 @@ public class KotlinCompiler {
|
||||
environment.addToClasspath(rtJar);
|
||||
|
||||
environment.registerFileType(JetFileType.INSTANCE, "kt");
|
||||
environment.registerFileType(JetFileType.INSTANCE, "jet");
|
||||
environment.registerParserDefinition(new JetParserDefinition());
|
||||
|
||||
VirtualFile vFile = environment.getLocalFileSystem().findFileByPath(arguments.src);
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ public class JavaDescriptorResolver {
|
||||
private DeclarationDescriptor resolveParentDescriptor(PsiClass psiClass) {
|
||||
PsiClass containingClass = psiClass.getContainingClass();
|
||||
if (containingClass != null) {
|
||||
return resolveClass(psiClass);
|
||||
return resolveClass(containingClass);
|
||||
}
|
||||
|
||||
PsiJavaFile containingFile = (PsiJavaFile) psiClass.getContainingFile();
|
||||
|
||||
@@ -556,6 +556,7 @@ public class JetControlFlowProcessor {
|
||||
List<JetElement> statements = bodyExpression.getStatements();
|
||||
generateSubroutineControlFlow(functionLiteral, statements);
|
||||
}
|
||||
builder.read(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -39,6 +39,6 @@ public class LocalDeclarationInstruction extends ReadValueInstruction {
|
||||
else if (element instanceof JetObjectDeclaration) {
|
||||
kind = "o";
|
||||
}
|
||||
return "r" + kind + "(" + element.getText() + ")";
|
||||
return "d" + kind + "(" + element.getText() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.jetbrains.jet.lang.psi;
|
||||
import com.intellij.extapi.psi.ASTWrapperPsiElement;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
@@ -48,6 +49,16 @@ public class JetElement extends ASTWrapperPsiElement {
|
||||
}
|
||||
}
|
||||
|
||||
public <D> void acceptChildren(@NotNull JetTreeVisitor<D> visitor, D data) {
|
||||
PsiElement child = getFirstChild();
|
||||
while (child != null) {
|
||||
if (child instanceof JetElement) {
|
||||
((JetElement) child).accept(visitor, data);
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
public void accept(@NotNull JetVisitorVoid visitor) {
|
||||
visitor.visitJetElement(this);
|
||||
}
|
||||
|
||||
@@ -1,804 +1,12 @@
|
||||
package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class JetTreeVisitor<D> extends JetVisitor<Void, D> {
|
||||
@Override
|
||||
public Void visitNamespace(JetNamespace namespace, D data) {
|
||||
List<JetImportDirective> importDirectives = namespace.getImportDirectives();
|
||||
for (JetImportDirective directive : importDirectives) {
|
||||
directive.accept(this, data);
|
||||
}
|
||||
List<JetDeclaration> declarations = namespace.getDeclarations();
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
declaration.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitClass(JetClass klass, D data) {
|
||||
List<JetDeclaration> declarations = klass.getDeclarations();
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
declaration.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitClassObject(JetClassObject classObject, D data) {
|
||||
JetObjectDeclaration objectDeclaration = classObject.getObjectDeclaration();
|
||||
if (objectDeclaration != null) {
|
||||
objectDeclaration.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitConstructor(JetConstructor constructor, D data) {
|
||||
visitDeclarationWithBody(constructor, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitNamedFunction(JetNamedFunction function, D data) {
|
||||
visitDeclarationWithBody(function, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitProperty(JetProperty property, D data) {
|
||||
List<JetPropertyAccessor> accessors = property.getAccessors();
|
||||
for (JetPropertyAccessor accessor : accessors) {
|
||||
accessor.accept(this, data);
|
||||
}
|
||||
JetExpression initializer = property.getInitializer();
|
||||
if (initializer != null) {
|
||||
initializer.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypedef(JetTypedef typedef, D data) {
|
||||
return super.visitTypedef(typedef, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitJetFile(JetFile file, D data) {
|
||||
JetNamespace rootNamespace = file.getRootNamespace();
|
||||
return rootNamespace.accept(this, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitImportDirective(JetImportDirective importDirective, D data) {
|
||||
return super.visitImportDirective(importDirective, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitClassBody(JetClassBody classBody, D data) {
|
||||
List<JetDeclaration> declarations = classBody.getDeclarations();
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
declaration.accept(this, data);
|
||||
}
|
||||
List<JetConstructor> secondaryConstructors = classBody.getSecondaryConstructors();
|
||||
for (JetConstructor constructor : secondaryConstructors) {
|
||||
constructor.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitNamespaceBody(JetNamespaceBody body, D data) {
|
||||
List<JetDeclaration> declarations = body.getDeclarations();
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
declaration.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitModifierList(JetModifierList list, D data) {
|
||||
return super.visitModifierList(list, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitAnnotation(JetAnnotation annotation, D data) {
|
||||
return super.visitAnnotation(annotation, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitAnnotationEntry(JetAnnotationEntry annotationEntry, D data) {
|
||||
return super.visitAnnotationEntry(annotationEntry, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypeParameterList(JetTypeParameterList list, D data) {
|
||||
List<JetTypeParameter> parameters = list.getParameters();
|
||||
for (JetTypeParameter parameter : parameters) {
|
||||
parameter.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypeParameter(JetTypeParameter parameter, D data) {
|
||||
return super.visitTypeParameter(parameter, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitEnumEntry(JetEnumEntry enumEntry, D data) {
|
||||
List<JetDelegationSpecifier> delegationSpecifiers = enumEntry.getDelegationSpecifiers();
|
||||
for (JetDelegationSpecifier delegationSpecifier : delegationSpecifiers) {
|
||||
delegationSpecifier.accept(this, data);
|
||||
}
|
||||
JetModifierList modifierList = enumEntry.getModifierList();
|
||||
if (modifierList != null) {
|
||||
modifierList.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitParameterList(JetParameterList list, D data) {
|
||||
List<JetParameter> parameters = list.getParameters();
|
||||
for (JetParameter parameter : parameters) {
|
||||
parameter.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitParameter(JetParameter parameter, D data) {
|
||||
return super.visitParameter(parameter, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDelegationSpecifierList(JetDelegationSpecifierList list, D data) {
|
||||
List<JetDelegationSpecifier> delegationSpecifiers = list.getDelegationSpecifiers();
|
||||
for (JetDelegationSpecifier delegationSpecifier : delegationSpecifiers) {
|
||||
delegationSpecifier.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDelegationSpecifier(JetDelegationSpecifier specifier, D data) {
|
||||
return super.visitDelegationSpecifier(specifier, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDelegationByExpressionSpecifier(JetDelegatorByExpressionSpecifier specifier, D data) {
|
||||
return super.visitDelegationByExpressionSpecifier(specifier, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDelegationToSuperCallSpecifier(JetDelegatorToSuperCall call, D data) {
|
||||
return super.visitDelegationToSuperCallSpecifier(call, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDelegationToSuperClassSpecifier(JetDelegatorToSuperClass specifier, D data) {
|
||||
return super.visitDelegationToSuperClassSpecifier(specifier, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDelegationToThisCall(JetDelegatorToThisCall thisCall, D data) {
|
||||
return super.visitDelegationToThisCall(thisCall, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypeReference(JetTypeReference typeReference, D data) {
|
||||
return super.visitTypeReference(typeReference, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitValueArgumentList(JetValueArgumentList list, D data) {
|
||||
List<JetValueArgument> arguments = list.getArguments();
|
||||
for (JetValueArgument argument : arguments) {
|
||||
argument.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitArgument(JetValueArgument argument, D data) {
|
||||
return super.visitArgument(argument, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitLoopExpression(JetLoopExpression loopExpression, D data) {
|
||||
JetExpression body = loopExpression.getBody();
|
||||
if (body != null) {
|
||||
body.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitConstantExpression(JetConstantExpression expression, D data) {
|
||||
return super.visitConstantExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitSimpleNameExpression(JetSimpleNameExpression expression, D data) {
|
||||
return super.visitSimpleNameExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitReferenceExpression(JetReferenceExpression expression, D data) {
|
||||
return super.visitReferenceExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTupleExpression(JetTupleExpression expression, D data) {
|
||||
return super.visitTupleExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitPrefixExpression(JetPrefixExpression expression, D data) {
|
||||
JetExpression baseExpression = expression.getBaseExpression();
|
||||
if (baseExpression != null) {
|
||||
baseExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitPostfixExpression(JetPostfixExpression expression, D data) {
|
||||
JetExpression baseExpression = expression.getBaseExpression();
|
||||
baseExpression.accept(this, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitUnaryExpression(JetUnaryExpression expression, D data) {
|
||||
JetExpression baseExpression = expression.getBaseExpression();
|
||||
assert baseExpression != null;
|
||||
baseExpression.accept(this, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitBinaryExpression(JetBinaryExpression expression, D data) {
|
||||
JetExpression left = expression.getLeft();
|
||||
left.accept(this, data);
|
||||
JetExpression right = expression.getRight();
|
||||
if (right != null) {
|
||||
right.accept(this, data);
|
||||
}
|
||||
return super.visitBinaryExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitReturnExpression(JetReturnExpression expression, D data) {
|
||||
JetExpression returnedExpression = expression.getReturnedExpression();
|
||||
if (returnedExpression != null) {
|
||||
returnedExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitLabelQualifiedExpression(JetLabelQualifiedExpression expression, D data) {
|
||||
JetExpression labeledExpression = expression.getLabeledExpression();
|
||||
if (labeledExpression != null) {
|
||||
labeledExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitThrowExpression(JetThrowExpression expression, D data) {
|
||||
JetExpression thrownExpression = expression.getThrownExpression();
|
||||
if (thrownExpression != null) {
|
||||
thrownExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitBreakExpression(JetBreakExpression expression, D data) {
|
||||
return super.visitBreakExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitContinueExpression(JetContinueExpression expression, D data) {
|
||||
return super.visitContinueExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitIfExpression(JetIfExpression expression, D data) {
|
||||
JetExpression condition = expression.getCondition();
|
||||
if (condition != null) {
|
||||
condition.accept(this, data);
|
||||
}
|
||||
JetExpression then = expression.getThen();
|
||||
if (then != null) {
|
||||
then.accept(this, data);
|
||||
}
|
||||
JetExpression anElse = expression.getElse();
|
||||
if (anElse != null) {
|
||||
anElse.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitWhenExpression(JetWhenExpression expression, D data) {
|
||||
List<JetWhenEntry> entries = expression.getEntries();
|
||||
for (JetWhenEntry entry : entries) {
|
||||
entry.accept(this, data);
|
||||
}
|
||||
JetExpression subjectExpression = expression.getSubjectExpression();
|
||||
if (subjectExpression != null) {
|
||||
subjectExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTryExpression(JetTryExpression expression, D data) {
|
||||
JetBlockExpression tryBlock = expression.getTryBlock();
|
||||
tryBlock.accept(this, data);
|
||||
List<JetCatchClause> catchClauses = expression.getCatchClauses();
|
||||
for (JetCatchClause catchClause : catchClauses) {
|
||||
catchClause.accept(this, data);
|
||||
}
|
||||
JetFinallySection finallyBlock = expression.getFinallyBlock();
|
||||
if (finallyBlock != null) {
|
||||
finallyBlock.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitForExpression(JetForExpression expression, D data) {
|
||||
JetParameter loopParameter = expression.getLoopParameter();
|
||||
if (loopParameter != null) {
|
||||
loopParameter.accept(this, data);
|
||||
}
|
||||
JetExpression loopRange = expression.getLoopRange();
|
||||
if (loopRange != null) {
|
||||
loopRange.accept(this, data);
|
||||
}
|
||||
visitLoopExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitWhileExpression(JetWhileExpression expression, D data) {
|
||||
JetExpression condition = expression.getCondition();
|
||||
if (condition != null) {
|
||||
condition.accept(this, data);
|
||||
}
|
||||
visitLoopExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDoWhileExpression(JetDoWhileExpression expression, D data) {
|
||||
JetExpression condition = expression.getCondition();
|
||||
if (condition != null) {
|
||||
condition.accept(this, data);
|
||||
}
|
||||
visitLoopExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitFunctionLiteralExpression(JetFunctionLiteralExpression expression, D data) {
|
||||
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
||||
functionLiteral.accept(this, data);
|
||||
visitDeclarationWithBody(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitAnnotatedExpression(JetAnnotatedExpression expression, D data) {
|
||||
JetExpression baseExpression = expression.getBaseExpression();
|
||||
baseExpression.accept(this, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitCallExpression(JetCallExpression expression, D data) {
|
||||
JetExpression calleeExpression = expression.getCalleeExpression();
|
||||
if (calleeExpression != null) {
|
||||
calleeExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitArrayAccessExpression(JetArrayAccessExpression expression, D data) {
|
||||
JetExpression arrayExpression = expression.getArrayExpression();
|
||||
arrayExpression.accept(this, data);
|
||||
List<JetExpression> indexExpressions = expression.getIndexExpressions();
|
||||
for (JetExpression indexExpression : indexExpressions) {
|
||||
indexExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitQualifiedExpression(JetQualifiedExpression expression, D data) {
|
||||
JetExpression receiver = expression.getReceiverExpression();
|
||||
receiver.accept(this, data);
|
||||
JetExpression selector = expression.getSelectorExpression();
|
||||
if (selector != null) {
|
||||
selector.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitHashQualifiedExpression(JetHashQualifiedExpression expression, D data) {
|
||||
visitQualifiedExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDotQualifiedExpression(JetDotQualifiedExpression expression, D data) {
|
||||
visitQualifiedExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitPredicateExpression(JetPredicateExpression expression, D data) {
|
||||
visitQualifiedExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitSafeQualifiedExpression(JetSafeQualifiedExpression expression, D data) {
|
||||
visitQualifiedExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitObjectLiteralExpression(JetObjectLiteralExpression expression, D data) {
|
||||
JetObjectDeclaration objectDeclaration = expression.getObjectDeclaration();
|
||||
objectDeclaration.accept(this, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitRootNamespaceExpression(JetRootNamespaceExpression expression, D data) {
|
||||
return super.visitRootNamespaceExpression(expression, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitBlockExpression(JetBlockExpression expression, D data) {
|
||||
List<JetElement> statements = expression.getStatements();
|
||||
for (JetElement statement : statements) {
|
||||
statement.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitCatchSection(JetCatchClause catchClause, D data) {
|
||||
JetParameter catchParameter = catchClause.getCatchParameter();
|
||||
if (catchParameter != null) {
|
||||
catchParameter.accept(this, data);
|
||||
}
|
||||
JetExpression catchBody = catchClause.getCatchBody();
|
||||
if (catchBody != null) {
|
||||
catchBody.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitFinallySection(JetFinallySection finallySection, D data) {
|
||||
JetBlockExpression finalExpression = finallySection.getFinalExpression();
|
||||
finalExpression.accept(this, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypeArgumentList(JetTypeArgumentList typeArgumentList, D data) {
|
||||
List<JetTypeProjection> arguments = typeArgumentList.getArguments();
|
||||
for (JetTypeProjection argument : arguments) {
|
||||
argument.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitThisExpression(JetThisExpression expression, D data) {
|
||||
JetReferenceExpression thisReference = expression.getInstanceReference();
|
||||
thisReference.accept(this, data);
|
||||
visitLabelQualifiedExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitSuperExpression(JetSuperExpression expression, D data) {
|
||||
JetReferenceExpression thisReference = expression.getInstanceReference();
|
||||
thisReference.accept(this, data);
|
||||
JetTypeReference superTypeQualifier = expression.getSuperTypeQualifier();
|
||||
if (superTypeQualifier != null) {
|
||||
superTypeQualifier.accept(this, data);
|
||||
}
|
||||
visitLabelQualifiedExpression(expression, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitParenthesizedExpression(JetParenthesizedExpression expression, D data) {
|
||||
JetExpression innerExpression = expression.getExpression();
|
||||
if (innerExpression != null) {
|
||||
innerExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitInitializerList(JetInitializerList list, D data) {
|
||||
List<JetDelegationSpecifier> initializers = list.getInitializers();
|
||||
for (JetDelegationSpecifier initializer : initializers) {
|
||||
initializer.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitAnonymousInitializer(JetClassInitializer initializer, D data) {
|
||||
JetExpression body = initializer.getBody();
|
||||
body.accept(this, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitPropertyAccessor(JetPropertyAccessor accessor, D data) {
|
||||
visitDeclarationWithBody(accessor, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypeConstraintList(JetTypeConstraintList list, D data) {
|
||||
List<JetTypeConstraint> constraints = list.getConstraints();
|
||||
for (JetTypeConstraint constraint : constraints) {
|
||||
constraint.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypeConstraint(JetTypeConstraint constraint, D data) {
|
||||
JetSimpleNameExpression subjectTypeParameterName = constraint.getSubjectTypeParameterName();
|
||||
if (subjectTypeParameterName != null) {
|
||||
subjectTypeParameterName.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitUserType(JetUserType type, D data) {
|
||||
return super.visitUserType(type, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTupleType(JetTupleType type, D data) {
|
||||
return super.visitTupleType(type, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitFunctionType(JetFunctionType type, D data) {
|
||||
return super.visitFunctionType(type, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitSelfType(JetSelfType type, D data) {
|
||||
return super.visitSelfType(type, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitBinaryWithTypeRHSExpression(JetBinaryExpressionWithTypeRHS expression, D data) {
|
||||
JetExpression left = expression.getLeft();
|
||||
left.accept(this, data);
|
||||
JetTypeReference right = expression.getRight();
|
||||
if (right != null) {
|
||||
right.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitStringTemplateExpression(JetStringTemplateExpression expression, D data) {
|
||||
JetStringTemplateEntry[] entries = expression.getEntries();
|
||||
for (JetStringTemplateEntry entry : entries) {
|
||||
entry.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitNamedDeclaration(JetNamedDeclaration declaration, D data) {
|
||||
return super.visitNamedDeclaration(declaration, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitNullableType(JetNullableType nullableType, D data) {
|
||||
return super.visitNullableType(nullableType, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypeProjection(JetTypeProjection typeProjection, D data) {
|
||||
return super.visitTypeProjection(typeProjection, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitWhenEntry(JetWhenEntry jetWhenEntry, D data) {
|
||||
JetExpression expression = jetWhenEntry.getExpression();
|
||||
if (expression != null) {
|
||||
expression.accept(this, data);
|
||||
}
|
||||
JetWhenCondition[] conditions = jetWhenEntry.getConditions();
|
||||
for (JetWhenCondition condition : conditions) {
|
||||
condition.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitIsExpression(JetIsExpression expression, D data) {
|
||||
JetExpression leftHandSide = expression.getLeftHandSide();
|
||||
leftHandSide.accept(this, data);
|
||||
JetSimpleNameExpression operationReference = expression.getOperationReference();
|
||||
operationReference.accept(this, data);
|
||||
JetPattern pattern = expression.getPattern();
|
||||
if (pattern != null) {
|
||||
pattern.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitWhenConditionCall(JetWhenConditionCall condition, D data) {
|
||||
JetExpression callSuffixExpression = condition.getCallSuffixExpression();
|
||||
if (callSuffixExpression != null) {
|
||||
callSuffixExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitWhenConditionIsPattern(JetWhenConditionIsPattern condition, D data) {
|
||||
JetPattern pattern = condition.getPattern();
|
||||
if (pattern != null) {
|
||||
pattern.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitWhenConditionInRange(JetWhenConditionInRange condition, D data) {
|
||||
JetSimpleNameExpression operationReference = condition.getOperationReference();
|
||||
operationReference.accept(this, data);
|
||||
JetExpression rangeExpression = condition.getRangeExpression();
|
||||
if (rangeExpression != null) {
|
||||
rangeExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTypePattern(JetTypePattern pattern, D data) {
|
||||
return super.visitTypePattern(pattern, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitWildcardPattern(JetWildcardPattern pattern, D data) {
|
||||
return super.visitWildcardPattern(pattern, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitExpressionPattern(JetExpressionPattern pattern, D data) {
|
||||
JetExpression expression = pattern.getExpression();
|
||||
if (expression != null) {
|
||||
expression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitTuplePattern(JetTuplePattern pattern, D data) {
|
||||
List<JetTuplePatternEntry> entries = pattern.getEntries();
|
||||
for (JetTuplePatternEntry entry : entries) {
|
||||
entry.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitDecomposerPattern(JetDecomposerPattern pattern, D data) {
|
||||
JetTuplePattern argumentList = pattern.getArgumentList();
|
||||
argumentList.accept(this, data);
|
||||
JetExpression decomposerExpression = pattern.getDecomposerExpression();
|
||||
if (decomposerExpression != null) {
|
||||
decomposerExpression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitObjectDeclaration(JetObjectDeclaration objectDeclaration, D data) {
|
||||
List<JetDeclaration> declarations = objectDeclaration.getDeclarations();
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
declaration.accept(this, data);
|
||||
}
|
||||
JetDelegationSpecifierList delegationSpecifierList = objectDeclaration.getDelegationSpecifierList();
|
||||
if (delegationSpecifierList != null) {
|
||||
delegationSpecifierList.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitBindingPattern(JetBindingPattern pattern, D data) {
|
||||
JetWhenCondition condition = pattern.getCondition();
|
||||
if (condition != null) {
|
||||
condition.accept(this, data);
|
||||
}
|
||||
JetProperty variableDeclaration = pattern.getVariableDeclaration();
|
||||
variableDeclaration.accept(this, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitStringTemplateEntry(JetStringTemplateEntry entry, D data) {
|
||||
JetExpression expression = entry.getExpression();
|
||||
if (expression != null) {
|
||||
expression.accept(this, data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitStringTemplateEntryWithExpression(JetStringTemplateEntryWithExpression entry, D data) {
|
||||
visitStringTemplateEntry(entry, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitBlockStringTemplateEntry(JetBlockStringTemplateEntry entry, D data) {
|
||||
visitStringTemplateEntry(entry, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitSimpleNameStringTemplateEntry(JetSimpleNameStringTemplateEntry entry, D data) {
|
||||
visitStringTemplateEntry(entry, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitLiteralStringTemplateEntry(JetLiteralStringTemplateEntry entry, D data) {
|
||||
visitStringTemplateEntry(entry, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitEscapeStringTemplateEntry(JetEscapeStringTemplateEntry entry, D data) {
|
||||
visitStringTemplateEntry(entry, data);
|
||||
return null;
|
||||
}
|
||||
|
||||
private Void visitDeclarationWithBody(JetDeclarationWithBody declaration, D data) {
|
||||
JetExpression bodyExpression = declaration.getBodyExpression();
|
||||
if (bodyExpression != null) {
|
||||
bodyExpression.accept(this, data);
|
||||
}
|
||||
List<JetParameter> valueParameters = declaration.getValueParameters();
|
||||
for (JetParameter valueParameter : valueParameters) {
|
||||
valueParameter.accept(this, data);
|
||||
}
|
||||
public Void visitJetElement(JetElement element, D data) {
|
||||
element.acceptChildren(this, data);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,12 @@ import java.util.Set;
|
||||
protected final Map<JetNamespace, WritableScope> namespaceScopes = Maps.newHashMap();
|
||||
protected final Map<JetNamespace, NamespaceDescriptorImpl> namespaceDescriptors = Maps.newHashMap();
|
||||
|
||||
private final Map<JetDeclaration, JetScope> declaringScopes = Maps.newHashMap();
|
||||
|
||||
private final Map<JetNamedFunction, FunctionDescriptorImpl> functions = Maps.newLinkedHashMap();
|
||||
private final Map<JetDeclaration, ConstructorDescriptor> constructors = Maps.newLinkedHashMap();
|
||||
private final Map<JetProperty, PropertyDescriptor> properties = Maps.newLinkedHashMap();
|
||||
private final Set<PropertyDescriptor> primaryConstructorParameterProperties = Sets.newHashSet();
|
||||
private final Map<JetDeclaration, JetScope> declaringScopes = Maps.newHashMap();
|
||||
|
||||
public TopDownAnalysisContext(JetSemanticServices semanticServices, BindingTrace trace) {
|
||||
this.trace = new ObservableBindingTrace(trace);
|
||||
|
||||
@@ -18,44 +18,14 @@ public class TopDownAnalyzer {
|
||||
|
||||
private TopDownAnalyzer() {}
|
||||
|
||||
public static void processObject(
|
||||
public static void process(
|
||||
@NotNull JetSemanticServices semanticServices,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull JetScope outerScope,
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull JetObjectDeclaration object) {
|
||||
process(semanticServices, trace, outerScope, new NamespaceLike.Adapter(containingDeclaration) {
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptorImpl getNamespace(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassifierDescriptor(@NotNull MutableClassDescriptor classDescriptor) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFunctionDescriptor(@NotNull FunctionDescriptor functionDescriptor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyDescriptor(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptor classObjectDescriptor) {
|
||||
return ClassObjectStatus.NOT_ALLOWED;
|
||||
}
|
||||
}, Collections.<JetDeclaration>singletonList(object), JetControlFlowDataTraceFactory.EMPTY, true);
|
||||
NamespaceLike owner,
|
||||
@NotNull List<? extends JetDeclaration> declarations,
|
||||
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
process(semanticServices, trace, outerScope, owner, declarations, flowDataTraceFactory, false);
|
||||
}
|
||||
|
||||
private static void process(
|
||||
@@ -75,16 +45,6 @@ public class TopDownAnalyzer {
|
||||
new DeclarationsChecker(context).process();
|
||||
new ControlFlowAnalyzer(context, flowDataTraceFactory, declaredLocally).process();
|
||||
}
|
||||
|
||||
public static void process(
|
||||
@NotNull JetSemanticServices semanticServices,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull JetScope outerScope,
|
||||
NamespaceLike owner,
|
||||
@NotNull List<? extends JetDeclaration> declarations,
|
||||
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
process(semanticServices, trace, outerScope, owner, declarations, flowDataTraceFactory, false);
|
||||
}
|
||||
|
||||
public static void processStandardLibraryNamespace(
|
||||
@NotNull JetSemanticServices semanticServices,
|
||||
@@ -93,6 +53,8 @@ public class TopDownAnalyzer {
|
||||
TopDownAnalysisContext context = new TopDownAnalysisContext(semanticServices, trace);
|
||||
context.getNamespaceScopes().put(namespace, standardLibraryNamespace.getMemberScope());
|
||||
context.getNamespaceDescriptors().put(namespace, standardLibraryNamespace);
|
||||
context.getDeclaringScopes().put(namespace, outerScope);
|
||||
|
||||
new TypeHierarchyResolver(context).process(outerScope, standardLibraryNamespace, namespace.getDeclarations());
|
||||
new DeclarationResolver(context).process();
|
||||
new DelegationResolver(context).process();
|
||||
@@ -105,6 +67,46 @@ public class TopDownAnalyzer {
|
||||
new BodyResolver(context).resolveBehaviorDeclarationBodies();
|
||||
}
|
||||
|
||||
public static void processObject(
|
||||
@NotNull JetSemanticServices semanticServices,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull JetScope outerScope,
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull JetObjectDeclaration object) {
|
||||
process(semanticServices, trace, outerScope, new NamespaceLike.Adapter(containingDeclaration) {
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptorImpl getNamespace(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassifierDescriptor(@NotNull MutableClassDescriptor classDescriptor) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFunctionDescriptor(@NotNull FunctionDescriptor functionDescriptor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyDescriptor(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptor classObjectDescriptor) {
|
||||
return ClassObjectStatus.NOT_ALLOWED;
|
||||
}
|
||||
}, Collections.<JetDeclaration>singletonList(object), JetControlFlowDataTraceFactory.EMPTY, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WriteThroughScope;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
@@ -38,6 +39,8 @@ public class TypeHierarchyResolver {
|
||||
public void process(@NotNull JetScope outerScope, NamespaceLike owner, @NotNull List<? extends JetDeclaration> declarations) {
|
||||
collectNamespacesAndClassifiers(outerScope, owner, declarations); // namespaceScopes, classes
|
||||
|
||||
processTypeImports();
|
||||
|
||||
createTypeConstructors(); // create type constructors for classes and generic parameters, supertypes are not filled in
|
||||
resolveTypesInClassHeaders(); // Generic bounds and types in supertype lists (no expressions or constructor resolution)
|
||||
|
||||
@@ -82,8 +85,9 @@ public class TypeHierarchyResolver {
|
||||
|
||||
WriteThroughScope namespaceScope = new WriteThroughScope(outerScope, namespaceDescriptor.getMemberScope(), new TraceBasedRedeclarationHandler(context.getTrace()));
|
||||
context.getNamespaceScopes().put(namespace, namespaceScope);
|
||||
context.getDeclaringScopes().put(namespace, outerScope);
|
||||
|
||||
processImports(namespace, namespaceScope, outerScope);
|
||||
// processImports(namespace, namespaceScope, outerScope);
|
||||
|
||||
collectNamespacesAndClassifiers(namespaceScope, namespaceDescriptor, namespace.getDeclarations());
|
||||
}
|
||||
@@ -205,12 +209,17 @@ public class TypeHierarchyResolver {
|
||||
return ClassKind.CLASS;
|
||||
}
|
||||
|
||||
private void processImports(@NotNull JetNamespace namespace, @NotNull WriteThroughScope namespaceScope, @NotNull JetScope outerScope) {
|
||||
private void processTypeImports() {
|
||||
for (JetNamespace jetNamespace : context.getNamespaceDescriptors().keySet()) {
|
||||
processImports(jetNamespace, context.getNamespaceScopes().get(jetNamespace), context.getDeclaringScopes().get(jetNamespace));
|
||||
}
|
||||
}
|
||||
|
||||
private void processImports(@NotNull JetNamespace namespace, @NotNull WritableScope namespaceScope, @NotNull JetScope outerScope) {
|
||||
List<JetImportDirective> importDirectives = namespace.getImportDirectives();
|
||||
for (JetImportDirective importDirective : importDirectives) {
|
||||
if (importDirective.isAbsoluteInRootNamespace()) {
|
||||
// context.getTrace().getErrorHandler().genericError(namespace.getNode(), "Unsupported by TDA"); // TODO
|
||||
context.getTrace().report(UNSUPPORTED.on(namespace, "TypeHierarchyResolver")); // TODO
|
||||
context.getTrace().report(UNSUPPORTED.on(importDirective, "TypeHierarchyResolver")); // TODO
|
||||
continue;
|
||||
}
|
||||
if (importDirective.isAllUnder()) {
|
||||
|
||||
@@ -33,4 +33,8 @@ public interface WritableScope extends JetScope {
|
||||
void importScope(@NotNull JetScope imported);
|
||||
|
||||
void setImplicitReceiver(@NotNull ReceiverDescriptor implicitReceiver);
|
||||
|
||||
void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor);
|
||||
|
||||
void importNamespaceAlias(String aliasName, NamespaceDescriptor namespaceDescriptor);
|
||||
}
|
||||
|
||||
+2
@@ -106,11 +106,13 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
||||
return currentIndividualImportScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||
getCurrentIndividualImportScope().addClassifierAlias(importedClassifierName, classifierDescriptor);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void importNamespaceAlias(String aliasName, NamespaceDescriptor namespaceDescriptor) {
|
||||
getCurrentIndividualImportScope().addNamespaceAlias(aliasName, namespaceDescriptor);
|
||||
}
|
||||
|
||||
@@ -167,4 +167,9 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
}
|
||||
return allDescriptors;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetScope getOuterScope() {
|
||||
return getWorkerScope();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,9 +40,10 @@ l0:
|
||||
r(foo) NEXT:[r(foo(a, 3))] PREV:[r(3)]
|
||||
r(foo(a, 3)) NEXT:[r(genfun)] PREV:[r(foo)]
|
||||
r(genfun) NEXT:[r(genfun<Any>())] PREV:[r(foo(a, 3))]
|
||||
r(genfun<Any>()) NEXT:[rf({1})] PREV:[r(genfun)]
|
||||
rf({1}) NEXT:[r(flfun)] PREV:[r(genfun<Any>())]
|
||||
r(flfun) NEXT:[r(flfun {1})] PREV:[rf({1})]
|
||||
r(genfun<Any>()) NEXT:[df({1})] PREV:[r(genfun)]
|
||||
df({1}) NEXT:[r({1})] PREV:[r(genfun<Any>())]
|
||||
r({1}) NEXT:[r(flfun)] PREV:[df({1})]
|
||||
r(flfun) NEXT:[r(flfun {1})] PREV:[r({1})]
|
||||
r(flfun {1}) NEXT:[r(3)] PREV:[r(flfun)]
|
||||
r(3) NEXT:[r(4)] PREV:[r(flfun {1})]
|
||||
r(4) NEXT:[r(equals)] PREV:[r(3)]
|
||||
|
||||
@@ -93,14 +93,19 @@ fun t3() {
|
||||
l0:
|
||||
<START> NEXT:[jmp?(l2)] PREV:[]
|
||||
jmp?(l2) NEXT:[r(2), r(1)] PREV:[<START>]
|
||||
r(1) NEXT:[rf({ () => if (2 > 3) { retu..)] PREV:[jmp?(l2)]
|
||||
rf({ () =>
|
||||
r(1) NEXT:[df({ () => if (2 > 3) { retu..)] PREV:[jmp?(l2)]
|
||||
df({ () =>
|
||||
if (2 > 3) {
|
||||
return@
|
||||
}
|
||||
}) NEXT:[r(2)] PREV:[r(1)]
|
||||
}) NEXT:[r({ () => if (2 > 3) { retur..)] PREV:[r(1)]
|
||||
r({ () =>
|
||||
if (2 > 3) {
|
||||
return@
|
||||
}
|
||||
}) NEXT:[r(2)] PREV:[df({ () => if (2 > 3) { retu..)]
|
||||
l2:
|
||||
r(2) NEXT:[<END>] PREV:[jmp?(l2), rf({ () => if (2 > 3) { retu..)]
|
||||
r(2) NEXT:[<END>] PREV:[jmp?(l2), r({ () => if (2 > 3) { retur..)]
|
||||
l1:
|
||||
<END> NEXT:[] PREV:[r(2)]
|
||||
error:
|
||||
@@ -171,8 +176,8 @@ fun t3() {
|
||||
}
|
||||
---------------------
|
||||
l0:
|
||||
<START> NEXT:[rf({ () => try { 1 if (2 > 3..)] PREV:[]
|
||||
rf({ () =>
|
||||
<START> NEXT:[df({ () => try { 1 if (2 > 3..)] PREV:[]
|
||||
df({ () =>
|
||||
try {
|
||||
1
|
||||
if (2 > 3) {
|
||||
@@ -181,9 +186,19 @@ l0:
|
||||
} finally {
|
||||
2
|
||||
}
|
||||
}) NEXT:[<END>] PREV:[<START>]
|
||||
}) NEXT:[r({ () => try { 1 if (2 > 3)..)] PREV:[<START>]
|
||||
r({ () =>
|
||||
try {
|
||||
1
|
||||
if (2 > 3) {
|
||||
return@
|
||||
}
|
||||
} finally {
|
||||
2
|
||||
}
|
||||
}) NEXT:[<END>] PREV:[df({ () => try { 1 if (2 > 3..)]
|
||||
l1:
|
||||
<END> NEXT:[] PREV:[rf({ () => try { 1 if (2 > 3..)]
|
||||
<END> NEXT:[] PREV:[r({ () => try { 1 if (2 > 3)..)]
|
||||
error:
|
||||
<ERROR> NEXT:[] PREV:[]
|
||||
l2:
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace kt402
|
||||
|
||||
fun getTypeChecker() : fun(Any):Boolean {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{ (a : Any) => a is <!UNRESOLVED_REFERENCE!>T<!> }<!> // reports unsupported
|
||||
}
|
||||
fun f() : fun(Any) : Boolean {
|
||||
return { (a : Any) => a is String }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// KT-355 Resolve imports after all symbols are built
|
||||
|
||||
namespace a {
|
||||
import b.*
|
||||
val x : X = X()
|
||||
}
|
||||
|
||||
namespace b {
|
||||
class X() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
*/
|
||||
public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
private static FilenameFilter emptyFilter;
|
||||
private boolean checkInfos = false;
|
||||
private String dataPath;
|
||||
protected final String name;
|
||||
@@ -75,20 +76,49 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
|
||||
return dataPath;
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
emptyFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String name) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public interface NamedTestFactory {
|
||||
@NotNull Test createTest(@NotNull String dataPath, @NotNull String name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TestSuite suiteForDirectory(String baseDataDir, @NotNull final String dataPath, boolean recursive, @NotNull NamedTestFactory factory) {
|
||||
return suiteForDirectory(baseDataDir, dataPath, recursive, emptyFilter, factory);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TestSuite suiteForDirectory(String baseDataDir, @NotNull final String dataPath, boolean recursive, final FilenameFilter filter, @NotNull NamedTestFactory factory) {
|
||||
TestSuite suite = new TestSuite(dataPath);
|
||||
final String extension = ".jet";
|
||||
FilenameFilter extensionFilter = new FilenameFilter() {
|
||||
final String extensionJet = ".jet";
|
||||
final String extensionKt = ".kt";
|
||||
final FilenameFilter extensionFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith(extension);
|
||||
return name.endsWith(extensionJet) || name.endsWith(extensionKt);
|
||||
}
|
||||
};
|
||||
FilenameFilter resultFilter;
|
||||
if (filter != emptyFilter) {
|
||||
resultFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String s) {
|
||||
if (extensionFilter.accept(file, s) && filter.accept(file, s)) return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
resultFilter = extensionFilter;
|
||||
}
|
||||
File dir = new File(baseDataDir + dataPath);
|
||||
FileFilter dirFilter = new FileFilter() {
|
||||
@Override
|
||||
@@ -105,11 +135,12 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
|
||||
suite.addTest(suiteForDirectory(baseDataDir, dataPath + "/" + subdir.getName(), recursive, factory));
|
||||
}
|
||||
}
|
||||
List<File> files = Arrays.asList(dir.listFiles(extensionFilter));
|
||||
List<File> files = Arrays.asList(dir.listFiles(resultFilter));
|
||||
Collections.sort(files);
|
||||
for (File file : files) {
|
||||
String fileName = file.getName();
|
||||
assert fileName != null;
|
||||
String extension = fileName.endsWith(extensionJet) ? extensionJet : extensionKt;
|
||||
suite.addTest(factory.createTest(dataPath, fileName.substring(0, fileName.length() - extension.length())));
|
||||
}
|
||||
return suite;
|
||||
|
||||
Reference in New Issue
Block a user