Merge remote branch 'origin/master'
This commit is contained in:
@@ -229,7 +229,7 @@ public abstract class CodegenContext {
|
||||
pd.getName() + "$bridge$" + accessors.size()
|
||||
);
|
||||
JetType receiverType = pd.getReceiverParameter().exists() ? pd.getReceiverParameter().getType() : null;
|
||||
myAccessor.setType(pd.getInType(), pd.getOutType(), Collections.<TypeParameterDescriptor>emptyList(), pd.getExpectedThisObject(), receiverType);
|
||||
myAccessor.setType(pd.getOutType(), Collections.<TypeParameterDescriptor>emptyList(), pd.getExpectedThisObject(), receiverType);
|
||||
|
||||
PropertyGetterDescriptor pgd = new PropertyGetterDescriptor(
|
||||
myAccessor, Collections.<AnnotationDescriptor>emptyList(), myAccessor.getModality(),
|
||||
|
||||
@@ -672,9 +672,11 @@ public class JetTypeMapper {
|
||||
|
||||
@Nullable
|
||||
public JvmMethodSignature mapSetterSignature(PropertyDescriptor descriptor, OwnerKind kind) {
|
||||
JetType inType = descriptor.getInType();
|
||||
if(inType == null)
|
||||
if (!descriptor.isVar()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
JetType outType = descriptor.getOutType();
|
||||
|
||||
String name = PropertyCodegen.setterName(descriptor.getName());
|
||||
ArrayList<Type> params = new ArrayList<Type>();
|
||||
@@ -694,7 +696,7 @@ public class JetTypeMapper {
|
||||
}
|
||||
}
|
||||
|
||||
params.add(mapType(inType));
|
||||
params.add(mapType(outType));
|
||||
|
||||
// TODO: proper generic signature
|
||||
return new JvmMethodSignature(new Method(name, Type.VOID_TYPE, params.toArray(new Type[params.size()])), null, null, null, null);
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaClassDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.types.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeProjection;
|
||||
@@ -206,12 +207,12 @@ public class NamespaceCodegen {
|
||||
|
||||
public static String getJVMClassName(String fqName) {
|
||||
if (fqName.length() == 0) {
|
||||
return "namespace";
|
||||
return JvmAbi.PACKAGE_CLASS;
|
||||
}
|
||||
|
||||
String name = fqName.replace('.', '/') + "/namespace";
|
||||
String name = fqName.replace('.', '/') + "/" + JvmAbi.PACKAGE_CLASS;
|
||||
if(name.startsWith("<java_root>")) {
|
||||
name = name.substring("<java_root>".length() + 1, name.length() - ".namespace".length());
|
||||
name = name.substring("<java_root>".length() + 1, name.length() - 1 - JvmAbi.PACKAGE_CLASS.length());
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.jetbrains.jet.codegen.ClassFileFactory;
|
||||
import org.jetbrains.jet.codegen.GeneratedClassLoader;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.plugin.JetMainDetector;
|
||||
|
||||
import java.io.*;
|
||||
@@ -210,7 +211,7 @@ public class CompileEnvironment {
|
||||
Class moduleSetBuilderClass = loader.loadClass("kotlin.modules.ModuleSetBuilder");
|
||||
final IModuleSetBuilder moduleSetBuilder = (IModuleSetBuilder) moduleSetBuilderClass.newInstance();
|
||||
|
||||
Class namespaceClass = loader.loadClass("namespace");
|
||||
Class namespaceClass = loader.loadClass(JvmAbi.PACKAGE_CLASS);
|
||||
final Field[] fields = namespaceClass.getDeclaredFields();
|
||||
boolean modulesDefined = false;
|
||||
for (Field field : fields) {
|
||||
@@ -343,7 +344,7 @@ public class CompileEnvironment {
|
||||
String mainClass = null;
|
||||
for (JetFile file : session.getSourceFileNamespaces()) {
|
||||
if (JetMainDetector.hasMain(file.getDeclarations())) {
|
||||
mainClass = JetPsiUtil.getFQName(file) + ".namespace";
|
||||
mainClass = JetPsiUtil.getFQName(file) + "." + JvmAbi.PACKAGE_CLASS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -743,7 +743,7 @@ public class JavaDescriptorResolver {
|
||||
i,
|
||||
Collections.<AnnotationDescriptor>emptyList(), // TODO
|
||||
name,
|
||||
null, // TODO : review
|
||||
false,
|
||||
changeNullable ? TypeUtils.makeNullableAsSpecified(outType, nullable) : outType,
|
||||
hasDefaultValue,
|
||||
varargElementType
|
||||
@@ -767,7 +767,6 @@ public class JavaDescriptorResolver {
|
||||
null,
|
||||
DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration),
|
||||
field.getName(),
|
||||
isFinal ? null : type,
|
||||
type);
|
||||
semanticServices.getTrace().record(BindingContext.VARIABLE, field, propertyDescriptor);
|
||||
fieldDescriptorCache.put(field, propertyDescriptor);
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ public class JavaPackageScope extends JetScopeImpl {
|
||||
}
|
||||
|
||||
// TODO: what is GlobalSearchScope
|
||||
PsiClass psiClass = semanticServices.getDescriptorResolver().javaFacade.findClass(getQualifiedName("namespace"));
|
||||
PsiClass psiClass = semanticServices.getDescriptorResolver().javaFacade.findClass(getQualifiedName(JvmAbi.PACKAGE_CLASS));
|
||||
if (psiClass == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class JavaPackageScope extends JetScopeImpl {
|
||||
}
|
||||
|
||||
for (PsiClass psiClass : javaPackage.getClasses()) {
|
||||
if (isKotlinNamespace && "namespace".equals(psiClass.getName())) continue;
|
||||
if (isKotlinNamespace && JvmAbi.PACKAGE_CLASS.equals(psiClass.getName())) continue;
|
||||
|
||||
// If this is a Kotlin class, we have already taken it through a containing namespace descriptor
|
||||
ClassDescriptor kotlinClassDescriptor = semanticServices.getKotlinClassDescriptor(psiClass.getQualifiedName());
|
||||
|
||||
@@ -8,4 +8,5 @@ public class JvmAbi {
|
||||
public static final String DEFAULT_PARAMS_IMPL_SUFFIX = "$default";
|
||||
public static final String GETTER_PREFIX = "get";
|
||||
public static final String SETTER_PREFIX = "set";
|
||||
public static final String PACKAGE_CLASS = "namespace";
|
||||
}
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class FunctionDescriptorUtil {
|
||||
substitutedDescriptor,
|
||||
unsubstitutedValueParameter,
|
||||
unsubstitutedValueParameter.getAnnotations(),
|
||||
unsubstitutedValueParameter.getInType() == null ? null : substitutedType,
|
||||
unsubstitutedValueParameter.isVar(),
|
||||
substitutedType,
|
||||
substituteVarargElementType
|
||||
));
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ public class LocalVariableDescriptor extends VariableDescriptorImpl {
|
||||
@NotNull String name,
|
||||
@Nullable JetType type,
|
||||
boolean mutable) {
|
||||
super(containingDeclaration, annotations, name, mutable ? type : null, type);
|
||||
super(containingDeclaration, annotations, name, type);
|
||||
isVar = mutable;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,23 +71,20 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull ReceiverDescriptor expectedThisObject,
|
||||
@NotNull String name,
|
||||
@Nullable JetType inType,
|
||||
@NotNull JetType outType
|
||||
) {
|
||||
this(containingDeclaration, annotations, modality, visibility, isVar, name);
|
||||
setType(inType, outType, Collections.<TypeParameterDescriptor>emptyList(), expectedThisObject, receiverType);
|
||||
setType(outType, Collections.<TypeParameterDescriptor>emptyList(), expectedThisObject, receiverType);
|
||||
}
|
||||
|
||||
public void setType(@Nullable JetType inType, @NotNull JetType outType, @NotNull List<TypeParameterDescriptor> typeParameters, @NotNull ReceiverDescriptor expectedThisObject, @Nullable JetType receiverType) {
|
||||
public void setType(@NotNull JetType outType, @NotNull List<TypeParameterDescriptor> typeParameters, @NotNull ReceiverDescriptor expectedThisObject, @Nullable JetType receiverType) {
|
||||
ReceiverDescriptor receiver = receiverType == null
|
||||
? NO_RECEIVER
|
||||
: new ExtensionReceiver(this, receiverType);
|
||||
setType(inType, outType, typeParameters, expectedThisObject, receiver);
|
||||
setType(outType, typeParameters, expectedThisObject, receiver);
|
||||
}
|
||||
|
||||
public void setType(@Nullable JetType inType, @NotNull JetType outType, @NotNull List<TypeParameterDescriptor> typeParameters, @NotNull ReceiverDescriptor expectedThisObject, @NotNull ReceiverDescriptor receiver) {
|
||||
assert !isVar || inType != null;
|
||||
setInType(inType);
|
||||
public void setType(@NotNull JetType outType, @NotNull List<TypeParameterDescriptor> typeParameters, @NotNull ReceiverDescriptor expectedThisObject, @NotNull ReceiverDescriptor receiver) {
|
||||
setOutType(outType);
|
||||
|
||||
this.typeParemeters = typeParameters;
|
||||
@@ -123,17 +120,6 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
return getOutType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetType getInType() {
|
||||
return super.getInType();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JetType getOutType() {
|
||||
return super.getOutType();
|
||||
}
|
||||
|
||||
public boolean isVar() {
|
||||
return isVar;
|
||||
}
|
||||
@@ -170,11 +156,9 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
List<TypeParameterDescriptor> substitutedTypeParameters = Lists.newArrayList();
|
||||
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(getTypeParameters(), originalSubstitutor, substitutedDescriptor, substitutedTypeParameters);
|
||||
|
||||
JetType originalInType = getInType();
|
||||
JetType inType = originalInType == null ? null : substitutor.substitute(originalInType, Variance.IN_VARIANCE);
|
||||
JetType originalOutType = getOutType();
|
||||
JetType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE);
|
||||
if (inType == null && outType == null) {
|
||||
if (outType == null) {
|
||||
return null; // TODO : tell the user that the property was projected out
|
||||
}
|
||||
|
||||
@@ -196,7 +180,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
substitutedReceiverType = null;
|
||||
}
|
||||
|
||||
substitutedDescriptor.setType(inType, outType, substitutedTypeParameters, substitutedExpectedThisObject, substitutedReceiverType);
|
||||
substitutedDescriptor.setType(outType, substitutedTypeParameters, substitutedExpectedThisObject, substitutedReceiverType);
|
||||
|
||||
return substitutedDescriptor;
|
||||
}
|
||||
@@ -231,7 +215,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
DescriptorUtils.convertModality(modality, makeNonAbstract), visibility, isVar,
|
||||
getName());
|
||||
|
||||
propertyDescriptor.setType(getInType(), getOutType(), DescriptorUtils.copyTypeParameters(propertyDescriptor, getTypeParameters()), expectedThisObject, receiver.exists() ? receiver.getType() : null);
|
||||
propertyDescriptor.setType(getOutType(), DescriptorUtils.copyTypeParameters(propertyDescriptor, getTypeParameters()), expectedThisObject, receiver.exists() ? receiver.getType() : null);
|
||||
|
||||
PropertyGetterDescriptor newGetter = getter == null ? null : new PropertyGetterDescriptor(
|
||||
propertyDescriptor, Lists.newArrayList(getter.getAnnotations()),
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ public class PropertySetterDescriptor extends PropertyAccessorDescriptor {
|
||||
|
||||
public void initializeDefault() {
|
||||
assert parameter == null;
|
||||
parameter = new ValueParameterDescriptorImpl(this, 0, Collections.<AnnotationDescriptor>emptyList(), "<>", null, getCorrespondingProperty().getReturnType(), false, null);
|
||||
parameter = new ValueParameterDescriptorImpl(this, 0, Collections.<AnnotationDescriptor>emptyList(), "<>", false, getCorrespondingProperty().getReturnType(), false, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+7
-12
@@ -24,42 +24,37 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
int index,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name,
|
||||
@Nullable JetType inType,
|
||||
boolean isVar,
|
||||
@NotNull JetType outType,
|
||||
boolean hasDefaultValue,
|
||||
@Nullable JetType varargElementType) {
|
||||
super(containingDeclaration, annotations, name, inType, outType);
|
||||
super(containingDeclaration, annotations, name, outType);
|
||||
this.original = this;
|
||||
this.index = index;
|
||||
this.hasDefaultValue = hasDefaultValue;
|
||||
this.varargElementType = varargElementType;
|
||||
this.isVar = inType != null;
|
||||
this.isVar = isVar;
|
||||
}
|
||||
|
||||
public ValueParameterDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull ValueParameterDescriptor original,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@Nullable JetType inType,
|
||||
boolean isVar,
|
||||
@NotNull JetType outType,
|
||||
@Nullable JetType varargElementType
|
||||
) {
|
||||
super(containingDeclaration, annotations, original.getName(), inType, outType);
|
||||
super(containingDeclaration, annotations, original.getName(), outType);
|
||||
this.original = original;
|
||||
this.index = original.getIndex();
|
||||
this.hasDefaultValue = original.hasDefaultValue();
|
||||
this.varargElementType = varargElementType;
|
||||
this.isVar = inType != null;
|
||||
this.isVar = isVar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(@NotNull JetType type) {
|
||||
assert getOutType() == null;
|
||||
setOutType(type);
|
||||
if (isVar) {
|
||||
assert getInType() == null;
|
||||
setInType(type);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,6 +102,6 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
@NotNull
|
||||
@Override
|
||||
public ValueParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner) {
|
||||
return new ValueParameterDescriptorImpl(newOwner, index, Lists.newArrayList(getAnnotations()), getName(), getInType(), getOutType(), hasDefaultValue, varargElementType);
|
||||
return new ValueParameterDescriptorImpl(newOwner, index, Lists.newArrayList(getAnnotations()), getName(), isVar, getOutType(), hasDefaultValue, varargElementType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,18 +9,9 @@ import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
* @author abreslav
|
||||
*/
|
||||
public interface VariableDescriptor extends CallableDescriptor {
|
||||
/**
|
||||
* @return <code>null</code> for write-only variables (i.e. properties), variable value type otherwise
|
||||
*/
|
||||
@Nullable
|
||||
@NotNull
|
||||
JetType getOutType();
|
||||
|
||||
/**
|
||||
* @return <code>null</code> for read-only variables (i.e. val's etc), or the type expected on assignment type otherwise
|
||||
*/
|
||||
@Nullable
|
||||
JetType getInType();
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"NullableProblems"})
|
||||
@NotNull
|
||||
|
||||
-5
@@ -34,11 +34,6 @@ public class VariableDescriptorBoundToReceiver implements VariableDescriptor {
|
||||
return variableDescriptor.getOutType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetType getInType() {
|
||||
return variableDescriptor.getInType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DeclarationDescriptor getContainingDeclaration() {
|
||||
|
||||
+2
-14
@@ -14,19 +14,15 @@ import java.util.Set;
|
||||
* @author abreslav
|
||||
*/
|
||||
public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl implements VariableDescriptor {
|
||||
private JetType inType;
|
||||
private JetType outType;
|
||||
|
||||
public VariableDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name,
|
||||
@Nullable JetType inType,
|
||||
@Nullable JetType outType) {
|
||||
@NotNull JetType outType) {
|
||||
super(containingDeclaration, annotations, name);
|
||||
assert (inType != null) || (outType != null);
|
||||
|
||||
this.inType = inType;
|
||||
this.outType = outType;
|
||||
}
|
||||
|
||||
@@ -44,16 +40,8 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl i
|
||||
return outType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetType getInType() {
|
||||
return inType;
|
||||
}
|
||||
|
||||
protected void setInType(JetType inType) {
|
||||
this.inType = inType;
|
||||
}
|
||||
|
||||
protected void setOutType(JetType outType) {
|
||||
assert this.outType == null;
|
||||
this.outType = outType;
|
||||
}
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ public class DescriptorResolver {
|
||||
index,
|
||||
annotationResolver.createAnnotationStubs(valueParameter.getModifierList()),
|
||||
JetPsiUtil.safeName(valueParameter.getName()),
|
||||
valueParameter.isMutable() ? variableType : null,
|
||||
valueParameter.isMutable(),
|
||||
variableType,
|
||||
valueParameter.getDefaultValue() != null,
|
||||
varargElementType
|
||||
@@ -479,7 +479,7 @@ public class DescriptorResolver {
|
||||
JetPsiUtil.safeName(objectDeclaration.getName())
|
||||
);
|
||||
|
||||
propertyDescriptor.setType(null, classDescriptor.getDefaultType(), Collections.<TypeParameterDescriptor>emptyList(), DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration), ReceiverDescriptor.NO_RECEIVER);
|
||||
propertyDescriptor.setType(classDescriptor.getDefaultType(), Collections.<TypeParameterDescriptor>emptyList(), DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration), ReceiverDescriptor.NO_RECEIVER);
|
||||
propertyDescriptor.initialize(null, null);
|
||||
|
||||
JetObjectDeclarationName nameAsDeclaration = objectDeclaration.getNameAsDeclaration();
|
||||
@@ -553,8 +553,7 @@ public class DescriptorResolver {
|
||||
|
||||
JetType type = getVariableType(propertyScope, property, DataFlowInfo.EMPTY, true);
|
||||
|
||||
JetType inType = isVar ? type : null;
|
||||
propertyDescriptor.setType(inType, type, typeParameterDescriptors, DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration), receiverDescriptor);
|
||||
propertyDescriptor.setType(type, typeParameterDescriptors, DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration), receiverDescriptor);
|
||||
|
||||
PropertyGetterDescriptor getter = resolvePropertyGetterDescriptor(scopeWithTypeParameters, property, propertyDescriptor);
|
||||
PropertySetterDescriptor setter = resolvePropertySetterDescriptor(scopeWithTypeParameters, property, propertyDescriptor);
|
||||
@@ -686,11 +685,11 @@ public class DescriptorResolver {
|
||||
JetType type;
|
||||
JetTypeReference typeReference = parameter.getTypeReference();
|
||||
if (typeReference == null) {
|
||||
type = propertyDescriptor.getInType(); // TODO : this maybe unknown at this point
|
||||
type = propertyDescriptor.getOutType(); // TODO : this maybe unknown at this point
|
||||
}
|
||||
else {
|
||||
type = typeResolver.resolveType(scope, typeReference);
|
||||
JetType inType = propertyDescriptor.getInType();
|
||||
JetType inType = propertyDescriptor.getOutType();
|
||||
if (inType != null) {
|
||||
if (!TypeUtils.equalTypes(type, inType)) {
|
||||
// trace.getErrorHandler().genericError(typeReference.getNode(), "Setter parameter type must be equal to the type of the property, i.e. " + inType);
|
||||
@@ -842,8 +841,7 @@ public class DescriptorResolver {
|
||||
isMutable,
|
||||
name == null ? "<no name>" : name
|
||||
);
|
||||
JetType inType = isMutable ? type : null;
|
||||
propertyDescriptor.setType(inType, type, Collections.<TypeParameterDescriptor>emptyList(), DescriptorUtils.getExpectedThisObjectIfNeeded(classDescriptor), ReceiverDescriptor.NO_RECEIVER);
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(), DescriptorUtils.getExpectedThisObjectIfNeeded(classDescriptor), ReceiverDescriptor.NO_RECEIVER);
|
||||
|
||||
PropertyGetterDescriptor getter = createDefaultGetter(propertyDescriptor);
|
||||
PropertySetterDescriptor setter = createDefaultSetter(propertyDescriptor);
|
||||
|
||||
@@ -116,7 +116,7 @@ public class ErrorUtils {
|
||||
null,
|
||||
ReceiverDescriptor.NO_RECEIVER,
|
||||
"<ERROR PROPERTY>",
|
||||
ERROR_PROPERTY_TYPE, ERROR_PROPERTY_TYPE);
|
||||
ERROR_PROPERTY_TYPE);
|
||||
private static final Set<VariableDescriptor> ERROR_PROPERTY_GROUP = Collections.singleton(ERROR_PROPERTY);
|
||||
|
||||
private static FunctionDescriptor createErrorFunction(List<TypeParameterDescriptor> typeParameters, List<JetType> positionedValueArgumentTypes) {
|
||||
@@ -165,7 +165,7 @@ public class ErrorUtils {
|
||||
i,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
"<ERROR VALUE_PARAMETER>",
|
||||
ERROR_PARAMETER_TYPE,
|
||||
true,
|
||||
ERROR_PARAMETER_TYPE,
|
||||
false,
|
||||
null));
|
||||
|
||||
@@ -385,7 +385,7 @@ public class JetStandardClasses {
|
||||
List<ValueParameterDescriptor> valueParameters = Lists.newArrayList();
|
||||
for (int i = first; i <= last; i++) {
|
||||
JetType parameterType = arguments.get(i).getType();
|
||||
ValueParameterDescriptorImpl valueParameterDescriptor = new ValueParameterDescriptorImpl(functionDescriptor, i, Collections.<AnnotationDescriptor>emptyList(), "p" + i, null, parameterType, false, null);
|
||||
ValueParameterDescriptorImpl valueParameterDescriptor = new ValueParameterDescriptorImpl(functionDescriptor, i, Collections.<AnnotationDescriptor>emptyList(), "p" + i, false, parameterType, false, null);
|
||||
valueParameters.add(valueParameterDescriptor);
|
||||
}
|
||||
return valueParameters;
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (functionTypeExpected && !hasDeclaredValueParameters && expectedValueParameters.size() == 1) {
|
||||
ValueParameterDescriptor valueParameterDescriptor = expectedValueParameters.get(0);
|
||||
ValueParameterDescriptor it = new ValueParameterDescriptorImpl(
|
||||
functionDescriptor, 0, Collections.<AnnotationDescriptor>emptyList(), "it", valueParameterDescriptor.getInType(), valueParameterDescriptor.getOutType(), valueParameterDescriptor.hasDefaultValue(), valueParameterDescriptor.getVarargElementType()
|
||||
functionDescriptor, 0, Collections.<AnnotationDescriptor>emptyList(), "it", false, valueParameterDescriptor.getOutType(), valueParameterDescriptor.hasDefaultValue(), valueParameterDescriptor.getVarargElementType()
|
||||
);
|
||||
valueParameterDescriptors.add(it);
|
||||
context.trace.record(AUTO_CREATED_IT, it);
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.jetbrains.jet.lang.diagnostics.Renderer;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -135,7 +136,7 @@ public class DescriptorRenderer implements Renderer {
|
||||
|
||||
@Override
|
||||
public Void visitVariableDescriptor(VariableDescriptor descriptor, StringBuilder builder) {
|
||||
String typeString = renderPropertyPrefixAndComputeTypeString(builder, Collections.<TypeParameterDescriptor>emptyList(), ReceiverDescriptor.NO_RECEIVER, descriptor.getOutType(), descriptor.getInType());
|
||||
String typeString = renderPropertyPrefixAndComputeTypeString(builder, Collections.<TypeParameterDescriptor>emptyList(), ReceiverDescriptor.NO_RECEIVER, descriptor.getOutType());
|
||||
renderName(descriptor, builder);
|
||||
builder.append(" : ").append(escape(typeString));
|
||||
return super.visitVariableDescriptor(descriptor, builder);
|
||||
@@ -145,26 +146,16 @@ public class DescriptorRenderer implements Renderer {
|
||||
@NotNull StringBuilder builder,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull ReceiverDescriptor receiver,
|
||||
@Nullable JetType outType,
|
||||
@Nullable JetType inType) {
|
||||
@Nullable JetType outType) {
|
||||
String typeString = lt() + "no type>";
|
||||
if (inType != null && outType != null) {
|
||||
if (outType != null) {
|
||||
builder.append(renderKeyword("var")).append(" ");
|
||||
if (inType.equals(outType)) {
|
||||
typeString = renderType(outType);
|
||||
}
|
||||
else {
|
||||
typeString = "<" + renderKeyword("in") + ": " + renderType(inType) + " " + renderKeyword("out") + ": " + renderType(outType) + ">";
|
||||
}
|
||||
typeString = renderType(outType);
|
||||
}
|
||||
else if (outType != null) {
|
||||
builder.append(renderKeyword("val")).append(" ");
|
||||
typeString = renderType(outType);
|
||||
}
|
||||
else if (inType != null) {
|
||||
builder.append(lt()).append("write-only> ");
|
||||
typeString = renderType(inType);
|
||||
}
|
||||
|
||||
renderTypeParameters(typeParameters, builder);
|
||||
|
||||
@@ -181,8 +172,7 @@ public class DescriptorRenderer implements Renderer {
|
||||
String typeString = renderPropertyPrefixAndComputeTypeString(
|
||||
builder, descriptor.getTypeParameters(),
|
||||
descriptor.getReceiverParameter(),
|
||||
descriptor.getOutType(),
|
||||
descriptor.getInType());
|
||||
descriptor.getOutType());
|
||||
renderName(descriptor, builder);
|
||||
builder.append(" : ").append(escape(typeString));
|
||||
return null;
|
||||
@@ -268,7 +258,7 @@ public class DescriptorRenderer implements Renderer {
|
||||
|
||||
@Override
|
||||
public Void visitNamespaceDescriptor(NamespaceDescriptor namespaceDescriptor, StringBuilder builder) {
|
||||
builder.append(renderKeyword("namespace")).append(" ");
|
||||
builder.append(renderKeyword(JetTokens.NAMESPACE_KEYWORD.getValue())).append(" ");
|
||||
renderName(namespaceDescriptor, builder);
|
||||
return super.visitNamespaceDescriptor(namespaceDescriptor, builder);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ var x : Int = 1 + x
|
||||
|
||||
val xx : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1 + x<!>
|
||||
get() : Int = 1
|
||||
<!VAL_WITH_SETTER!>set(value : Long) {}<!>
|
||||
<!VAL_WITH_SETTER!>set(value : <!WRONG_SETTER_PARAMETER_TYPE!>Long<!>) {}<!>
|
||||
|
||||
val p : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1<!>
|
||||
get() = 1
|
||||
@@ -26,4 +26,4 @@ class Test() {
|
||||
a = <!NO_BACKING_FIELD_CUSTOM_ACCESSORS!>$b<!>
|
||||
}
|
||||
public val <!PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE!>i<!> = 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.plugin.JetFileType;
|
||||
|
||||
import java.util.*;
|
||||
@@ -72,7 +73,7 @@ public class JavaElementFinder extends PsiElementFinder {
|
||||
for (JetFile file : filesInScope) {
|
||||
final String packageName = JetPsiUtil.getFQName(file);
|
||||
if (packageName != null && qualifiedName.startsWith(packageName)) {
|
||||
if (qualifiedName.equals(fqn(packageName, "namespace"))) {
|
||||
if (qualifiedName.equals(fqn(packageName, JvmAbi.PACKAGE_CLASS))) {
|
||||
answer.add(new JetLightClass(psiManager, file, qualifiedName));
|
||||
}
|
||||
else {
|
||||
@@ -122,7 +123,7 @@ public class JavaElementFinder extends PsiElementFinder {
|
||||
String packageFQN = psiPackage.getQualifiedName();
|
||||
for (JetFile psiFile : collectProjectJetFiles(project, GlobalSearchScope.allScope(project))) {
|
||||
if (packageFQN.equals(JetPsiUtil.getFQName(psiFile))) {
|
||||
answer.add("namespace");
|
||||
answer.add(JvmAbi.PACKAGE_CLASS);
|
||||
for (JetDeclaration declaration : psiFile.getDeclarations()) {
|
||||
if (declaration instanceof JetClassOrObject) {
|
||||
answer.add(getLocalName(declaration));
|
||||
@@ -160,7 +161,7 @@ public class JavaElementFinder extends PsiElementFinder {
|
||||
String packageFQN = psiPackage.getQualifiedName();
|
||||
for (JetFile file : filesInScope) {
|
||||
if (packageFQN.equals(JetPsiUtil.getFQName(file))) {
|
||||
answer.add(new JetLightClass(psiManager, file, fqn(packageFQN, "namespace")));
|
||||
answer.add(new JetLightClass(psiManager, file, fqn(packageFQN, JvmAbi.PACKAGE_CLASS)));
|
||||
for (JetDeclaration declaration : file.getDeclarations()) {
|
||||
if (declaration instanceof JetClassOrObject) {
|
||||
answer.add(new JetLightClass(psiManager, file, fqn(packageFQN, getLocalName(declaration))));
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.codegen.ClassBuilder;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.FieldVisitor;
|
||||
@@ -52,7 +53,7 @@ public class StubClassBuilder extends ClassBuilder {
|
||||
v = new StubBuildingVisitor<Object>(null, EMPTY_STRATEGY, parent, access);
|
||||
|
||||
super.defineClass(origin, version, access, name, signature, superName, interfaces);
|
||||
if (name.equals("namespace") || name.endsWith("/namespace")) {
|
||||
if (name.equals(JvmAbi.PACKAGE_CLASS) || name.endsWith("/" + JvmAbi.PACKAGE_CLASS)) {
|
||||
isNamespace = true;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.plugin.JetMainDetector;
|
||||
|
||||
/**
|
||||
@@ -44,7 +45,7 @@ public class JetRunConfigurationProducer extends RuntimeConfigurationProducer im
|
||||
if (JetMainDetector.hasMain(jetFile.getDeclarations())) {
|
||||
mySourceElement = jetFile;
|
||||
String fqName = JetPsiUtil.getFQName(jetFile);
|
||||
String className = fqName.length() == 0 ? "namespace" : fqName + ".namespace";
|
||||
String className = fqName.length() == 0 ? JvmAbi.PACKAGE_CLASS : fqName + "." + JvmAbi.PACKAGE_CLASS;
|
||||
return createConfigurationByQName(module, configurationContext, className);
|
||||
}
|
||||
}
|
||||
@@ -59,7 +60,7 @@ public class JetRunConfigurationProducer extends RuntimeConfigurationProducer im
|
||||
RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(module.getProject(), context);
|
||||
JetRunConfiguration configuration = (JetRunConfiguration) settings.getConfiguration();
|
||||
configuration.setModule(module);
|
||||
configuration.setName(StringUtil.trimEnd(fqName, ".namespace"));
|
||||
configuration.setName(StringUtil.trimEnd(fqName, "." + JvmAbi.PACKAGE_CLASS));
|
||||
configuration.MAIN_CLASS_NAME = fqName;
|
||||
return settings;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
val xx : Int = <error>1 + x</error>
|
||||
get() : Int = 1
|
||||
<error>set(value : Long) {}</error>
|
||||
<error>set(value : <error>Long</error>) {}</error>
|
||||
|
||||
val p : Int = <error>1</error>
|
||||
get() = 1
|
||||
@@ -25,4 +25,4 @@ class Test() {
|
||||
<error>$b</error> = $a
|
||||
a = <error>$b</error>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user