提交 ff6fcabd 编写于 作者: D Dmitry Jemerov

Merge remote branch 'origin/master'

......@@ -3,6 +3,7 @@ package org.jetbrains.jet.codegen;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import jet.typeinfo.TypeInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
......@@ -125,7 +126,7 @@ public class JetTypeMapper {
return mapType(jetType, OwnerKind.INTERFACE);
}
public Type mapType(final JetType jetType, OwnerKind kind) {
public Type mapType(@NotNull final JetType jetType, OwnerKind kind) {
if (jetType.equals(JetStandardClasses.getUnitType()) || jetType.equals(JetStandardClasses.getNothingType())) {
return Type.VOID_TYPE;
}
......
......@@ -30,10 +30,9 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
public MutableClassDescriptor(@NotNull BindingTrace trace, @NotNull DeclarationDescriptor containingDeclaration, @NotNull JetScope outerScope) {
super(containingDeclaration);
this.scopeForMemberLookup = new WritableScopeImpl(JetScope.EMPTY, this, trace.getErrorHandler());
this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, trace.getErrorHandler());
this.scopeForMemberResolution = new WritableScopeImpl(scopeForMemberLookup, this, trace.getErrorHandler());
scopeForMemberResolution.importScope(scopeForSupertypeResolution);
this.scopeForMemberLookup = new WritableScopeImpl(JetScope.EMPTY, this, trace.getErrorHandler()).setDebugName("MemberLookup");
this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, trace.getErrorHandler()).setDebugName("SupertypeResolution");
this.scopeForMemberResolution = new WritableScopeImpl(new ChainedScope(this, scopeForMemberLookup, scopeForSupertypeResolution), this, trace.getErrorHandler()).setDebugName("MemberResolution");
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -2,6 +2,8 @@ package org.jetbrains.jet.lang.descriptors;
import com.google.common.collect.Sets;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.resolve.JetScope;
import org.jetbrains.jet.lang.resolve.LazyScopeAdapter;
import org.jetbrains.jet.lang.types.*;
import java.util.Collections;
......@@ -115,7 +117,12 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
getTypeConstructor(),
TypeUtils.hasNullableBound(this),
Collections.<TypeProjection>emptyList(),
getBoundsAsType().getMemberScope());
new LazyScopeAdapter(new LazyValue<JetScope>() {
@Override
protected JetScope compute() {
return getBoundsAsType().getMemberScope();
}
}));
}
return type;
}
......
......@@ -1520,7 +1520,10 @@ public class JetExpressionParsing extends AbstractJetParsing {
private void parseThisExpression() {
assert _at(THIS_KEYWORD);
PsiBuilder.Marker mark = mark();
PsiBuilder.Marker thisReference = mark();
advance(); // THIS_KEYWORD
thisReference.done(REFERENCE_EXPRESSION);
parseLabel();
......
......@@ -15,7 +15,7 @@ import org.jetbrains.jet.lexer.JetTokens;
* @author max
*/
public class JetSimpleNameExpression extends JetReferenceExpression {
public static final TokenSet REFERENCE_TOKENS = TokenSet.orSet(JetTokens.LABELS, TokenSet.create(JetTokens.IDENTIFIER, JetTokens.FIELD_IDENTIFIER));
public static final TokenSet REFERENCE_TOKENS = TokenSet.orSet(JetTokens.LABELS, TokenSet.create(JetTokens.IDENTIFIER, JetTokens.FIELD_IDENTIFIER, JetTokens.THIS_KEYWORD));
public JetSimpleNameExpression(@NotNull ASTNode node) {
super(node);
......
......@@ -24,4 +24,9 @@ public class JetThisExpression extends JetLabelQualifiedExpression {
return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE);
}
@NotNull
public JetReferenceExpression getThisReference() {
return (JetReferenceExpression) findChildByType(JetNodeTypes.REFERENCE_EXPRESSION);
}
}
package org.jetbrains.jet.lang.resolve;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.types.JetType;
import java.util.Collection;
/**
* @author abreslav
*/
public abstract class AbstractScopeAdapter implements JetScope {
@NotNull
protected abstract JetScope getWorkerScope();
@NotNull
@Override
public JetType getThisType() {
return getWorkerScope().getThisType();
}
@NotNull
@Override
public FunctionGroup getFunctionGroup(@NotNull String name) {
return getWorkerScope().getFunctionGroup(name);
}
@Override
public NamespaceDescriptor getNamespace(@NotNull String name) {
return getWorkerScope().getNamespace(name);
}
@Override
public ClassifierDescriptor getClassifier(@NotNull String name) {
return getWorkerScope().getClassifier(name);
}
@Override
public VariableDescriptor getVariable(@NotNull String name) {
return getWorkerScope().getVariable(name);
}
@NotNull
@Override
public DeclarationDescriptor getContainingDeclaration() {
return getWorkerScope().getContainingDeclaration();
}
@NotNull
@Override
public Collection<DeclarationDescriptor> getDeclarationsByLabel(String labelName) {
return getWorkerScope().getDeclarationsByLabel(labelName);
}
@Override
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
return getWorkerScope().getPropertyByFieldReference(fieldName);
}
@Override
public DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis() {
return getWorkerScope().getDeclarationDescriptorForUnqualifiedThis();
}
}
package org.jetbrains.jet.lang.resolve;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.types.JetType;
import java.util.Collection;
import java.util.Collections;
/**
* @author abreslav
*/
public class ChainedScope implements JetScope {
private final DeclarationDescriptor containingDeclaration;
private final JetScope[] scopeChain;
public ChainedScope(DeclarationDescriptor containingDeclaration, JetScope... scopes) {
this.containingDeclaration = containingDeclaration;
scopeChain = scopes.clone();
}
@Override
public ClassifierDescriptor getClassifier(@NotNull String name) {
for (JetScope scope : scopeChain) {
ClassifierDescriptor classifier = scope.getClassifier(name);
if (classifier != null) return classifier;
}
return null;
}
@Override
public NamespaceDescriptor getNamespace(@NotNull String name) {
for (JetScope jetScope : scopeChain) {
NamespaceDescriptor namespace = jetScope.getNamespace(name);
if (namespace != null) {
return namespace;
}
}
return null;
}
@Override
public VariableDescriptor getVariable(@NotNull String name) {
for (JetScope jetScope : scopeChain) {
VariableDescriptor variable = jetScope.getVariable(name);
if (variable != null) {
return variable;
}
}
return null;
}
@NotNull
@Override
public FunctionGroup getFunctionGroup(@NotNull String name) {
for (JetScope jetScope : scopeChain) {
FunctionGroup functionGroup = jetScope.getFunctionGroup(name);
if (!functionGroup.isEmpty()) return functionGroup;
}
return FunctionGroup.EMPTY;
}
@NotNull
@Override
public JetType getThisType() {
throw new UnsupportedOperationException(); // TODO
}
@NotNull
@Override
public DeclarationDescriptor getContainingDeclaration() {
return containingDeclaration;
}
@NotNull
@Override
public Collection<DeclarationDescriptor> getDeclarationsByLabel(String labelName) {
for (JetScope jetScope : scopeChain) {
Collection<DeclarationDescriptor> declarationsByLabel = jetScope.getDeclarationsByLabel(labelName);
if (!declarationsByLabel.isEmpty()) return declarationsByLabel; // TODO : merge?
}
return Collections.emptyList();
}
@Override
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
for (JetScope jetScope : scopeChain) {
PropertyDescriptor propertyByFieldReference = jetScope.getPropertyByFieldReference(fieldName);
if (propertyByFieldReference != null) {
return propertyByFieldReference;
}
}
return null;
}
@Override
public DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis() {
if (DescriptorUtils.definesItsOwnThis(getContainingDeclaration())) {
return getContainingDeclaration();
}
for (JetScope jetScope : scopeChain) {
DeclarationDescriptor containingDeclaration = jetScope.getContainingDeclaration();
if (DescriptorUtils.definesItsOwnThis(containingDeclaration)) {
return containingDeclaration;
}
}
return null;
}
}
......@@ -174,7 +174,6 @@ public class ClassDescriptorResolver {
WritableScope innerScope = new WritableScopeImpl(scope, functionDescriptor, trace.getErrorHandler());
innerScope.addLabeledDeclaration(functionDescriptor);
List<TypeParameterDescriptor> typeParameterDescriptors = resolveTypeParameters(functionDescriptor, innerScope, function.getTypeParameters());
JetType receiverType = null;
......
package org.jetbrains.jet.lang.resolve;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*;
/**
* @author abreslav
*/
public class DescriptorUtils {
public static boolean definesItsOwnThis(@NotNull DeclarationDescriptor descriptor) {
return descriptor.accept(new DeclarationDescriptorVisitor<Boolean, Void>() {
@Override
public Boolean visitDeclarationDescriptor(DeclarationDescriptor descriptor, Void data) {
return false;
}
@Override
public Boolean visitFunctionDescriptor(FunctionDescriptor descriptor, Void data) {
return descriptor.getReceiverType() != null;
}
@Override
public Boolean visitClassDescriptor(ClassDescriptor descriptor, Void data) {
return true;
}
@Override
public Boolean visitPropertyDescriptor(PropertyDescriptor descriptor, Void data) {
return descriptor.getReceiverType() != null;
}
}, null);
}
}
......@@ -46,4 +46,7 @@ public interface JetScope {
*/
@Nullable
PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName);
@Nullable
DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis();
}
\ No newline at end of file
package org.jetbrains.jet.lang.resolve;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.types.*;
import java.util.Collection;
/**
* @author abreslav
*/
public class JetScopeAdapter implements JetScope {
public class JetScopeAdapter extends AbstractScopeAdapter {
@NotNull
private final JetScope scope;
......@@ -18,51 +14,8 @@ public class JetScopeAdapter implements JetScope {
}
@NotNull
@Override
protected final JetScope getWorkerScope() {
return scope;
}
@NotNull
@Override
public JetType getThisType() {
return scope.getThisType();
}
@NotNull
@Override
public FunctionGroup getFunctionGroup(@NotNull String name) {
return scope.getFunctionGroup(name);
}
@Override
public NamespaceDescriptor getNamespace(@NotNull String name) {
return scope.getNamespace(name);
}
@Override
public ClassifierDescriptor getClassifier(@NotNull String name) {
return scope.getClassifier(name);
}
@Override
public VariableDescriptor getVariable(@NotNull String name) {
return scope.getVariable(name);
}
@NotNull
@Override
public DeclarationDescriptor getContainingDeclaration() {
return scope.getContainingDeclaration();
}
@NotNull
@Override
public Collection<DeclarationDescriptor> getDeclarationsByLabel(String labelName) {
return scope.getDeclarationsByLabel(labelName);
}
@Override
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
return scope.getPropertyByFieldReference(fieldName);
}
}
\ No newline at end of file
......@@ -48,4 +48,9 @@ public abstract class JetScopeImpl implements JetScope {
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
return null;
}
@Override
public DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis() {
return null;
}
}
package org.jetbrains.jet.lang.resolve;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.types.LazyValue;
/**
* @author abreslav
*/
public class LazyScopeAdapter extends AbstractScopeAdapter {
private final LazyValue<JetScope> scope;
public LazyScopeAdapter(LazyValue<JetScope> scope) {
this.scope = scope;
}
@NotNull
@Override
protected JetScope getWorkerScope() {
return scope.get();
}
}
package org.jetbrains.jet.lang.resolve;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.types.*;
......@@ -79,4 +80,10 @@ public class SubstitutingScope implements JetScope {
public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) {
throw new UnsupportedOperationException(); // TODO
}
@Override
@Nullable
public DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis() {
return workerScope.getDeclarationDescriptorForUnqualifiedThis();
}
}
......@@ -12,7 +12,8 @@ import org.jetbrains.jet.lang.JetSemanticServices;
import org.jetbrains.jet.lang.cfg.JetFlowInformationProvider;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.JetTypeInferrer;
import org.jetbrains.jet.lexer.JetTokens;
import java.util.*;
......@@ -98,7 +99,6 @@ public class TopDownAnalyzer {
declaration.accept(new JetVisitor() {
@Override
public void visitNamespace(JetNamespace namespace) {
List<JetImportDirective> importDirectives = namespace.getImportDirectives();
String name = namespace.getName();
if (name == null) {
......@@ -117,25 +117,10 @@ public class TopDownAnalyzer {
}
namespaceDescriptors.put(namespace, namespaceDescriptor);
WritableScope namespaceScope = new WriteThroughScope(outerScope, (WritableScope) namespaceDescriptor.getMemberScope());
WriteThroughScope namespaceScope = new WriteThroughScope(outerScope, namespaceDescriptor.getMemberScope(), trace.getErrorHandler());
namespaceScopes.put(namespace, namespaceScope);
for (JetImportDirective importDirective : importDirectives) {
if (importDirective.isAbsoluteInRootNamespace()) {
throw new UnsupportedOperationException();
}
if (importDirective.isAllUnder()) {
JetExpression importedReference = importDirective.getImportedReference();
if (importedReference != null) {
JetType type = semanticServices.getTypeInferrer(trace, JetFlowInformationProvider.THROW_EXCEPTION).getTypeWithNamespaces(namespaceScope, importedReference, false);
if (type != null) {
namespaceScope.importScope(type.getMemberScope());
}
}
} else {
throw new UnsupportedOperationException();
}
}
processImports(namespace, namespaceScope, outerScope);
collectNamespacesAndClassifiers(namespaceScope, namespaceDescriptor, namespace.getDeclarations());
}
......@@ -167,6 +152,58 @@ public class TopDownAnalyzer {
}
}
private void processImports(@NotNull JetNamespace namespace, @NotNull WriteThroughScope namespaceScope, @NotNull JetScope outerScope) {
List<JetImportDirective> importDirectives = namespace.getImportDirectives();
for (JetImportDirective importDirective : importDirectives) {
if (importDirective.isAbsoluteInRootNamespace()) {
throw new UnsupportedOperationException();
}
if (importDirective.isAllUnder()) {
JetExpression importedReference = importDirective.getImportedReference();
if (importedReference != null) {
JetType type = semanticServices.getTypeInferrer(trace, JetFlowInformationProvider.THROW_EXCEPTION).getTypeWithNamespaces(namespaceScope, importedReference, false);
if (type != null) {
namespaceScope.importScope(type.getMemberScope());
}
}
} else {
ClassifierDescriptor classifierDescriptor = null;
JetSimpleNameExpression referenceExpression = null;
JetExpression importedReference = importDirective.getImportedReference();
if (importedReference instanceof JetDotQualifiedExpression) {
JetDotQualifiedExpression reference = (JetDotQualifiedExpression) importedReference;
JetType type = semanticServices.getTypeInferrer(trace, JetFlowInformationProvider.THROW_EXCEPTION).getTypeWithNamespaces(namespaceScope, reference.getReceiverExpression(), false);
JetExpression selectorExpression = reference.getSelectorExpression();
if (selectorExpression != null) {
referenceExpression = (JetSimpleNameExpression) selectorExpression;
String referencedName = referenceExpression.getReferencedName();
if (type != null && referencedName != null) {
classifierDescriptor = type.getMemberScope().getClassifier(referencedName);
}
}
}
else {
assert importedReference instanceof JetSimpleNameExpression;
referenceExpression = (JetSimpleNameExpression) importedReference;
String referencedName = referenceExpression.getReferencedName();
if (referencedName != null) {
classifierDescriptor = outerScope.getClassifier(referencedName);
}
}
if (classifierDescriptor != null) {
trace.recordReferenceResolution(referenceExpression, classifierDescriptor);
String aliasName = importDirective.getAliasName();
String importedClassifierName = aliasName != null ? aliasName : classifierDescriptor.getName();
namespaceScope.importClassifierAlias(importedClassifierName, classifierDescriptor);
}
}
}
}
private void createTypeConstructors() {
for (Map.Entry<JetClass, MutableClassDescriptor> entry : classes.entrySet()) {
JetClass jetClass = entry.getKey();
......
......@@ -13,8 +13,6 @@ import java.util.*;
* @author abreslav
*/
public class WritableScopeImpl extends WritableScopeWithImports {
@NotNull
private final ErrorHandler errorHandler;
@NotNull
private final DeclarationDescriptor ownerDeclarationDescriptor;
......@@ -37,9 +35,8 @@ public class WritableScopeImpl extends WritableScopeWithImports {
private JetType thisType;
public WritableScopeImpl(@NotNull JetScope scope, @NotNull DeclarationDescriptor owner, @NotNull ErrorHandler errorHandler) {
super(scope);
super(scope, errorHandler);
this.ownerDeclarationDescriptor = owner;
this.errorHandler = errorHandler;
}
@NotNull
......@@ -48,6 +45,14 @@ public class WritableScopeImpl extends WritableScopeWithImports {
return ownerDeclarationDescriptor;
}
@Override
public DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis() {
if (DescriptorUtils.definesItsOwnThis(ownerDeclarationDescriptor)) {
return ownerDeclarationDescriptor;
}
return super.getDeclarationDescriptorForUnqualifiedThis();
}
@NotNull
private Map<String, List<DeclarationDescriptor>> getLabelsToDescriptors() {
if (labelsToDescriptors == null) {
......@@ -59,8 +64,8 @@ public class WritableScopeImpl extends WritableScopeWithImports {
@NotNull
@Override
public Collection<DeclarationDescriptor> getDeclarationsByLabel(@NotNull String labelName) {
Map<String, List<DeclarationDescriptor>> labelsToDescriptors = getLabelsToDescriptors();
Collection<DeclarationDescriptor> superResult = super.getDeclarationsByLabel(labelName);
Map<String, List<DeclarationDescriptor>> labelsToDescriptors = getLabelsToDescriptors();
List<DeclarationDescriptor> declarationDescriptors = labelsToDescriptors.get(labelName);
if (declarationDescriptors == null) {
return superResult;
......
......@@ -2,6 +2,7 @@ package org.jetbrains.jet.lang.resolve;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.ErrorHandler;
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionGroup;
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
......@@ -15,11 +16,22 @@ import java.util.List;
*/
public abstract class WritableScopeWithImports extends JetScopeAdapter implements WritableScope {
private String debugName;
@Nullable
private List<JetScope> imports;
private WritableScope currentIndividualImportScope;
protected final ErrorHandler errorHandler;
public WritableScopeWithImports(@NotNull JetScope scope) {
public WritableScopeWithImports(@NotNull JetScope scope, @NotNull ErrorHandler errorHandler) {
super(scope);
this.errorHandler = errorHandler;
}
public WritableScopeWithImports setDebugName(@NotNull String debugName) {
assert this.debugName == null : this.debugName;
this.debugName = debugName;
return this;
}
@NotNull
......@@ -33,6 +45,7 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
@Override
public void importScope(@NotNull JetScope imported) {
getImports().add(0, imported);
currentIndividualImportScope = null;
}
@Override
......@@ -80,4 +93,19 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
}
return null;
}
public void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) {
if (currentIndividualImportScope == null) {
WritableScopeImpl writableScope = new WritableScopeImpl(JetScope.EMPTY, getContainingDeclaration(), ErrorHandler.DO_NOTHING);
importScope(writableScope);
currentIndividualImportScope = writableScope;
}
currentIndividualImportScope.addClassifierAlias(importedClassifierName, classifierDescriptor);
}
@Override
public String toString() {
return debugName + " for " + getContainingDeclaration();
}
}
......@@ -2,6 +2,7 @@ package org.jetbrains.jet.lang.resolve;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.ErrorHandler;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.types.*;
......@@ -13,8 +14,8 @@ import java.util.Collection;
public class WriteThroughScope extends WritableScopeWithImports {
private final WritableScope writableWorker;
public WriteThroughScope(@NotNull JetScope outerScope, @NotNull WritableScope scope) {
super(outerScope);
public WriteThroughScope(@NotNull JetScope outerScope, @NotNull WritableScope scope, @NotNull ErrorHandler errorHandler) {
super(outerScope, errorHandler);
this.writableWorker = scope;
}
......
......@@ -47,6 +47,11 @@ public class JavaClassMembersScope implements JetScope {
return null;
}
@Override
public DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis() {
throw new UnsupportedOperationException();
}
@Override
public ClassifierDescriptor getClassifier(@NotNull String name) {
ClassifierDescriptor classifierDescriptor = classifiers.get(name);
......
......@@ -32,6 +32,7 @@ public class JavaDescriptorResolver {
protected final Map<String, ClassDescriptor> classDescriptorCache = new HashMap<String, ClassDescriptor>();
protected final Map<PsiTypeParameter, TypeParameterDescriptor> typeParameterDescriptorCache = Maps.newHashMap();
protected final Map<PsiMethod, FunctionDescriptor> methodDescriptorCache = Maps.newHashMap();
protected final Map<String, NamespaceDescriptor> namespaceDescriptorCache = new HashMap<String, NamespaceDescriptor>();
protected final JavaPsiFacade javaFacade;
protected final GlobalSearchScope javaSearchScope;
......@@ -140,6 +141,7 @@ public class JavaDescriptorResolver {
typeParameter.getName(),
typeParameter.getIndex()
);
typeParameterDescriptorCache.put(typeParameter, typeParameterDescriptor);
PsiClassType[] referencedTypes = typeParameter.getExtendsList().getReferencedTypes();
if (referencedTypes.length == 0){
typeParameterDescriptor.addUpperBound(JetStandardClasses.getNullableAnyType());
......@@ -160,7 +162,7 @@ public class JavaDescriptorResolver {
TypeParameterDescriptor typeParameterDescriptor = typeParameterDescriptorCache.get(psiTypeParameter);
if (typeParameterDescriptor == null) {
typeParameterDescriptor = createJavaTypeParameterDescriptor(JAVA_ROOT, psiTypeParameter);
typeParameterDescriptorCache.put(psiTypeParameter, typeParameterDescriptor);
// Tis is done inside the method: typeParameterDescriptorCache.put(psiTypeParameter, typeParameterDescriptor);
}
return typeParameterDescriptor;
}
......@@ -247,28 +249,34 @@ public class JavaDescriptorResolver {
WritableFunctionGroup writableFunctionGroup = new WritableFunctionGroup(methodName);
final Collection<HierarchicalMethodSignature> signatures = psiClass.getVisibleSignatures();
for (HierarchicalMethodSignature signature: signatures) {
final PsiMethod method = signature.getMethod();
PsiMethod method = signature.getMethod();
if (method.hasModifierProperty(PsiModifier.STATIC) != staticMembers) {
continue;
}
if (!methodName.equals(method.getName())) {
continue;
}
final PsiParameter[] parameters = method.getParameterList().getParameters();
FunctionDescriptor functionDescriptor = methodDescriptorCache.get(method);
if (functionDescriptor != null) {
writableFunctionGroup.addFunction(functionDescriptor);
continue;
}
FunctionDescriptorImpl functionDescriptor = new FunctionDescriptorImpl(
PsiParameter[] parameters = method.getParameterList().getParameters();
FunctionDescriptorImpl functionDescriptorImpl = new FunctionDescriptorImpl(
JavaDescriptorResolver.JAVA_ROOT,
Collections.<Annotation>emptyList(), // TODO
methodName
);
functionDescriptor.initialize(
functionDescriptorImpl.initialize(
null,
resolveTypeParameters(method.getTypeParameters()),
semanticServices.getDescriptorResolver().resolveParameterDescriptors(functionDescriptor, parameters),
semanticServices.getDescriptorResolver().resolveParameterDescriptors(functionDescriptorImpl, parameters),
semanticServices.getTypeTransformer().transformToType(method.getReturnType())
);
semanticServices.getTrace().recordDeclarationResolution(method, functionDescriptor);
writableFunctionGroup.addFunction(functionDescriptor);
semanticServices.getTrace().recordDeclarationResolution(method, functionDescriptorImpl);
writableFunctionGroup.addFunction(functionDescriptorImpl);
methodDescriptorCache.put(method, functionDescriptorImpl);
}
return writableFunctionGroup;
}
......
......@@ -59,6 +59,11 @@ public class ErrorUtils {
return null; // TODO : review
}
@Override
public DeclarationDescriptor getDeclarationDescriptorForUnqualifiedThis() {
return ERROR_CLASS; // TODO : review
}
};
private static final FunctionGroup ERROR_FUNCTION_GROUP = new FunctionGroup() {
......
package org.jetbrains.jet.lang.types;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
......@@ -465,21 +466,32 @@ public class JetTypeInferrer {
if (resolutionResult.isSuccess()) {
final FunctionDescriptor functionDescriptor = resolutionResult.getFunctionDescriptor();
List<TypeParameterDescriptor> typeParameters = functionDescriptor.getOriginal().getTypeParameters();
for (int i = 0, typeParametersSize = typeParameters.size(); i < typeParametersSize; i++) {
TypeParameterDescriptor typeParameterDescriptor = typeParameters.get(i);
final JetType typeArgument = typeArguments.get(i);
if (!semanticServices.getTypeChecker().isSubtypeOf(typeArgument, typeParameterDescriptor.getBoundsAsType())) {
trace.getErrorHandler().genericError(jetTypeArguments.get(i).getNode(), "Bound of the type parameter " + DescriptorRenderer.TEXT.render(typeParameterDescriptor) + " is not respected by the type " + typeArgument);
}
}
checkGenericBoundsInAFunctionCall(jetTypeArguments, typeArguments, functionDescriptor);
return functionDescriptor.getUnsubstitutedReturnType();
}
}
return null;
}
private void checkGenericBoundsInAFunctionCall(List<JetTypeProjection> jetTypeArguments, List<JetType> typeArguments, FunctionDescriptor functionDescriptor) {
Map<TypeConstructor, TypeProjection> context = Maps.newHashMap();
List<TypeParameterDescriptor> typeParameters = functionDescriptor.getOriginal().getTypeParameters();
for (int i = 0, typeParametersSize = typeParameters.size(); i < typeParametersSize; i++) {
TypeParameterDescriptor typeParameter = typeParameters.get(i);
JetType typeArgument = typeArguments.get(i);
context.put(typeParameter.getTypeConstructor(), new TypeProjection(typeArgument));
}
TypeSubstitutor substitutor = TypeSubstitutor.create(context);
for (int i = 0, typeParametersSize = typeParameters.size(); i < typeParametersSize; i++) {
TypeParameterDescriptor typeParameterDescriptor = typeParameters.get(i);
JetType typeArgument = typeArguments.get(i);
JetTypeReference typeReference = jetTypeArguments.get(i).getTypeReference();
assert typeReference != null;
classDescriptorResolver.checkBounds(typeReference, typeArgument, typeParameterDescriptor, substitutor);
}
}
@Nullable
public JetType checkConstructorCall(JetScope scope, @NotNull JetTypeReference typeReference, @NotNull JetCall call) {
JetTypeElement typeElement = typeReference.getTypeElement();
......@@ -891,7 +903,8 @@ public class JetTypeInferrer {
trace.getErrorHandler().genericWarning(expression.getOperationSign().getNode(), "No cast needed, use ':' instead");
}
else {
trace.getErrorHandler().genericError(expression.getOperationSign().getNode(), "This cast can never succeed");
// See JET-58 Make 'as never succeeds' a warning, or even never check for Java (external) types
trace.getErrorHandler().genericWarning(expression.getOperationSign().getNode(), "This cast can never succeed");
}
}
else {
......@@ -920,27 +933,34 @@ public class JetTypeInferrer {
if (labelName != null) {
Collection<DeclarationDescriptor> declarationsByLabel = scope.getDeclarationsByLabel(labelName);
int size = declarationsByLabel.size();
final JetSimpleNameExpression targetLabel = expression.getTargetLabel();
assert targetLabel != null;
if (size == 1) {
DeclarationDescriptor declarationDescriptor = declarationsByLabel.iterator().next();
if (declarationDescriptor instanceof ClassDescriptor) {
ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor;
thisType = classDescriptor.getDefaultType();
trace.recordReferenceResolution(targetLabel, classDescriptor);
trace.recordReferenceResolution(expression.getThisReference(), classDescriptor);
}
else {
throw new UnsupportedOperationException(); // TODO
}
}
else if (size == 0) {
trace.getErrorHandler().unresolvedReference(expression.getTargetLabel());
trace.getErrorHandler().unresolvedReference(targetLabel);
}
else {
JetSimpleNameExpression labelElement = expression.getTargetLabel();
assert labelElement != null;
trace.getErrorHandler().genericError(labelElement.getNode(), "Ambiguous label");
trace.getErrorHandler().genericError(targetLabel.getNode(), "Ambiguous label");
}
}
else {
thisType = scope.getThisType();
DeclarationDescriptor declarationDescriptorForUnqualifiedThis = scope.getDeclarationDescriptorForUnqualifiedThis();
if (declarationDescriptorForUnqualifiedThis != null) {
trace.recordReferenceResolution(expression.getThisReference(), declarationDescriptorForUnqualifiedThis);
}
}
if (thisType != null) {
......@@ -975,6 +995,9 @@ public class JetTypeInferrer {
} else {
result = thisType;
}
if (result != null) {
trace.recordExpressionType(expression.getThisReference(), result);
}
}
}
}
......
......@@ -2,6 +2,9 @@ import java.*
import util.*
import <error>utils</error>.*
import java.io.PrintStream
import java.lang.Comparable as Com
val l : List<in Int> = new ArrayList<Int>()
fun test(l : java.util.List<Int>) {
......@@ -22,4 +25,28 @@ fun test(l : java.util.List<Int>) {
Collections.singleton<Int><error>(1.0)</error>
<error>new List<Int></error>
val o = "sdf" <warning>as</warning> Object
try {
// ...
}
catch(e: Exception) {
System.out?.println(e.getMessage())
}
new PrintStream("sdf")
val c : Com<Int>? = null
c : java.lang.Comparable<Int>?
// Collections.sort<Integer>(new ArrayList<Integer>())
new xxx.<error>Class</error>()
}
namespace xxx {
import java.lang.Class;
}
import java.*
import util.*
import java.io.*
fun takeFirst(expr: StringBuilder): Char {
val c = expr.charAt(0)
expr.deleteCharAt(0)
return c
}
fun evaluateArg(expr: AbstractStringBuilder, numbers: ArrayList<Int>): Int {
if (expr.length() == 0) throw new Exception("Syntax error: Character expected");
val c = takeFirst<error>(expr)</error>
if (c <error>>=</error> '0' && c <error><=</error> '9') {
val n = c - '0'
if (!numbers.contains(n)) throw new Exception("You used incorrect number: " + n)
numbers.remove(n)
return n \
}
throw new Exception("Syntax error: Unrecognized character " + c)
}
fun evaluateAdd(expr: StringBuilder, numbers: ArrayList<Int>): Int {
val lhs = evaluateArg(expr, numbers)
if (expr.length() > 0) {
}
return lhs
}
fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int {
val lhs = evaluateAdd(expr, numbers)
if (expr.length() > 0) {
val c = expr.charAt(0)
expr.deleteCharAt(0)
}
return lhs
}
fun main(args: Array<String>) {
System.out?.println("24 game")
val numbers = new ArrayList<Int>(4)
val rnd = new Random();
val prompt = new StringBuilder()
for(val i in 0..3) {
val n = rnd.nextInt(9) + 1
numbers.add(n)
if (i > 0) prompt.append(" ");
prompt.append(n)
}
System.out?.println("Your numbers: " + prompt)
System.out?.println("Enter your expression:")
val reader = new BufferedReader(new InputStreamReader(System.`in`))
val expr = new StringBuilder(reader.readLine())
try {
val result = evaluate(expr, numbers)
if (result != 24)
System.out?.println("Sorry, that's " + result)
else
System.out?.println("You won!");
}
catch(e: Throwable) {
System.out?.println(e.getMessage())
}
}
......@@ -38,6 +38,7 @@ JetFile: AnnotatedExpressions.jet
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
\ No newline at end of file
......@@ -385,28 +385,33 @@ JetFile: Labels.jet
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace('\n ')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
LABEL_QUALIFIER
LABEL_REFERENCE
PsiElement(AT)('@')
PsiWhiteSpace('\n ')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
LABEL_QUALIFIER
LABEL_REFERENCE
PsiElement(LABEL_IDENTIFIER)('@a')
PsiWhiteSpace('\n ')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
LABEL_QUALIFIER
LABEL_REFERENCE
PsiElement(ATAT)('@@')
PsiWhiteSpace('\n\n ')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(LT)('<')
TYPE_REFERENCE
USER_TYPE
......@@ -415,7 +420,8 @@ JetFile: Labels.jet
PsiElement(GT)('>')
PsiWhiteSpace('\n ')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
LABEL_QUALIFIER
LABEL_REFERENCE
PsiElement(AT)('@')
......@@ -427,7 +433,8 @@ JetFile: Labels.jet
PsiElement(GT)('>')
PsiWhiteSpace('\n ')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
LABEL_QUALIFIER
LABEL_REFERENCE
PsiElement(LABEL_IDENTIFIER)('@a')
......@@ -439,7 +446,8 @@ JetFile: Labels.jet
PsiElement(GT)('>')
PsiWhiteSpace('\n ')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
LABEL_QUALIFIER
LABEL_REFERENCE
PsiElement(ATAT)('@@')
......
......@@ -768,7 +768,8 @@ JetFile: Properties.jet
BINARY_EXPRESSION
DOT_QUALIFIED_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('size')
......
......@@ -261,7 +261,8 @@ JetFile: SimpleExpressions.jet
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(COMMA)(',')
PsiWhiteSpace('\n ')
VALUE_PARAMETER
......@@ -277,7 +278,8 @@ JetFile: SimpleExpressions.jet
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(LT)('<')
TYPE_REFERENCE
USER_TYPE
......
......@@ -180,7 +180,8 @@ JetFile: BinaryTree.jet
BINARY_EXPRESSION
DOT_QUALIFIED_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('compare')
......@@ -286,7 +287,8 @@ JetFile: BinaryTree.jet
PsiElement(LPAR)('(')
VALUE_ARGUMENT
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
VALUE_ARGUMENT
......@@ -1897,7 +1899,8 @@ JetFile: BinaryTree.jet
PsiElement(IDENTIFIER)('BinaryTree')
PsiElement(DOT)('.')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('version')
......@@ -2475,7 +2478,8 @@ JetFile: BinaryTree.jet
PsiElement(IDENTIFIER)('BinaryTree')
PsiElement(DOT)('.')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('version')
......@@ -2520,7 +2524,8 @@ JetFile: BinaryTree.jet
PsiElement(IDENTIFIER)('BinaryTree')
PsiElement(DOT)('.')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('version')
......
......@@ -499,7 +499,8 @@ JetFile: BitArith.jet
BINARY_EXPRESSION
BINARY_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(IDENTIFIER)('and')
......
......@@ -363,7 +363,8 @@ JetFile: PolymorphicClassObjects.jet
PsiWhiteSpace(' ')
LOOP_RANGE
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BODY
......
......@@ -388,7 +388,8 @@ JetFile: UnionFind.jet
BINARY_EXPRESSION
BINARY_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(PERC)('%')
......
......@@ -350,7 +350,8 @@ JetFile: ArrayList.jet
PsiElement(IDENTIFIER)('ArrayList')
PsiElement(DOT)('.')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(DOT)('.')
CALL_EXPRESSION
REFERENCE_EXPRESSION
......
......@@ -44,7 +44,8 @@ JetFile: HashMap.jet
PsiElement(LPAR)('(')
BINARY_WITH_TYPE
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(as)('as')
......@@ -138,7 +139,8 @@ JetFile: HashMap.jet
PsiElement(LPAR)('(')
BINARY_WITH_TYPE
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(as)('as')
......@@ -373,7 +375,8 @@ JetFile: HashMap.jet
PsiElement(LPAR)('(')
VALUE_ARGUMENT
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n')
CLASS
......
......@@ -202,7 +202,8 @@ JetFile: List.jet
PsiWhiteSpace(' ')
BINARY_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(EQEQ)('==')
......@@ -256,7 +257,8 @@ JetFile: List.jet
PsiElement(IDENTIFIER)('List')
PsiElement(DOT)('.')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace('\n\n ')
PROPERTY
MODIFIER_LIST
......
......@@ -138,7 +138,8 @@ JetFile: BinaryHeap.jet
BINARY_EXPRESSION
DOT_QUALIFIED_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('compare')
......@@ -152,7 +153,8 @@ JetFile: BinaryHeap.jet
BINARY_EXPRESSION
DOT_QUALIFIED_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('data')
......@@ -254,7 +256,8 @@ JetFile: BinaryHeap.jet
BINARY_EXPRESSION
DOT_QUALIFIED_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('compare')
......@@ -268,7 +271,8 @@ JetFile: BinaryHeap.jet
BINARY_EXPRESSION
DOT_QUALIFIED_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('data')
......@@ -297,7 +301,8 @@ JetFile: BinaryHeap.jet
BINARY_EXPRESSION
DOT_QUALIFIED_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('data')
......@@ -343,7 +348,8 @@ JetFile: BinaryHeap.jet
BINARY_EXPRESSION
DOT_QUALIFIED_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('comparator')
......@@ -393,7 +399,8 @@ JetFile: BinaryHeap.jet
CONDITION
DOT_QUALIFIED_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('isEmpty')
......@@ -942,7 +949,8 @@ JetFile: BinaryHeap.jet
PsiElement(LPAR)('(')
BINARY_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(MINUS)('-')
......@@ -979,7 +987,8 @@ JetFile: BinaryHeap.jet
BINARY_EXPRESSION
BINARY_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(MUL)('*')
......@@ -1015,7 +1024,8 @@ JetFile: BinaryHeap.jet
BINARY_EXPRESSION
BINARY_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(MUL)('*')
......@@ -1067,7 +1077,8 @@ JetFile: BinaryHeap.jet
INDICES
PsiElement(LBRACKET)('[')
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(RBRACKET)(']')
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
......@@ -1117,7 +1128,8 @@ JetFile: BinaryHeap.jet
PsiElement(LPAR)('(')
BINARY_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(LT)('<')
......@@ -1137,7 +1149,8 @@ JetFile: BinaryHeap.jet
PsiElement(LPAR)('(')
BINARY_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(GTEQ)('>=')
......@@ -1209,7 +1222,8 @@ JetFile: BinaryHeap.jet
PsiElement(LPAR)('(')
VALUE_ARGUMENT
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
VALUE_ARGUMENT
......@@ -1274,7 +1288,8 @@ JetFile: BinaryHeap.jet
PsiWhiteSpace(' ')
ARRAY_ACCESS_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
INDICES
PsiElement(LBRACKET)('[')
REFERENCE_EXPRESSION
......@@ -1284,7 +1299,8 @@ JetFile: BinaryHeap.jet
BINARY_EXPRESSION
ARRAY_ACCESS_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
INDICES
PsiElement(LBRACKET)('[')
REFERENCE_EXPRESSION
......@@ -1296,7 +1312,8 @@ JetFile: BinaryHeap.jet
PsiWhiteSpace(' ')
ARRAY_ACCESS_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
INDICES
PsiElement(LBRACKET)('[')
REFERENCE_EXPRESSION
......@@ -1306,7 +1323,8 @@ JetFile: BinaryHeap.jet
BINARY_EXPRESSION
ARRAY_ACCESS_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
INDICES
PsiElement(LBRACKET)('[')
REFERENCE_EXPRESSION
......@@ -1356,7 +1374,8 @@ JetFile: BinaryHeap.jet
BINARY_EXPRESSION
DOT_QUALIFIED_EXPRESSION
THIS_EXPRESSION
PsiElement(this)('this')
REFERENCE_EXPRESSION
PsiElement(this)('this')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('size')
......
namespace qualified_this {
~qtA~class A(val a:Int) {
~qtB~class B() {
val x = `qtB`this`qtB`@B
val y = `qtA`this`qtA`@A
val z = `qtB`this
~xx~val Int.xx = `xx`this : Int
~xx()~fun Int.xx() {
`xx()`this : Int
}
}
}
}
class A<~T~T, ~E~E> {
val a : `T`T
val x : A<`T`T, `E`E>
......@@ -8,4 +24,5 @@ class A<~T~T, ~E~E> {
~X.E~class E {}
}
}
\ No newline at end of file
}
......@@ -178,6 +178,7 @@ public class JetTestUtils {
public Collection<JetDiagnostic> getDiagnostics() {
throw new UnsupportedOperationException(); // TODO
}
};
}
};
......
......@@ -277,6 +277,8 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
assertSubtype("Derived_T<Int>", "Base_T<in Int>");
assertSubtype("MDerived_T<Int>", "Base_T<in Int>");
assertSubtype("ArrayList<Int>", "List<in Int>");
assertSubtype("Integer", "java.lang.Comparable<Integer>?");
}
public void testNullable() throws Exception {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册