diff --git a/compiler/backend/src/org/jetbrains/jet/cli/jvm/compiler/TipsManager.java b/compiler/backend/src/org/jetbrains/jet/cli/jvm/compiler/TipsManager.java index 3e7972e5e28..cc341a24cb7 100644 --- a/compiler/backend/src/org/jetbrains/jet/cli/jvm/compiler/TipsManager.java +++ b/compiler/backend/src/org/jetbrains/jet/cli/jvm/compiler/TipsManager.java @@ -135,13 +135,6 @@ public final class TipsManager { return false; } - if (descriptor instanceof NamespaceDescriptor) { - NamespaceDescriptor namespaceDescriptor = (NamespaceDescriptor) descriptor; - if (namespaceDescriptor.getName().isEmpty()) { - return false; - } - } - return true; } }); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java index 968bf25822f..ad98e4f268d 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java @@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.lang.resolve.calls.*; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; import org.objectweb.asm.*; @@ -101,8 +102,8 @@ public abstract class AnnotationCodegen { continue; } - String keyName = entry.getKey().getName(); - genAnnotationValueArgument(annotationVisitor, valueArgument, keyName); + Name keyName = entry.getKey().getName(); + genAnnotationValueArgument(annotationVisitor, valueArgument, keyName.getName()); } } @@ -139,7 +140,7 @@ public abstract class AnnotationCodegen { if(call != null) { if(call.getResultingDescriptor() instanceof PropertyDescriptor) { PropertyDescriptor descriptor = (PropertyDescriptor)call.getResultingDescriptor(); - annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor.getReturnType(), MapTypeMode.VALUE).getDescriptor(), descriptor.getName()); + annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor.getReturnType(), MapTypeMode.VALUE).getDescriptor(), descriptor.getName().getName()); return; } } @@ -154,7 +155,7 @@ public abstract class AnnotationCodegen { String value = null; if (annotations != null) { for (AnnotationDescriptor annotation : annotations) { - if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName())) { + if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().getName())) { value = (String) annotation.getValueArguments().get(0).getValue(); break; } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ClosureAnnotator.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClosureAnnotator.java index f4d66ff2b28..3fc2e420152 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ClosureAnnotator.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ClosureAnnotator.java @@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.java.JvmAbi; import org.jetbrains.jet.lang.resolve.java.JvmClassName; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.types.lang.JetStandardClasses; @@ -74,7 +75,7 @@ public class ClosureAnnotator { funDescriptor, Collections.emptyList(), // TODO: internal name used as identifier - name.getInternalName()); // TODO: + Name.identifier(name.getInternalName())); // TODO: classDescriptor.initialize( false, Collections.emptyList(), @@ -126,8 +127,7 @@ public class ClosureAnnotator { } public boolean hasThis0(ClassDescriptor classDescriptor) { - if(DescriptorUtils.isClassObject(classDescriptor)) - return false; + if (DescriptorUtils.isClassObject(classDescriptor)) { return false; } ClassDescriptor other = enclosing.get(classDescriptor); return other != null; @@ -208,11 +208,10 @@ public class ClosureAnnotator { recordEnclosing(classDescriptor); classStack.push(classDescriptor); String base = nameStack.peek(); - if(classDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) { - nameStack.push(base.isEmpty() ? classDescriptor.getName() : base + '/' + classDescriptor.getName()); + if (classDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) { + nameStack.push(base.isEmpty() ? classDescriptor.getName().getName() : base + '/' + classDescriptor.getName()); } - else - nameStack.push(base + '$' + classDescriptor.getName()); + else { nameStack.push(base + '$' + classDescriptor.getName()); } super.visitObjectDeclaration(declaration); nameStack.pop(); classStack.pop(); @@ -227,11 +226,10 @@ public class ClosureAnnotator { recordEnclosing(classDescriptor); classStack.push(classDescriptor); String base = nameStack.peek(); - if(classDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) { - nameStack.push(base.isEmpty() ? classDescriptor.getName() : base + '/' + classDescriptor.getName()); + if (classDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) { + nameStack.push(base.isEmpty() ? classDescriptor.getName().getName() : base + '/' + classDescriptor.getName()); } - else - nameStack.push(base + '$' + classDescriptor.getName()); + else { nameStack.push(base + '$' + classDescriptor.getName()); } super.visitClass(klass); nameStack.pop(); classStack.pop(); @@ -298,10 +296,8 @@ public class ClosureAnnotator { } else if (containingDeclaration instanceof NamespaceDescriptor) { String peek = nameStack.peek(); - if(peek.isEmpty()) - peek = "namespace"; - else - peek = peek + "/namespace"; + if (peek.isEmpty()) { peek = "namespace"; } + else { peek = peek + "/namespace"; } nameStack.push(peek + '$' + function.getName()); super.visitNamedFunction(function); nameStack.pop(); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java index 9b140171dcf..18edab436a2 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java @@ -32,6 +32,7 @@ import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.lang.resolve.java.JvmClassName; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.lang.JetStandardClasses; @@ -99,7 +100,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen { } public JvmMethodSignature invokeSignature(FunctionDescriptor fd) { - return state.getInjector().getJetTypeMapper().mapSignature("invoke", fd); + return state.getInjector().getJetTypeMapper().mapSignature(Name.identifier("invoke"), fd); } public GeneratedAnonymousClassDescriptor gen(JetExpression fun) { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenContext.java b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenContext.java index c6c77561c07..d387a0f20b4 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenContext.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenContext.java @@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.resolve.DescriptorUtils; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; import org.objectweb.asm.Type; import org.objectweb.asm.commons.InstructionAdapter; @@ -97,8 +98,7 @@ public abstract class CodegenContext { } protected StackValue getOuterExpression(@Nullable StackValue prefix) { - if(outerExpression == null) - throw new UnsupportedOperationException(); + if (outerExpression == null) { throw new UnsupportedOperationException(); } outerWasUsed = outerExpression.type; return prefix != null ? StackValue.composed(prefix, outerExpression) : outerExpression; @@ -173,8 +173,7 @@ public abstract class CodegenContext { final ObjectOrClosureCodegen top = closure; if (top != null) { final StackValue answer = top.lookupInContext(d, result); - if (answer != null) - return result == null ? answer : StackValue.composed(result, answer); + if (answer != null) { return result == null ? answer : StackValue.composed(result, answer); } StackValue outer = getOuterExpression(null); result = result == null ? outer : StackValue.composed(result, outer); @@ -185,15 +184,13 @@ public abstract class CodegenContext { public Type enclosingClassType(JetTypeMapper typeMapper) { CodegenContext cur = getParentContext(); - while(cur != null && !(cur.getContextDescriptor() instanceof ClassDescriptor)) - cur = cur.getParentContext(); + while (cur != null && !(cur.getContextDescriptor() instanceof ClassDescriptor)) { cur = cur.getParentContext(); } return cur == null ? null : typeMapper.mapType(((ClassDescriptor) cur.getContextDescriptor()).getDefaultType(), MapTypeMode.IMPL); } public int getTypeInfoConstantIndex(JetType type) { - if(parentContext != STATIC) - return parentContext.getTypeInfoConstantIndex(type); + if (parentContext != STATIC) { return parentContext.getTypeInfoConstantIndex(type); } if(typeInfoConstants == null) { typeInfoConstants = new LinkedHashMap(); @@ -215,13 +212,12 @@ public abstract class CodegenContext { } descriptor = descriptor.getOriginal(); DeclarationDescriptor accessor = accessors.get(descriptor); - if(accessor != null) - return accessor; + if (accessor != null) { return accessor; } if(descriptor instanceof SimpleFunctionDescriptor) { SimpleFunctionDescriptorImpl myAccessor = new SimpleFunctionDescriptorImpl(contextType, Collections.emptyList(), - descriptor.getName() + "$bridge$" + accessors.size(), + Name.identifier(descriptor.getName() + "$bridge$" + accessors.size()), // TODO: evil CallableMemberDescriptor.Kind.DECLARATION); FunctionDescriptor fd = (SimpleFunctionDescriptor) descriptor; myAccessor.initialize(fd.getReceiverParameter().exists() ? fd.getReceiverParameter().getType() : null, @@ -242,7 +238,7 @@ public abstract class CodegenContext { pd.getVisibility(), pd.isVar(), pd.isObjectDeclaration(), - pd.getName() + "$bridge$" + accessors.size(), + Name.identifier(pd.getName() + "$bridge$" + accessors.size()), // TODO: evil CallableMemberDescriptor.Kind.DECLARATION ); JetType receiverType = pd.getReceiverParameter().exists() ? pd.getReceiverParameter().getType() : null; diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java index 5188c638b1f..caaf653c39b 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java @@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContextUtils; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.lang.JetStandardClasses; import org.jetbrains.jet.lang.types.JetType; @@ -48,7 +49,7 @@ public class CodegenUtil { SimpleFunctionDescriptorImpl invokeDescriptor = new SimpleFunctionDescriptorImpl( fd.getExpectedThisObject().exists() ? JetStandardClasses.getReceiverFunction(arity) : JetStandardClasses.getFunction(arity), Collections.emptyList(), - "invoke", + Name.identifier("invoke"), CallableMemberDescriptor.Kind.DECLARATION); invokeDescriptor.initialize(fd.getReceiverParameter().exists() ? fd.getReceiverParameter().getType() : null, diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 1f64f19a5d3..fb370463936 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -1010,7 +1010,7 @@ public class ExpressionCodegen extends JetVisitor { if(classDescriptor.getKind() == ClassKind.ENUM_ENTRY) { ClassDescriptor containing = (ClassDescriptor) classDescriptor.getContainingDeclaration().getContainingDeclaration(); Type type = typeMapper.mapType(containing.getDefaultType(), MapTypeMode.VALUE); - StackValue.field(type, type.getInternalName(), classDescriptor.getName(), true).put(TYPE_OBJECT, v); + StackValue.field(type, type.getInternalName(), classDescriptor.getName().getName(), true).put(TYPE_OBJECT, v); // todo: for now we don't generate classes for enum entries, so we need this hack type = typeMapper.mapType(classDescriptor.getDefaultType(), MapTypeMode.VALUE); @@ -1148,7 +1148,7 @@ public class ExpressionCodegen extends JetVisitor { isInterface = CodegenUtil.isInterface(containingDeclaration); } - v.visitMethodInsn(isStatic ? Opcodes.INVOKESTATIC : isInterface ? Opcodes.INVOKEINTERFACE : Opcodes.INVOKEVIRTUAL, owner, functionDescriptor.getName(), typeMapper.mapSignature(functionDescriptor.getName(),functionDescriptor).getAsmMethod().getDescriptor()); + v.visitMethodInsn(isStatic ? Opcodes.INVOKESTATIC : isInterface ? Opcodes.INVOKEINTERFACE : Opcodes.INVOKEVIRTUAL, owner, functionDescriptor.getName().getName(), typeMapper.mapSignature(functionDescriptor.getName(),functionDescriptor).getAsmMethod().getDescriptor()); StackValue.onStack(asmType(functionDescriptor.getReturnType())).coerce(type, v); } @@ -1238,7 +1238,7 @@ public class ExpressionCodegen extends JetVisitor { ownerParam = callableMethod.getDefaultImplParam(); } - return StackValue.property(propertyDescriptor.getName(), owner, ownerParam, asmType(propertyDescriptor.getType()), isStatic, isInterface, isSuper, getter, setter, invokeOpcode); + return StackValue.property(propertyDescriptor.getName().getName(), owner, ownerParam, asmType(propertyDescriptor.getType()), isStatic, isInterface, isSuper, getter, setter, invokeOpcode); } @Override @@ -1951,7 +1951,7 @@ public class ExpressionCodegen extends JetVisitor { if (!(descriptor instanceof ClassDescriptor)) { return false; } - String className = descriptor.getName(); + String className = descriptor.getName().getName(); return className.equals("Int") || className.equals("Long") || className.equals("Short") || className.equals("Byte") || className.equals("Char") || className.equals("Float") || className.equals("Double"); @@ -1961,7 +1961,7 @@ public class ExpressionCodegen extends JetVisitor { if (!(descriptor instanceof ClassDescriptor)) { return false; } - String className = descriptor.getName(); + String className = descriptor.getName().getName(); return className.equals(name); } @@ -2113,7 +2113,7 @@ public class ExpressionCodegen extends JetVisitor { } else { DeclarationDescriptor cls = op.getContainingDeclaration(); - if (isNumberPrimitive(cls) || !(op.getName().equals("inc") || op.getName().equals("dec")) ) { + if (isNumberPrimitive(cls) || !(op.getName().getName().equals("inc") || op.getName().getName().equals("dec")) ) { return invokeOperation(expression, (FunctionDescriptor) op, (CallableMethod) callable); } else { @@ -2165,14 +2165,14 @@ public class ExpressionCodegen extends JetVisitor { if (op instanceof FunctionDescriptor) { final Type asmType = expressionType(expression); DeclarationDescriptor cls = op.getContainingDeclaration(); - if (op.getName().equals("inc") || op.getName().equals("dec")) { + if (op.getName().getName().equals("inc") || op.getName().getName().equals("dec")) { if (isNumberPrimitive(cls)) { receiver.put(receiver.type, v); JetExpression operand = expression.getBaseExpression(); if (operand instanceof JetReferenceExpression) { final int index = indexOfLocal((JetReferenceExpression) operand); if (index >= 0 && isIntPrimitive(asmType)) { - int increment = op.getName().equals("inc") ? 1 : -1; + int increment = op.getName().getName().equals("inc") ? 1 : -1; return StackValue.postIncrement(index, increment); } } @@ -2230,7 +2230,7 @@ public class ExpressionCodegen extends JetVisitor { } private void generateIncrement(DeclarationDescriptor op, Type asmType, JetExpression operand, StackValue receiver) { - int increment = op.getName().equals("inc") ? 1 : -1; + int increment = op.getName().getName().equals("inc") ? 1 : -1; if (operand instanceof JetReferenceExpression) { final int index = indexOfLocal((JetReferenceExpression) operand); if (index >= 0 && isIntPrimitive(asmType)) { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java index f5259ba60f1..4a3d6788223 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java @@ -159,7 +159,7 @@ public class FunctionCodegen { for(int i = 0; i != paramDescrs.size(); ++i) { JetValueParameterAnnotationWriter av = JetValueParameterAnnotationWriter.visitParameterAnnotation(mv, i + start); ValueParameterDescriptor parameterDescriptor = paramDescrs.get(i); - av.writeName(parameterDescriptor.getName()); + av.writeName(parameterDescriptor.getName().getName()); av.writeHasDefaultValue(parameterDescriptor.declaresDefaultValue()); av.writeNullable(parameterDescriptor.getType().isNullable()); if (jvmSignature.getKotlinParameterTypes() != null && jvmSignature.getKotlinParameterTypes().get(i) != null) { @@ -261,7 +261,7 @@ public class FunctionCodegen { for (ValueParameterDescriptor parameter : paramDescrs) { Type type = state.getInjector().getJetTypeMapper().mapType(parameter.getType(), MapTypeMode.VALUE); // TODO: specify signature - mv.visitLocalVariable(parameter.getName(), type.getDescriptor(), null, methodBegin, methodEnd, k); + mv.visitLocalVariable(parameter.getName().getName(), type.getDescriptor(), null, methodBegin, methodEnd, k); k += type.getSize(); } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java index eeab96e059c..6a1b9ce6331 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java @@ -150,7 +150,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { // TODO: cache internal names String outerClassInernalName = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName(); String innerClassInternalName = typeMapper.mapType(innerClass.getDefaultType(), MapTypeMode.IMPL).getInternalName(); - v.visitInnerClass(innerClassInternalName, outerClassInernalName, innerClass.getName(), innerClassAccess); + v.visitInnerClass(innerClassInternalName, outerClassInernalName, innerClass.getName().getName(), innerClassAccess); } if (descriptor.getClassObjectDescriptor() != null) { @@ -298,7 +298,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { Method originalMethod = typeMapper.mapSignature(original.getName(), original).getAsmMethod(); Type[] argTypes = method.getArgumentTypes(); - MethodVisitor mv = v.newMethod(null, ACC_PUBLIC| ACC_BRIDGE| ACC_FINAL, bridge.getName(), method.getDescriptor(), null, null); + MethodVisitor mv = v.newMethod(null, ACC_PUBLIC| ACC_BRIDGE| ACC_FINAL, bridge.getName().getName(), method.getDescriptor(), null, null); if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) { StubCodegen.generateStubCode(mv); } @@ -340,7 +340,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { iv.load(0, JetTypeMapper.TYPE_OBJECT); if(original.getVisibility() == Visibilities.PRIVATE) - iv.getfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), original.getName(), originalMethod.getReturnType().getDescriptor()); + iv.getfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), original.getName().getName(), originalMethod.getReturnType().getDescriptor()); else iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor()); @@ -373,7 +373,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { reg += argType.getSize(); } if(original.getVisibility() == Visibilities.PRIVATE && original.getModality() == Modality.FINAL) - iv.putfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), original.getName(), originalMethod.getArgumentTypes()[0].getDescriptor()); + iv.putfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), original.getName().getName(), originalMethod.getArgumentTypes()[0].getDescriptor()); else iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor()); @@ -484,7 +484,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { if(closure != null) { if(closure.captureThis != null) { if(!hasThis0) - consArgTypes.add(insert, new JvmMethodParameterSignature(Type.getObjectType(context.getThisDescriptor().getName()), "", JvmMethodParameterKind.THIS0)); + consArgTypes.add(insert, new JvmMethodParameterSignature(Type.getObjectType(context.getThisDescriptor().getName().getName()), "", JvmMethodParameterKind.THIS0)); insert++; } else { @@ -553,7 +553,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { for (ValueParameterDescriptor valueParameter : constructorDescriptor.getValueParameters()) { JetValueParameterAnnotationWriter jetValueParameterAnnotation = JetValueParameterAnnotationWriter.visitParameterAnnotation(mv, i); - jetValueParameterAnnotation.writeName(valueParameter.getName()); + jetValueParameterAnnotation.writeName(valueParameter.getName().getName()); jetValueParameterAnnotation.writeHasDefaultValue(valueParameter.declaresDefaultValue()); jetValueParameterAnnotation.writeType(constructorMethod.getKotlinParameterType(i)); jetValueParameterAnnotation.visitEnd(); @@ -689,7 +689,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { Type type = typeMapper.mapType(descriptor.getType(), MapTypeMode.VALUE); iv.load(0, classType); iv.load(frameMap.getIndex(descriptor), type); - iv.putfield(classname, descriptor.getName(), type.getDescriptor()); + iv.putfield(classname, descriptor.getName().getName(), type.getDescriptor()); } curParam++; } @@ -954,7 +954,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { codegen.gen(initializer, type); // @todo write directly to the field. Fix test excloset.jet::test6 String owner = typeMapper.getOwner(propertyDescriptor, OwnerKind.IMPLEMENTATION); - StackValue.property(propertyDescriptor.getName(), owner, owner, + StackValue.property(propertyDescriptor.getName().getName(), owner, owner, typeMapper.mapType(propertyDescriptor.getType(), MapTypeMode.VALUE), false, false, false, null, null, 0).store(iv); } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java b/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java index 2b16080e66d..6f72224dd55 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java @@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.java.*; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import org.jetbrains.jet.lang.types.*; import org.jetbrains.jet.lang.types.lang.JetStandardClasses; @@ -222,10 +223,6 @@ public class JetTypeMapper { r.append("$"); } } - if (ns.getName().length() == 0) { - throw new IllegalStateException( - "name must not be empty at this point when generating for " + namespace); - } r.append(ns.getName()); } @@ -316,14 +313,17 @@ public class JetTypeMapper { } DeclarationDescriptor container = descriptor.getContainingDeclaration(); - String name = descriptor.getName(); + Name name = descriptor.getName(); if(JetPsiUtil.NO_NAME_PROVIDED.equals(name)) { return closureAnnotator .classNameForAnonymousClass((JetElement) BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor)) .getInternalName(); } - if(name.contains("/")) - return name; + + // This is the worst code in the project + if(name.getName().contains("/")) + return name.getName(); + if (container != null) { String baseName = getFQName(container); if (!baseName.isEmpty()) { @@ -331,7 +331,7 @@ public class JetTypeMapper { } } - return name; + return name.getName(); } private static ClassDescriptor getContainingClass(DeclarationDescriptor descriptor) { @@ -667,7 +667,7 @@ public class JetTypeMapper { mapReturnType(f.getReturnType(), signatureVisitor); signatureVisitor.writeReturnTypeEnd(); } - return signatureVisitor.makeJvmMethodSignature(f.getName()); + return signatureVisitor.makeJvmMethodSignature(f.getName().getName()); } @@ -684,7 +684,7 @@ public class JetTypeMapper { } private void writeFormalTypeParameter(TypeParameterDescriptor typeParameterDescriptor, BothSignatureWriter signatureVisitor) { - signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName(), typeParameterDescriptor.getVariance(), typeParameterDescriptor.isReified()); + signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName().getName(), typeParameterDescriptor.getVariance(), typeParameterDescriptor.isReified()); classBound: { @@ -725,7 +725,7 @@ public class JetTypeMapper { } - public JvmMethodSignature mapSignature(String name, FunctionDescriptor f) { + public JvmMethodSignature mapSignature(Name name, FunctionDescriptor f) { final ReceiverDescriptor receiver = f.getReceiverParameter(); BothSignatureWriter signatureWriter = new BothSignatureWriter(BothSignatureWriter.Mode.METHOD, false); @@ -752,7 +752,7 @@ public class JetTypeMapper { mapReturnType(f.getReturnType(), signatureWriter); signatureWriter.writeReturnTypeEnd(); - return signatureWriter.makeJvmMethodSignature(name); + return signatureWriter.makeJvmMethodSignature(name.getName()); } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java index d9d4e9f9373..b5c4c42ef0f 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java @@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; import org.jetbrains.jet.lang.resolve.java.JvmAbi; import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames; +import org.jetbrains.jet.lang.resolve.name.Name; import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; @@ -206,7 +207,7 @@ public class PropertyCodegen { } else { iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? Opcodes.GETSTATIC : Opcodes.GETFIELD, - state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind), propertyDescriptor.getName(), + state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind), propertyDescriptor.getName().getName(), type.getDescriptor()); } iv.areturn(type); @@ -296,7 +297,7 @@ public class PropertyCodegen { else { iv.load(paramCode, type); iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? Opcodes.PUTSTATIC : Opcodes.PUTFIELD, - state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind), propertyDescriptor.getName(), + state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind), propertyDescriptor.getName().getName(), type.getDescriptor()); } @@ -307,12 +308,12 @@ public class PropertyCodegen { } } - public static String getterName(String propertyName) { - return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName); + public static String getterName(Name propertyName) { + return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.getName()); } - public static String setterName(String propertyName) { - return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName); + public static String setterName(Name propertyName) { + return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.getName()); } public void genDelegate(PropertyDescriptor declaration, PropertyDescriptor overriddenDescriptor, StackValue field) { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java index 2ae51835a8f..349aceedb3b 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java @@ -27,6 +27,7 @@ import com.intellij.psi.search.ProjectScope; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.types.lang.JetStandardClasses; import org.jetbrains.jet.lang.types.lang.JetStandardLibrary; @@ -54,8 +55,8 @@ public class IntrinsicMethods { private static final IntrinsicMethod INC = new Increment(1); private static final IntrinsicMethod DEC = new Increment(-1); - private static final List PRIMITIVE_TYPES = ImmutableList.of("Boolean", "Byte", "Char", "Short", "Int", "Float", "Long", "Double"); - private static final List PRIMITIVE_NUMBER_TYPES = ImmutableList.of("Byte", "Char", "Short", "Int", "Float", "Long", "Double"); + private static final List PRIMITIVE_TYPES = ImmutableList.of(Name.identifier("Boolean"), Name.identifier("Byte"), Name.identifier("Char"), Name.identifier("Short"), Name.identifier("Int"), Name.identifier("Float"), Name.identifier("Long"), Name.identifier("Double")); + private static final List PRIMITIVE_NUMBER_TYPES = ImmutableList.of(Name.identifier("Byte"), Name.identifier("Char"), Name.identifier("Short"), Name.identifier("Int"), Name.identifier("Float"), Name.identifier("Long"), Name.identifier("Double")); public static final IntrinsicMethod ARRAY_SIZE = new ArraySize(); public static final IntrinsicMethod ARRAY_INDICES = new ArrayIndices(); public static final Equals EQUALS = new Equals(); @@ -91,69 +92,69 @@ public class IntrinsicMethods { namedMethods.put(KOTLIN_JAVA_CLASS_PROPERTY, new JavaClassProperty()); namedMethods.put(KOTLIN_ARRAYS_ARRAY, new JavaClassArray()); - List primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList(); - for (String method : primitiveCastMethods) { - declareIntrinsicFunction("Number", method, 0, NUMBER_CAST, true); - for (String type : PRIMITIVE_NUMBER_TYPES) { + ImmutableList primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList(); + for (Name method : primitiveCastMethods) { + declareIntrinsicFunction(Name.identifier("Number"), method, 0, NUMBER_CAST, true); + for (Name type : PRIMITIVE_NUMBER_TYPES) { declareIntrinsicFunction(type, method, 0, NUMBER_CAST, true); } } - for (String type : PRIMITIVE_NUMBER_TYPES) { - declareIntrinsicFunction(type, "plus", 0, UNARY_PLUS, false); - declareIntrinsicFunction(type, "minus", 0, UNARY_MINUS, false); - declareIntrinsicFunction(type, "inv", 0, INV, false); - declareIntrinsicFunction(type, "rangeTo", 1, UP_TO, false); - declareIntrinsicFunction(type, "upto", 1, UP_TO, false); - declareIntrinsicFunction(type, "downto", 1, DOWN_TO, false); - declareIntrinsicFunction(type, "inc", 0, INC, false); - declareIntrinsicFunction(type, "dec", 0, DEC, false); + for (Name type : PRIMITIVE_NUMBER_TYPES) { + declareIntrinsicFunction(type, Name.identifier("plus"), 0, UNARY_PLUS, false); + declareIntrinsicFunction(type, Name.identifier("minus"), 0, UNARY_MINUS, false); + declareIntrinsicFunction(type, Name.identifier("inv"), 0, INV, false); + declareIntrinsicFunction(type, Name.identifier("rangeTo"), 1, UP_TO, false); + declareIntrinsicFunction(type, Name.identifier("upto"), 1, UP_TO, false); + declareIntrinsicFunction(type, Name.identifier("downto"), 1, DOWN_TO, false); + declareIntrinsicFunction(type, Name.identifier("inc"), 0, INC, false); + declareIntrinsicFunction(type, Name.identifier("dec"), 0, DEC, false); } - declareBinaryOp("plus", Opcodes.IADD); - declareBinaryOp("minus", Opcodes.ISUB); - declareBinaryOp("times", Opcodes.IMUL); - declareBinaryOp("div", Opcodes.IDIV); - declareBinaryOp("mod", Opcodes.IREM); - declareBinaryOp("shl", Opcodes.ISHL); - declareBinaryOp("shr", Opcodes.ISHR); - declareBinaryOp("ushr", Opcodes.IUSHR); - declareBinaryOp("and", Opcodes.IAND); - declareBinaryOp("or", Opcodes.IOR); - declareBinaryOp("xor", Opcodes.IXOR); + declareBinaryOp(Name.identifier("plus"), Opcodes.IADD); + declareBinaryOp(Name.identifier("minus"), Opcodes.ISUB); + declareBinaryOp(Name.identifier("times"), Opcodes.IMUL); + declareBinaryOp(Name.identifier("div"), Opcodes.IDIV); + declareBinaryOp(Name.identifier("mod"), Opcodes.IREM); + declareBinaryOp(Name.identifier("shl"), Opcodes.ISHL); + declareBinaryOp(Name.identifier("shr"), Opcodes.ISHR); + declareBinaryOp(Name.identifier("ushr"), Opcodes.IUSHR); + declareBinaryOp(Name.identifier("and"), Opcodes.IAND); + declareBinaryOp(Name.identifier("or"), Opcodes.IOR); + declareBinaryOp(Name.identifier("xor"), Opcodes.IXOR); - declareIntrinsicFunction("Boolean", "not", 0, new Not(), true); + declareIntrinsicFunction(Name.identifier("Boolean"), Name.identifier("not"), 0, new Not(), true); - declareIntrinsicFunction("String", "plus", 1, new Concat(), true); - declareIntrinsicFunction("CharSequence", "get", 1, new StringGetChar(), true); - declareIntrinsicFunction("String", "get", 1, new StringGetChar(), true); + declareIntrinsicFunction(Name.identifier("String"), Name.identifier("plus"), 1, new Concat(), true); + declareIntrinsicFunction(Name.identifier("CharSequence"), Name.identifier("get"), 1, new StringGetChar(), true); + declareIntrinsicFunction(Name.identifier("String"), Name.identifier("get"), 1, new StringGetChar(), true); - declareOverload(myStdLib.getLibraryScope().getFunctions("toString"), 0, new ToString()); - declareOverload(myStdLib.getLibraryScope().getFunctions("equals"), 1, EQUALS); - declareOverload(myStdLib.getLibraryScope().getFunctions("identityEquals"), 1, IDENTITY_EQUALS); - declareOverload(myStdLib.getLibraryScope().getFunctions("plus"), 1, STRING_PLUS); - declareOverload(myStdLib.getLibraryScope().getFunctions("arrayOfNulls"), 1, new NewArray()); - declareOverload(myStdLib.getLibraryScope().getFunctions("sure"), 0, new Sure()); - declareOverload(myStdLib.getLibraryScope().getFunctions("synchronized"), 2, new StupidSync()); - declareOverload(myStdLib.getLibraryScope().getFunctions("iterator"), 0, new IteratorIterator()); + declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("toString")), 0, new ToString()); + declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("equals")), 1, EQUALS); + declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("identityEquals")), 1, IDENTITY_EQUALS); + declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("plus")), 1, STRING_PLUS); + declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("arrayOfNulls")), 1, new NewArray()); + declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("sure")), 0, new Sure()); + declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("synchronized")), 2, new StupidSync()); + declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("iterator")), 0, new IteratorIterator()); - declareIntrinsicFunction("ByteIterator", "next", 0, ITERATOR_NEXT, false); - declareIntrinsicFunction("ShortIterator", "next", 0, ITERATOR_NEXT, false); - declareIntrinsicFunction("IntIterator", "next", 0, ITERATOR_NEXT, false); - declareIntrinsicFunction("LongIterator", "next", 0, ITERATOR_NEXT, false); - declareIntrinsicFunction("CharIterator", "next", 0, ITERATOR_NEXT, false); - declareIntrinsicFunction("BooleanIterator", "next", 0, ITERATOR_NEXT, false); - declareIntrinsicFunction("FloatIterator", "next", 0, ITERATOR_NEXT, false); - declareIntrinsicFunction("DoubleIterator", "next", 0, ITERATOR_NEXT, false); + declareIntrinsicFunction(Name.identifier("ByteIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false); + declareIntrinsicFunction(Name.identifier("ShortIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false); + declareIntrinsicFunction(Name.identifier("IntIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false); + declareIntrinsicFunction(Name.identifier("LongIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false); + declareIntrinsicFunction(Name.identifier("CharIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false); + declareIntrinsicFunction(Name.identifier("BooleanIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false); + declareIntrinsicFunction(Name.identifier("FloatIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false); + declareIntrinsicFunction(Name.identifier("DoubleIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false); - for (String type : PRIMITIVE_TYPES) { - declareIntrinsicFunction(type, "compareTo", 1, new CompareTo(), false); + for (Name type : PRIMITIVE_TYPES) { + declareIntrinsicFunction(type, Name.identifier("compareTo"), 1, new CompareTo(), false); } // declareIntrinsicFunction("Any", "equals", 1, new Equals()); // declareIntrinsicStringMethods(); - declareIntrinsicProperty("CharSequence", "length", new StringLength()); - declareIntrinsicProperty("String", "length", new StringLength()); + declareIntrinsicProperty(Name.identifier("CharSequence"), Name.identifier("length"), new StringLength()); + declareIntrinsicProperty(Name.identifier("String"), Name.identifier("length"), new StringLength()); declareArrayMethods(); } @@ -164,24 +165,24 @@ public class IntrinsicMethods { declareArrayMethodsForPrimitive(jvmPrimitiveType); } - declareIntrinsicProperty("Array", "size", ARRAY_SIZE); - declareIntrinsicProperty("Array", "indices", ARRAY_INDICES); - declareIntrinsicFunction("Array", "set", 2, ARRAY_SET, true); - declareIntrinsicFunction("Array", "get", 1, ARRAY_GET, true); + declareIntrinsicProperty(Name.identifier("Array"), Name.identifier("size"), ARRAY_SIZE); + declareIntrinsicProperty(Name.identifier("Array"), Name.identifier("indices"), ARRAY_INDICES); + declareIntrinsicFunction(Name.identifier("Array"), Name.identifier("set"), 2, ARRAY_SET, true); + declareIntrinsicFunction(Name.identifier("Array"), Name.identifier("get"), 1, ARRAY_GET, true); declareIterator(myStdLib.getArray()); } private void declareArrayMethodsForPrimitive(JvmPrimitiveType jvmPrimitiveType) { PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType(); - declareIntrinsicProperty(primitiveType.getArrayTypeName(), "size", ARRAY_SIZE); - declareIntrinsicProperty(primitiveType.getArrayTypeName(), "indices", ARRAY_INDICES); - declareIntrinsicFunction(primitiveType.getArrayTypeName(), "set", 2, ARRAY_SET, true); - declareIntrinsicFunction(primitiveType.getArrayTypeName(), "get", 1, ARRAY_GET, true); + declareIntrinsicProperty(primitiveType.getArrayTypeName(), Name.identifier("size"), ARRAY_SIZE); + declareIntrinsicProperty(primitiveType.getArrayTypeName(), Name.identifier("indices"), ARRAY_INDICES); + declareIntrinsicFunction(primitiveType.getArrayTypeName(), Name.identifier("set"), 2, ARRAY_SET, true); + declareIntrinsicFunction(primitiveType.getArrayTypeName(), Name.identifier("get"), 1, ARRAY_GET, true); declareIterator(myStdLib.getPrimitiveArrayClassDescriptor(primitiveType)); } private void declareIterator(ClassDescriptor classDescriptor) { - declareOverload(classDescriptor.getDefaultType().getMemberScope().getFunctions("iterator"), 0, ARRAY_ITERATOR); + declareOverload(classDescriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier("iterator")), 0, ARRAY_ITERATOR); } private void declareIntrinsicStringMethods() { @@ -200,7 +201,7 @@ public class IntrinsicMethods { if (stringMember instanceof SimpleFunctionDescriptor) { final SimpleFunctionDescriptor stringMethod = (SimpleFunctionDescriptor) stringMember; final PsiMethod[] methods = stringPsiClass != null? - stringPsiClass.findMethodsByName(stringMember.getName(), false) : new PsiMethod[]{}; + stringPsiClass.findMethodsByName(stringMember.getName().getName(), false) : new PsiMethod[]{}; for (PsiMethod method : methods) { if (method.getParameterList().getParametersCount() == stringMethod.getValueParameters().size()) { myMethods.put(stringMethod, new PsiMethodCall(stringMethod)); @@ -210,14 +211,14 @@ public class IntrinsicMethods { } } - private void declareBinaryOp(String methodName, int opcode) { + private void declareBinaryOp(Name methodName, int opcode) { BinaryOp op = new BinaryOp(opcode); - for (String type : PRIMITIVE_TYPES) { + for (Name type : PRIMITIVE_TYPES) { declareIntrinsicFunction(type, methodName, 1, op, false); } } - private void declareIntrinsicProperty(String className, String methodName, IntrinsicMethod implementation) { + private void declareIntrinsicProperty(Name className, Name methodName, IntrinsicMethod implementation) { final JetScope numberScope = getClassMemberScope(className); Set properties = numberScope.getProperties(methodName); assert properties.size() == 1; @@ -225,7 +226,7 @@ public class IntrinsicMethods { myMethods.put(property.getOriginal(), implementation); } - private void declareIntrinsicFunction(String className, String functionName, int arity, IntrinsicMethod implementation, boolean original) { + private void declareIntrinsicFunction(Name className, Name functionName, int arity, IntrinsicMethod implementation, boolean original) { JetScope memberScope = getClassMemberScope(className); final Set group = memberScope.getFunctions(functionName); for (FunctionDescriptor descriptor : group) { @@ -243,7 +244,7 @@ public class IntrinsicMethods { } } - private JetScope getClassMemberScope(String className) { + private JetScope getClassMemberScope(Name className) { final ClassDescriptor descriptor = (ClassDescriptor) myStdLib.getLibraryScope().getClassifier(className); final List typeParameterDescriptors = descriptor.getTypeConstructor().getParameters(); List typeParameters = new ArrayList(); @@ -257,11 +258,10 @@ public class IntrinsicMethods { List annotations = descriptor.getAnnotations(); if (annotations != null) { for (AnnotationDescriptor annotation : annotations) { - if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName())) { + if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().getName())) { String value = (String) annotation.getValueArguments().get(0).getValue(); IntrinsicMethod intrinsicMethod = namedMethods.get(value); - if(intrinsicMethod != null) - return intrinsicMethod; + if (intrinsicMethod != null) { return intrinsicMethod; } } } } @@ -274,11 +274,10 @@ public class IntrinsicMethods { List annotations = descriptor.getAnnotations(); if (annotations != null) { for (AnnotationDescriptor annotation : annotations) { - if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName())) { + if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().getName())) { String value = (String) annotation.getValueArguments().get(0).getValue(); intrinsicMethod = namedMethods.get(value); - if(intrinsicMethod != null) - break; + if (intrinsicMethod != null) { break; } } } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/signature/BothSignatureWriter.java b/compiler/backend/src/org/jetbrains/jet/codegen/signature/BothSignatureWriter.java index 63397eec365..14c5580afda 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/signature/BothSignatureWriter.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/signature/BothSignatureWriter.java @@ -23,6 +23,7 @@ import org.jetbrains.jet.codegen.signature.JvmMethodParameterKind; import org.jetbrains.jet.codegen.signature.JvmMethodParameterSignature; import org.jetbrains.jet.codegen.signature.JvmMethodSignature; import org.jetbrains.jet.lang.resolve.java.JetSignatureUtils; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.Variance; import org.jetbrains.jet.rt.signature.JetSignatureAdapter; import org.jetbrains.jet.rt.signature.JetSignatureReader; @@ -264,9 +265,9 @@ public class BothSignatureWriter { pop(); } - public void writeTypeVariable(final String name, boolean nullable, Type asmType) { - signatureVisitor().visitTypeVariable(name); - jetSignatureWriter.visitTypeVariable(name, nullable); + public void writeTypeVariable(final Name name, boolean nullable, Type asmType) { + signatureVisitor().visitTypeVariable(name.getName()); + jetSignatureWriter.visitTypeVariable(name.getName(), nullable); generic = true; writeAsmType0(asmType); } diff --git a/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java index 6add239a2a4..433574fa0ac 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java @@ -40,6 +40,7 @@ import org.jetbrains.jet.lang.psi.JetPsiUtil; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM; import org.jetbrains.jet.lang.resolve.java.JvmAbi; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.plugin.JetLanguage; import org.jetbrains.jet.plugin.JetMainDetector; import org.jetbrains.jet.utils.Progress; @@ -127,7 +128,7 @@ public class KotlinToJVMBytecodeCompiler { for (JetFile file : configuration.getEnvironment().getSourceFiles()) { if (JetMainDetector.hasMain(file.getDeclarations())) { FqName fqName = JetPsiUtil.getFQName(file); - mainClass = fqName.child(JvmAbi.PACKAGE_CLASS); + mainClass = fqName.child(Name.identifier(JvmAbi.PACKAGE_CLASS)); break; } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/di/InjectorForJavaSemanticServices.java b/compiler/frontend.java/src/org/jetbrains/jet/di/InjectorForJavaSemanticServices.java index a3fe4e74de8..f8c65b7b2c5 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/di/InjectorForJavaSemanticServices.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/di/InjectorForJavaSemanticServices.java @@ -57,7 +57,7 @@ public class InjectorForJavaSemanticServices { this.bindingTrace = new org.jetbrains.jet.lang.resolve.BindingTraceContext(); this.javaBridgeConfiguration = new JavaBridgeConfiguration(); this.psiClassFinderForJvm = new PsiClassFinderForJvm(); - this.moduleDescriptor = new org.jetbrains.jet.lang.descriptors.ModuleDescriptor(""); + this.moduleDescriptor = new org.jetbrains.jet.lang.descriptors.ModuleDescriptor(org.jetbrains.jet.lang.resolve.name.Name.special("")); this.compilerDependencies = compilerDependencies; this.compilerSpecialMode = compilerDependencies.getCompilerSpecialMode(); this.project = project; diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AnalyzerFacadeForJVM.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AnalyzerFacadeForJVM.java index 97875e8ee8a..8f745b4d233 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AnalyzerFacadeForJVM.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/AnalyzerFacadeForJVM.java @@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.resolve.AnalyzingUtils; import org.jetbrains.jet.lang.resolve.BindingTraceContext; import org.jetbrains.jet.lang.resolve.ObservableBindingTrace; import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.lang.JetStandardLibrary; import java.util.Collection; @@ -83,7 +84,7 @@ public enum AnalyzerFacadeForJVM implements AnalyzerFacade { @NotNull CompilerDependencies compilerDependencies) { BindingTraceContext bindingTraceContext = new BindingTraceContext(); - final ModuleDescriptor owner = new ModuleDescriptor(""); + final ModuleDescriptor owner = new ModuleDescriptor(Name.special("")); TopDownAnalysisParameters topDownAnalysisParameters = new TopDownAnalysisParameters( filesToAnalyzeCompletely, false, false); diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java index 48da0a24027..78e0e13086b 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java @@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.name.LabelName; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import java.util.Collection; @@ -40,7 +41,7 @@ import java.util.Set; * @author abreslav */ public class JavaClassMembersScope extends JavaClassOrPackageScope { - private final Map classifiers = Maps.newHashMap(); + private final Map classifiers = Maps.newHashMap(); public JavaClassMembersScope( @NotNull JavaSemanticServices semanticServices, @@ -62,7 +63,7 @@ public class JavaClassMembersScope extends JavaClassOrPackageScope { } @Override - public ClassifierDescriptor getClassifier(@NotNull String name) { + public ClassifierDescriptor getClassifier(@NotNull Name name) { ClassifierDescriptor classifierDescriptor = classifiers.get(name); if (classifierDescriptor == null) { classifierDescriptor = doGetClassifierDescriptor(name); @@ -72,7 +73,7 @@ public class JavaClassMembersScope extends JavaClassOrPackageScope { } @Override - public ClassDescriptor getObjectDescriptor(@NotNull String name) { + public ClassDescriptor getObjectDescriptor(@NotNull Name name) { return null; } @@ -82,10 +83,10 @@ public class JavaClassMembersScope extends JavaClassOrPackageScope { return Collections.emptySet(); } - private ClassifierDescriptor doGetClassifierDescriptor(String name) { + private ClassifierDescriptor doGetClassifierDescriptor(Name name) { // TODO : suboptimal, walk the list only once for (PsiClass innerClass : resolverScopeData.psiClass.getAllInnerClasses()) { - if (name.equals(innerClass.getName())) { + if (name.getName().equals(innerClass.getName())) { if (innerClass.hasModifierProperty(PsiModifier.STATIC) != resolverScopeData.staticMembers) return null; ClassDescriptor classDescriptor = semanticServices.getDescriptorResolver() .resolveClass(new FqName(innerClass.getQualifiedName()), DescriptorSearchRule.IGNORE_IF_FOUND_IN_KOTLIN); @@ -98,7 +99,7 @@ public class JavaClassMembersScope extends JavaClassOrPackageScope { } @Override - public NamespaceDescriptor getNamespace(@NotNull String name) { + public NamespaceDescriptor getNamespace(@NotNull Name name) { return null; } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassOrPackageScope.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassOrPackageScope.java index 5c160f9183c..ccecc40ded9 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassOrPackageScope.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassOrPackageScope.java @@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; import org.jetbrains.jet.lang.descriptors.VariableDescriptor; import org.jetbrains.jet.lang.resolve.name.FqName; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScopeImpl; import java.util.Collection; @@ -60,13 +61,13 @@ public abstract class JavaClassOrPackageScope extends JetScopeImpl { @NotNull @Override - public Set getProperties(@NotNull String name) { + public Set getProperties(@NotNull Name name) { return semanticServices.getDescriptorResolver().resolveFieldGroupByName(name, resolverScopeData); } @NotNull @Override - public Set getFunctions(@NotNull String name) { + public Set getFunctions(@NotNull Name name) { return semanticServices.getDescriptorResolver().resolveFunctionGroup(name, resolverScopeData); } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java index 3407b66ac0d..e69bf8ee9af 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java @@ -34,6 +34,7 @@ import org.jetbrains.jet.lang.resolve.constants.StringValue; import org.jetbrains.jet.lang.resolve.java.kt.JetClassAnnotation; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.*; import org.jetbrains.jet.lang.types.lang.JetStandardClasses; import org.jetbrains.jet.lang.types.lang.JetStandardLibrary; @@ -50,11 +51,11 @@ import java.util.*; */ public class JavaDescriptorResolver { - public static final String JAVA_ROOT = ""; + public static final Name JAVA_ROOT = Name.special(""); public static final ModuleDescriptor FAKE_ROOT_MODULE = new ModuleDescriptor(JAVA_ROOT); - /*package*/ static final DeclarationDescriptor JAVA_METHOD_TYPE_PARAMETER_PARENT = new DeclarationDescriptorImpl(null, Collections.emptyList(), "") { + /*package*/ static final DeclarationDescriptor JAVA_METHOD_TYPE_PARAMETER_PARENT = new DeclarationDescriptorImpl(null, Collections.emptyList(), Name.special("")) { @Override public DeclarationDescriptor substitute(TypeSubstitutor substitutor) { @@ -67,7 +68,7 @@ public class JavaDescriptorResolver { } }; - /*package*/ static final DeclarationDescriptor JAVA_CLASS_OBJECT = new DeclarationDescriptorImpl(null, Collections.emptyList(), "") { + /*package*/ static final DeclarationDescriptor JAVA_CLASS_OBJECT = new DeclarationDescriptorImpl(null, Collections.emptyList(), Name.special("")) { @NotNull @Override public DeclarationDescriptor substitute(TypeSubstitutor substitutor) { @@ -158,7 +159,7 @@ public class JavaDescriptorResolver { (new PsiClassWrapper(psiClass).getJetClass().isDefined() || psiClass.getName().equals(JvmAbi.PACKAGE_CLASS)); classOrNamespaceDescriptor = descriptor; - if (fqName.lastSegmentIs(JvmAbi.PACKAGE_CLASS) && psiClass != null && kotlin) { + if (fqName.lastSegmentIs(Name.identifier(JvmAbi.PACKAGE_CLASS)) && psiClass != null && kotlin) { throw new IllegalStateException("Kotlin namespace cannot have last segment " + JvmAbi.PACKAGE_CLASS + ": " + fqName); } } @@ -189,7 +190,7 @@ public class JavaDescriptorResolver { } } - private Map namedMembersMap; + private Map namedMembersMap; @NotNull public abstract List getTypeParameters(); @@ -359,7 +360,7 @@ public class JavaDescriptorResolver { checkPsiClassIsNotJet(psiClass); - String name = psiClass.getName(); + Name name = Name.identifier(psiClass.getName()); ClassKind kind = psiClass.isInterface() ? (psiClass.isAnnotationType() ? ClassKind.ANNOTATION_CLASS : ClassKind.TRAIT) : ClassKind.CLASS; ClassOrNamespaceDescriptor containingDeclaration = resolveParentDescriptor(psiClass); @@ -454,7 +455,7 @@ public class JavaDescriptorResolver { constructorDescriptor, i, Collections.emptyList(), - method.getName(), + Name.identifier(method.getName()), false, semanticServices.getTypeTransformer().transformToType(returnType, resolverForTypeParameters), annotationMethod.getDefaultValue() != null, @@ -686,7 +687,7 @@ public class JavaDescriptorResolver { Collections.emptyList(), // TODO: wrong reified, JetSignatureUtils.translateVariance(variance), - name, + Name.identifier(name), formalTypeParameterIndex++); previousTypeParameters.add(typeParameter); @@ -761,7 +762,7 @@ public class JavaDescriptorResolver { Collections.emptyList(), // TODO false, Variance.INVARIANT, - psiTypeParameter.getName(), + Name.identifier(psiTypeParameter.getName()), psiTypeParameter.getIndex() ); return new TypeParameterDescriptorInitialization(typeParameterDescriptor, psiTypeParameter); @@ -1012,7 +1013,7 @@ public class JavaDescriptorResolver { @Nullable private PsiClass getPsiClassForJavaPackageScope(@NotNull FqName packageFQN) { - return psiClassFinder.findPsiClass(packageFQN.child(JvmAbi.PACKAGE_CLASS), PsiClassFinder.RuntimeClassesHandleMode.IGNORE); + return psiClassFinder.findPsiClass(packageFQN.child(Name.identifier(JvmAbi.PACKAGE_CLASS)), PsiClassFinder.RuntimeClassesHandleMode.IGNORE); } private static class ValueParameterDescriptors { @@ -1068,10 +1069,10 @@ public class JavaDescriptorResolver { PsiType psiType = parameter.getPsiParameter().getType(); // TODO: must be very slow, make it lazy? - String name = parameter.getPsiParameter().getName() != null ? parameter.getPsiParameter().getName() : "p" + i; + Name name = Name.identifier(parameter.getPsiParameter().getName() != null ? parameter.getPsiParameter().getName() : "p" + i); if (parameter.getJetValueParameter().name().length() > 0) { - name = parameter.getJetValueParameter().name(); + name = Name.identifier(parameter.getJetValueParameter().name()); } String typeFromAnnotation = parameter.getJetValueParameter().type(); @@ -1123,7 +1124,7 @@ public class JavaDescriptorResolver { } } - public Set resolveFieldGroupByName(@NotNull String fieldName, @NotNull ResolverScopeData scopeData) { + public Set resolveFieldGroupByName(@NotNull Name fieldName, @NotNull ResolverScopeData scopeData) { if (scopeData.psiClass == null) { return Collections.emptySet(); @@ -1148,10 +1149,10 @@ public class JavaDescriptorResolver { getResolverScopeData(scopeData); Set descriptors = Sets.newHashSet(); - Map membersForProperties = scopeData.namedMembersMap; - for (Map.Entry entry : membersForProperties.entrySet()) { + Map membersForProperties = scopeData.namedMembersMap; + for (Map.Entry entry : membersForProperties.entrySet()) { NamedMembers namedMembers = entry.getValue(); - String propertyName = entry.getKey(); + Name propertyName = entry.getKey(); resolveNamedGroupProperties(scopeData.classOrNamespaceDescriptor, scopeData, namedMembers, propertyName, "class or namespace " + scopeData.psiClass.getQualifiedName()); descriptors.addAll(namedMembers.propertyDescriptors); @@ -1196,7 +1197,7 @@ public class JavaDescriptorResolver { private void resolveNamedGroupProperties( @NotNull ClassOrNamespaceDescriptor owner, @NotNull ResolverScopeData scopeData, - @NotNull NamedMembers namedMembers, @NotNull String propertyName, + @NotNull NamedMembers namedMembers, @NotNull Name propertyName, @NotNull String context) { getResolverScopeData(scopeData); @@ -1397,7 +1398,7 @@ public class JavaDescriptorResolver { getterDescriptor.initialize(propertyType); } if (setterDescriptor != null) { - setterDescriptor.initialize(new ValueParameterDescriptorImpl(setterDescriptor, 0, Collections.emptyList(), "p0"/*TODO*/, false, propertyDescriptor.getType(), false, null)); + setterDescriptor.initialize(new ValueParameterDescriptorImpl(setterDescriptor, 0, Collections.emptyList(), Name.identifier("p0") /*TODO*/, false, propertyDescriptor.getType(), false, null)); } trace.record(BindingContext.VARIABLE, anyMember.getMember().psiMember, propertyDescriptor); @@ -1432,7 +1433,7 @@ public class JavaDescriptorResolver { } private void resolveNamedGroupFunctions(@NotNull ClassOrNamespaceDescriptor owner, PsiClass psiClass, - TypeSubstitutor typeSubstitutorForGenericSuperclasses, NamedMembers namedMembers, String methodName, ResolverScopeData scopeData) { + TypeSubstitutor typeSubstitutorForGenericSuperclasses, NamedMembers namedMembers, Name methodName, ResolverScopeData scopeData) { if (namedMembers.functionDescriptors != null) { return; } @@ -1471,7 +1472,7 @@ public class JavaDescriptorResolver { namedMembers.functionDescriptors = functions; } - private Set getFunctionsFromSupertypes(ResolverScopeData scopeData, String methodName) { + private Set getFunctionsFromSupertypes(ResolverScopeData scopeData, Name methodName) { Set r = new HashSet(); for (JetType supertype : getSupertypes(scopeData)) { for (FunctionDescriptor function : supertype.getMemberScope().getFunctions(methodName)) { @@ -1481,7 +1482,7 @@ public class JavaDescriptorResolver { return r; } - private Set getPropertiesFromSupertypes(ResolverScopeData scopeData, String propertyName) { + private Set getPropertiesFromSupertypes(ResolverScopeData scopeData, Name propertyName) { Set r = new HashSet(); for (JetType supertype : getSupertypes(scopeData)) { for (VariableDescriptor property : supertype.getMemberScope().getProperties(propertyName)) { @@ -1498,11 +1499,11 @@ public class JavaDescriptorResolver { } @NotNull - public Set resolveFunctionGroup(@NotNull String methodName, @NotNull ResolverScopeData scopeData) { + public Set resolveFunctionGroup(@NotNull Name methodName, @NotNull ResolverScopeData scopeData) { getResolverScopeData(scopeData); - Map namedMembersMap = scopeData.namedMembersMap; + Map namedMembersMap = scopeData.namedMembersMap; NamedMembers namedMembers = namedMembersMap.get(methodName); if (namedMembers != null && namedMembers.methods != null) { @@ -1582,7 +1583,7 @@ public class JavaDescriptorResolver { SimpleFunctionDescriptorImpl functionDescriptorImpl = new SimpleFunctionDescriptorImpl( scopeData.classOrNamespaceDescriptor, resolveAnnotations(method.getPsiMethod()), - method.getName(), + Name.identifier(method.getName()), CallableMemberDescriptor.Kind.DECLARATION ); @@ -1696,8 +1697,8 @@ public class JavaDescriptorResolver { List functions = new ArrayList(); - for (Map.Entry entry : scopeData.namedMembersMap.entrySet()) { - String methodName = entry.getKey(); + for (Map.Entry entry : scopeData.namedMembersMap.entrySet()) { + Name methodName = entry.getKey(); NamedMembers namedMembers = entry.getValue(); resolveNamedGroupFunctions(scopeData.classOrNamespaceDescriptor, scopeData.psiClass, substitutorForGenericSupertypes, namedMembers, methodName, scopeData); functions.addAll(namedMembers.functionDescriptors); diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolverHelper.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolverHelper.java index 17e5b0b94cc..ed4c34caba1 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolverHelper.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolverHelper.java @@ -22,6 +22,7 @@ import com.intellij.psi.PsiParameter; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.resolve.java.prop.PropertyNameUtils; import org.jetbrains.jet.lang.resolve.java.prop.PropertyParseResult; +import org.jetbrains.jet.lang.resolve.name.Name; import java.util.Collections; import java.util.HashMap; @@ -39,7 +40,7 @@ class JavaDescriptorResolverHelper { private final boolean staticMembers; private final boolean kotlin; - private Map namedMembersMap = new HashMap(); + private Map namedMembersMap = new HashMap(); private Builder(PsiClassWrapper psiClass, boolean staticMembers, boolean kotlin) { this.psiClass = psiClass; @@ -52,10 +53,7 @@ class JavaDescriptorResolverHelper { processMethods(); } - private NamedMembers getNamedMembers(String name) { - if (name.length() == 0) { - throw new IllegalStateException("Oi! Empty member name in " + psiClass.getPsiClass() + ". How it is possible?"); - } + private NamedMembers getNamedMembers(Name name) { NamedMembers r = namedMembersMap.get(name); if (r == null) { r = new NamedMembers(); @@ -87,7 +85,7 @@ class JavaDescriptorResolverHelper { PsiFieldWrapper field = new PsiFieldWrapper(field0); // group must be created even for excluded field - NamedMembers namedMembers = getNamedMembers(field.getName()); + NamedMembers namedMembers = getNamedMembers(Name.identifier(field.getName())); if (!includeMember(field)) { continue; @@ -102,11 +100,11 @@ class JavaDescriptorResolverHelper { private void processMethods() { for (PsiMethod method : psiClass.getPsiClass().getAllMethods()) { - getNamedMembers(method.getName()); + getNamedMembers(Name.identifier(method.getName())); PropertyParseResult propertyParseResult = PropertyNameUtils.parseMethodToProperty(method.getName()); if (propertyParseResult != null) { - getNamedMembers(propertyParseResult.getPropertyName()); + getNamedMembers(Name.identifier(propertyParseResult.getPropertyName())); } } @@ -124,7 +122,7 @@ class JavaDescriptorResolverHelper { if (propertyParseResult != null && propertyParseResult.isGetter()) { String propertyName = propertyParseResult.getPropertyName(); - NamedMembers members = getNamedMembers(propertyName); + NamedMembers members = getNamedMembers(Name.identifier(propertyName)); // TODO: some java properties too if (method.getJetMethod().kind() == JvmStdlibNames.JET_METHOD_KIND_PROPERTY) { @@ -167,7 +165,7 @@ class JavaDescriptorResolverHelper { else if (propertyParseResult != null && !propertyParseResult.isGetter()) { String propertyName = propertyParseResult.getPropertyName(); - NamedMembers members = getNamedMembers(propertyName); + NamedMembers members = getNamedMembers(Name.identifier(propertyName)); if (method.getJetMethod().kind() == JvmStdlibNames.JET_METHOD_KIND_PROPERTY) { if (method.getParameters().size() == 0) { @@ -207,7 +205,7 @@ class JavaDescriptorResolverHelper { } if (method.getJetMethod().kind() != JvmStdlibNames.JET_METHOD_KIND_PROPERTY) { - NamedMembers namedMembers = getNamedMembers(method.getName()); + NamedMembers namedMembers = getNamedMembers(Name.identifier(method.getName())); namedMembers.addMethod(method); } } @@ -216,7 +214,7 @@ class JavaDescriptorResolverHelper { @NotNull - static Map getNamedMembers(@NotNull JavaDescriptorResolver.ResolverScopeData resolverScopeData) { + static Map getNamedMembers(@NotNull JavaDescriptorResolver.ResolverScopeData resolverScopeData) { if (resolverScopeData.psiClass != null) { Builder builder = new Builder(new PsiClassWrapper(resolverScopeData.psiClass), resolverScopeData.staticMembers, resolverScopeData.kotlin); builder.run(); diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaNamespaceDescriptor.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaNamespaceDescriptor.java index fc95f919f0d..fee049a5ed2 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaNamespaceDescriptor.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaNamespaceDescriptor.java @@ -21,6 +21,7 @@ import org.jetbrains.jet.lang.descriptors.AbstractNamespaceDescriptorImpl; import org.jetbrains.jet.lang.descriptors.NamespaceDescriptorParent; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.resolve.name.FqName; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import java.util.List; @@ -33,7 +34,7 @@ public class JavaNamespaceDescriptor extends AbstractNamespaceDescriptorImpl { private final FqName qualifiedName; public JavaNamespaceDescriptor(NamespaceDescriptorParent containingDeclaration, List annotations, - @NotNull String name, @NotNull FqName qualifiedName) { + @NotNull Name name, @NotNull FqName qualifiedName) { super(containingDeclaration, annotations, name); this.qualifiedName = qualifiedName; } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.java index d546c050bb4..cae2aef377f 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.java @@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor; import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.name.FqName; +import org.jetbrains.jet.lang.resolve.name.Name; /** * @author abreslav @@ -44,7 +45,7 @@ public class JavaPackageScope extends JavaClassOrPackageScope { } @Override - public ClassifierDescriptor getClassifier(@NotNull String name) { + public ClassifierDescriptor getClassifier(@NotNull Name name) { ClassDescriptor classDescriptor = semanticServices.getDescriptorResolver().resolveClass(packageFQN.child(name), DescriptorSearchRule.IGNORE_IF_FOUND_IN_KOTLIN); if (classDescriptor == null || DescriptorUtils.isObject(classDescriptor)) { // TODO: this is a big hack against several things that I barely understand myself and cannot explain @@ -56,13 +57,13 @@ public class JavaPackageScope extends JavaClassOrPackageScope { } @Override - public ClassDescriptor getObjectDescriptor(@NotNull String name) { + public ClassDescriptor getObjectDescriptor(@NotNull Name name) { // TODO return null; } @Override - public NamespaceDescriptor getNamespace(@NotNull String name) { + public NamespaceDescriptor getNamespace(@NotNull Name name) { return semanticServices.getDescriptorResolver().resolveNamespace(packageFQN.child(name), DescriptorSearchRule.INCLUDE_KOTLIN); } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaSemanticServices.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaSemanticServices.java index dab37d826da..834c5065d06 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaSemanticServices.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaSemanticServices.java @@ -23,6 +23,7 @@ import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingTrace; import org.jetbrains.jet.lang.resolve.name.FqName; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.lang.JetStandardLibrary; import javax.inject.Inject; @@ -87,8 +88,8 @@ public class JavaSemanticServices { @Nullable public ClassDescriptor getKotlinBuiltinClassDescriptor(@NotNull FqName qualifiedName) { - if (qualifiedName.getFqName().startsWith("jet.")) { - return (ClassDescriptor) JetStandardLibrary.getInstance().getLibraryScope().getClassifier(qualifiedName.getFqName().substring("jet.".length())); + if (qualifiedName.firstSegmentIs(Name.identifier("jet")) && qualifiedName.pathSegments().size() == 2) { + return (ClassDescriptor) JetStandardLibrary.getInstance().getLibraryScope().getClassifier(qualifiedName.pathSegments().get(1)); } else { return null; diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/NamedMembers.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/NamedMembers.java index c52862bae8a..f8cd9e7c181 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/NamedMembers.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/NamedMembers.java @@ -20,6 +20,7 @@ import com.intellij.psi.PsiClass; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; import org.jetbrains.jet.lang.descriptors.VariableDescriptor; +import org.jetbrains.jet.lang.resolve.name.Name; import java.util.ArrayList; import java.util.List; @@ -29,7 +30,7 @@ import java.util.Set; * @author Stepan Koltsov */ class NamedMembers { - String name; + Name name; List methods = new ArrayList(0); @Nullable diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/TypeVariableResolverFromTypeDescriptors.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/TypeVariableResolverFromTypeDescriptors.java index b9fbbed4257..ed1f6235fff 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/TypeVariableResolverFromTypeDescriptors.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/TypeVariableResolverFromTypeDescriptors.java @@ -64,7 +64,7 @@ public class TypeVariableResolverFromTypeDescriptors implements TypeVariableReso @NotNull DeclarationDescriptor owner, @NotNull String context) { for (TypeParameterDescriptor typeParameter : typeParameters) { - if (typeParameter.getName().equals(name)) { + if (typeParameter.getName().getName().equals(name)) { return typeParameter; } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/AbstractNamespaceDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/AbstractNamespaceDescriptorImpl.java index d8f9d8250a1..ea495607b24 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/AbstractNamespaceDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/AbstractNamespaceDescriptorImpl.java @@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.NamespaceType; import org.jetbrains.jet.lang.types.TypeSubstitutor; @@ -32,13 +33,12 @@ public abstract class AbstractNamespaceDescriptorImpl extends DeclarationDescrip public AbstractNamespaceDescriptorImpl( @NotNull NamespaceDescriptorParent containingDeclaration, List annotations, - @NotNull String name) { + @NotNull Name name) { super(containingDeclaration, annotations, name); boolean rootAccordingToContainer = containingDeclaration instanceof ModuleDescriptor; - boolean rootAccordingToName = name.startsWith("<"); - if (rootAccordingToContainer != rootAccordingToName) { + if (rootAccordingToContainer != name.isSpecial()) { throw new IllegalStateException("something is wrong, name: " + name + ", container: " + containingDeclaration); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.java index 58b821afa3f..3058e1fe40d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.java @@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.SubstitutingScope; import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver; @@ -42,7 +43,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements Cl public ClassDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, @NotNull List annotations, - @NotNull String name) { + @NotNull Name name) { super(containingDeclaration, annotations, name); } @@ -62,7 +63,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements Cl @NotNull Set constructors, @Nullable ConstructorDescriptor primaryConstructor, @Nullable JetType superclassType) { - this.typeConstructor = new TypeConstructorImpl(this, getAnnotations(), sealed, getName(), typeParameters, supertypes); + this.typeConstructor = new TypeConstructorImpl(this, getAnnotations(), sealed, getName().getName(), typeParameters, supertypes); this.memberDeclarations = memberDeclarations; this.constructors = constructors; this.primaryConstructor = primaryConstructor; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptor.java index 17d1edf81fe..209f248fc8e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptor.java @@ -17,8 +17,8 @@ package org.jetbrains.jet.lang.descriptors; import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; -import org.jetbrains.jet.lang.types.TypeSubstitutor; import java.util.List; @@ -49,7 +49,7 @@ public interface ConstructorDescriptor extends FunctionDescriptor { */ @NotNull @Override - String getName(); + Name getName(); boolean isPrimary(); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.java index 85055c2f487..11afe1e9036 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.java @@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.resolve.DescriptorUtils; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import java.util.Collections; @@ -32,13 +33,15 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements private final boolean isPrimary; + private static final Name NAME = Name.special(""); + public ConstructorDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull List annotations, boolean isPrimary) { - super(containingDeclaration, annotations, "", Kind.DECLARATION); + super(containingDeclaration, annotations, NAME, Kind.DECLARATION); this.isPrimary = isPrimary; } public ConstructorDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull ConstructorDescriptor original, @NotNull List annotations, boolean isPrimary) { - super(containingDeclaration, original, annotations, "", Kind.DECLARATION); + super(containingDeclaration, original, annotations, NAME, Kind.DECLARATION); this.isPrimary = isPrimary; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorImpl.java index 28703dc5a2f..189b140577f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorImpl.java @@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.annotations.AnnotatedImpl; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.resolve.DescriptorRenderer; import java.util.List; @@ -29,23 +30,20 @@ import java.util.List; */ public abstract class DeclarationDescriptorImpl extends AnnotatedImpl implements Named, DeclarationDescriptor { - private final String name; + @NotNull + private final Name name; private final DeclarationDescriptor containingDeclaration; - public DeclarationDescriptorImpl(@Nullable DeclarationDescriptor containingDeclaration, @NotNull List annotations, @NotNull String name) { + public DeclarationDescriptorImpl(@Nullable DeclarationDescriptor containingDeclaration, @NotNull List annotations, @NotNull Name name) { super(annotations); - if (name.length() == 0) { - throw new IllegalArgumentException("descriptor name cannot be empty string"); - } - this.name = name; this.containingDeclaration = containingDeclaration; } @NotNull @Override - public String getName() { + public Name getName() { return name; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.java index 9fca8cfa754..69216fca3f0 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.java @@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.resolve.OverridingUtil; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver; @@ -55,7 +56,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorImpl i protected FunctionDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, @NotNull List annotations, - @NotNull String name, + @NotNull Name name, Kind kind) { super(containingDeclaration, annotations, name); this.original = this; @@ -66,7 +67,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorImpl i @NotNull DeclarationDescriptor containingDeclaration, @NotNull FunctionDescriptor original, @NotNull List annotations, - @NotNull String name, + @NotNull Name name, Kind kind) { super(containingDeclaration, annotations, name); this.original = original; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java index 101c4a14e06..e9e543a1fe5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java @@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.resolve.BindingTrace; import org.jetbrains.jet.lang.resolve.TraceBasedRedeclarationHandler; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.WritableScope; import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl; @@ -141,7 +142,7 @@ public class FunctionDescriptorUtil { ClassifierDescriptor classDescriptorForFunction = functionType.getConstructor().getDeclarationDescriptor(); assert classDescriptorForFunction instanceof ClassDescriptor; - Set invokeFunctions = ((ClassDescriptor) classDescriptorForFunction).getMemberScope(functionType.getArguments()).getFunctions("invoke"); + Set invokeFunctions = ((ClassDescriptor) classDescriptorForFunction).getMemberScope(functionType.getArguments()).getFunctions(Name.identifier("invoke")); assert invokeFunctions.size() == 1; return invokeFunctions.iterator().next(); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.java index 8c22916b00d..9f63cbb20ef 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.java @@ -20,6 +20,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.SubstitutingScope; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; @@ -137,7 +138,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor { @NotNull @Override - public String getName() { + public Name getName() { return original.getName(); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LocalVariableDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LocalVariableDescriptor.java index 9be3ce3affb..bb7be65bedf 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LocalVariableDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LocalVariableDescriptor.java @@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.TypeSubstitutor; @@ -32,7 +33,7 @@ public class LocalVariableDescriptor extends VariableDescriptorImpl { public LocalVariableDescriptor( @NotNull DeclarationDescriptor containingDeclaration, @NotNull List annotations, - @NotNull String name, + @NotNull Name name, @Nullable JetType type, boolean mutable) { super(containingDeclaration, annotations, name, type); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ModuleDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ModuleDescriptor.java index 63709e62f81..a64c87bf928 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ModuleDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ModuleDescriptor.java @@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.TypeSubstitutor; import java.util.Collections; @@ -28,8 +29,11 @@ import java.util.Collections; public class ModuleDescriptor extends DeclarationDescriptorImpl implements ClassOrNamespaceDescriptor, NamespaceDescriptorParent { private NamespaceDescriptor rootNs; - public ModuleDescriptor(String name) { + public ModuleDescriptor(Name name) { super(null, Collections.emptyList(), name); + if (!name.isSpecial()) { + throw new IllegalArgumentException("module name must be special: " + name); + } } public void setRootNs(@NotNull NamespaceDescriptor rootNs) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java index 1dcbe098eff..ba6fe22b229 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java @@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.psi.JetParameter; import org.jetbrains.jet.lang.resolve.AbstractScopeAdapter; import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.lang.resolve.BindingTrace; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler; import org.jetbrains.jet.lang.resolve.scopes.WritableScope; @@ -47,7 +48,7 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite { private WritableScope scopeForInitializers = null; //contains members + primary constructor value parameters + map for backing fields public MutableClassDescriptor(@NotNull DeclarationDescriptor containingDeclaration, - @NotNull JetScope outerScope, ClassKind kind, String name) { + @NotNull JetScope outerScope, ClassKind kind, Name name) { super(containingDeclaration, kind); RedeclarationHandler redeclarationHandler = RedeclarationHandler.DO_NOTHING; @@ -118,7 +119,7 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @Override - public void setName(@NotNull String name) { + public void setName(@NotNull Name name) { super.setName(name); scopeForMemberResolution.addLabeledDeclaration(this); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptorLite.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptorLite.java index 9ebfffaa1a7..88d89a1cd63 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptorLite.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptorLite.java @@ -107,7 +107,7 @@ public class MutableClassDescriptorLite extends MutableDeclarationDescriptor this, Collections.emptyList(), // TODO : pass annotations from the class? !modality.isOverridable(), - getName(), + getName().getName(), typeParameters, supertypes); for (FunctionDescriptor functionDescriptor : constructors) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableDeclarationDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableDeclarationDescriptor.java index ed4945cc602..b7bff02d067 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableDeclarationDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableDeclarationDescriptor.java @@ -17,12 +17,13 @@ package org.jetbrains.jet.lang.descriptors; import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.resolve.name.Name; /** * @author abreslav */ public abstract class MutableDeclarationDescriptor implements DeclarationDescriptor { - private String name; + private Name name; private final DeclarationDescriptor containingDeclaration; public MutableDeclarationDescriptor(@NotNull DeclarationDescriptor containingDeclaration) { @@ -31,11 +32,11 @@ public abstract class MutableDeclarationDescriptor implements DeclarationDescrip @NotNull @Override - public String getName() { + public Name getName() { return name; } - public void setName(@NotNull String name) { + public void setName(@NotNull Name name) { assert this.name == null : this.name; this.name = name; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/Named.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/Named.java index 0f1738363c8..806154e2f5b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/Named.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/Named.java @@ -17,11 +17,12 @@ package org.jetbrains.jet.lang.descriptors; import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.resolve.name.Name; /** * @author abreslav */ public interface Named { @NotNull - String getName(); + Name getName(); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/NamespaceDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/NamespaceDescriptorImpl.java index fcb013589fc..e97dccd31d7 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/NamespaceDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/NamespaceDescriptorImpl.java @@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.name.FqName; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.WritableScope; import java.util.List; @@ -33,7 +34,7 @@ public class NamespaceDescriptorImpl extends AbstractNamespaceDescriptorImpl imp public NamespaceDescriptorImpl(@NotNull NamespaceDescriptorParent containingDeclaration, @NotNull List annotations, - @NotNull String name) { + @NotNull Name name) { super(containingDeclaration, annotations, name); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyAccessorDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyAccessorDescriptor.java index cde00f2e6eb..844c47fbaa0 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyAccessorDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyAccessorDescriptor.java @@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors; import com.google.common.collect.Sets; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import org.jetbrains.jet.lang.types.TypeSubstitutor; @@ -43,7 +44,7 @@ public abstract class PropertyAccessorDescriptor extends DeclarationDescriptorIm @NotNull Visibility visibility, @NotNull PropertyDescriptor correspondingProperty, @NotNull List annotations, - @NotNull String name, + @NotNull Name name, boolean hasBody, boolean isDefault, Kind kind) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java index 1d6c3f25ac4..4a535c807c0 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java @@ -23,6 +23,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.OverridingUtil; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver; @@ -54,7 +55,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab private PropertySetterDescriptor setter; private PropertyDescriptor() { - super(ErrorUtils.getErrorClass(), Collections.emptyList(), "dummy"); + super(ErrorUtils.getErrorClass(), Collections.emptyList(), Name.special("")); this.modality = null; this.visibility = null; this.isVar = false; @@ -71,7 +72,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab @NotNull Visibility visibility, boolean isVar, boolean isObject, - @NotNull String name, + @NotNull Name name, Kind kind) { super(containingDeclaration, annotations, name); this.isVar = isVar; @@ -89,7 +90,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab @NotNull Visibility visibility, boolean isVar, boolean isObject, - @NotNull String name, + @NotNull Name name, Kind kind) { this(null, containingDeclaration, annotations, modality, visibility, isVar, isObject, name, kind); } @@ -103,7 +104,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab boolean isObject, @Nullable JetType receiverType, @NotNull ReceiverDescriptor expectedThisObject, - @NotNull String name, + @NotNull Name name, @NotNull JetType outType, Kind kind ) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyGetterDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyGetterDescriptor.java index 5e6ca38b106..739ed73bb92 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyGetterDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyGetterDescriptor.java @@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; import java.util.Collections; @@ -33,7 +34,7 @@ public class PropertyGetterDescriptor extends PropertyAccessorDescriptor { public PropertyGetterDescriptor(@NotNull PropertyDescriptor correspondingProperty, @NotNull List annotations, @NotNull Modality modality, @NotNull Visibility visibility, boolean hasBody, boolean isDefault, Kind kind) { - super(modality, visibility, correspondingProperty, annotations, "get-" + correspondingProperty.getName(), hasBody, isDefault, kind); + super(modality, visibility, correspondingProperty, annotations, Name.special(""), hasBody, isDefault, kind); } public void initialize(JetType returnType) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertySetterDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertySetterDescriptor.java index 5f16d0dc143..5489a7eee7d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertySetterDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertySetterDescriptor.java @@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.lang.JetStandardClasses; import org.jetbrains.jet.lang.types.JetType; @@ -40,7 +41,7 @@ public class PropertySetterDescriptor extends PropertyAccessorDescriptor { boolean hasBody, boolean isDefault, Kind kind) { - super(modality, visibility, correspondingProperty, annotations, "set-" + correspondingProperty.getName(), hasBody, isDefault, kind); + super(modality, visibility, correspondingProperty, annotations, Name.special(""), hasBody, isDefault, kind); } public void initialize(@NotNull ValueParameterDescriptor parameter) { @@ -50,7 +51,7 @@ public class PropertySetterDescriptor extends PropertyAccessorDescriptor { public void initializeDefault() { assert parameter == null; - parameter = new ValueParameterDescriptorImpl(this, 0, Collections.emptyList(), "<>", false, getCorrespondingProperty().getReturnType(), false, null); + parameter = new ValueParameterDescriptorImpl(this, 0, Collections.emptyList(), Name.special(""), false, getCorrespondingProperty().getReturnType(), false, null); } @NotNull diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ScriptDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ScriptDescriptor.java index b9b60fdfdc8..2b3e96ad16a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ScriptDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ScriptDescriptor.java @@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.TypeSubstitutor; @@ -28,10 +29,12 @@ import java.util.Collections; * @author Stepan Koltsov */ public class ScriptDescriptor extends DeclarationDescriptorImpl { + private static final Name NAME = Name.special("