diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java index 43fbd168d4e..0f894a055f9 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java @@ -43,16 +43,22 @@ public abstract class AnnotationCodegen { for (AnnotationDescriptor annotationDescriptor : annotations) { List> valueArguments = annotationDescriptor.getValueArguments(); - if(!valueArguments.isEmpty()) { - throw new UnsupportedOperationException("Only annotations without values are supported by backend so far"); - } - JetType type = annotationDescriptor.getType(); ClassifierDescriptor classifierDescriptor = type.getConstructor().getDeclarationDescriptor(); RetentionPolicy rp = getRetentionPolicy(classifierDescriptor, typeMapper); if(rp != RetentionPolicy.SOURCE) { String internalName = typeMapper.mapType(type).getDescriptor(); AnnotationVisitor annotationVisitor = visitAnnotation(internalName, rp == RetentionPolicy.RUNTIME); + + if(!valueArguments.isEmpty()) { + // todo: temporary hack for intrinsics in stdlib + if(valueArguments.size()==1 && "intrinsic".equals(annotationDescriptor.getType().getConstructor().getDeclarationDescriptor().getName())) { + annotationVisitor.visit("value", valueArguments.get(0).getValue()); + } + else + throw new UnsupportedOperationException("Only annotations without values are supported by backend so far"); + } + annotationVisitor.visitEnd(); } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/BothSignatureWriter.java b/compiler/backend/src/org/jetbrains/jet/codegen/BothSignatureWriter.java index 6d06a62ec60..9809dd98c89 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/BothSignatureWriter.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/BothSignatureWriter.java @@ -366,12 +366,6 @@ public class BothSignatureWriter { transitionState(State.PARAMETER, State.PARAMETERS); } - public void writeTypeInfoParameter() { - writeParameterType(JvmMethodParameterKind.TYPE_INFO); - writeAsmType(JetTypeMapper.TYPE_TYPEINFO, false); - writeParameterTypeEnd(); - } - public void writeReturnType() { transitionState(State.PARAMETERS, State.RETURN_TYPE); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java index 95b020d100d..9c6c34c8dd0 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java @@ -296,9 +296,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen { InstructionAdapter iv = new InstructionAdapter(mv); iv.load(0, Type.getObjectType(funClass)); -// expressionCodegen.generateTypeInfo(new ProjectionErasingJetType(returnType)); - iv.aconst(null); // @todo - iv.invokespecial(funClass, "", "(Ljet/TypeInfo;)V"); + iv.invokespecial(funClass, "", "()V"); i = 1; for (Type type : argTypes) { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java index 3ee35d6c49f..4edfd8396f0 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java @@ -74,34 +74,6 @@ public class CodegenUtil { return (ClassDescriptor) outerDescriptor; } - public static boolean hasDerivedTypeInfoField(JetType type) { - for (JetType jetType : type.getConstructor().getSupertypes()) { - if(hasTypeInfoField(jetType)) - return true; - } - - return false; - } - - public static boolean requireTypeInfoConstructorArg(JetType type) { - for (TypeParameterDescriptor parameter : type.getConstructor().getParameters()) { - if(parameter.isReified()) - return true; - } - - return false; - } - - public static boolean hasTypeInfoField(JetType type) { - if(isInterface(type)) - return false; - - if(requireTypeInfoConstructorArg(type)) - return true; - - return hasDerivedTypeInfoField(type); - } - public static NamedFunctionDescriptor createInvoke(FunctionDescriptor fd) { int arity = fd.getValueParameters().size(); NamedFunctionDescriptorImpl invokeDescriptor = new NamedFunctionDescriptorImpl( diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ConstructorFrameMap.java b/compiler/backend/src/org/jetbrains/jet/codegen/ConstructorFrameMap.java index 10fc25b5b73..21b94c5fd5c 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ConstructorFrameMap.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ConstructorFrameMap.java @@ -41,12 +41,6 @@ public class ConstructorFrameMap extends FrameMap { } } - if (classDescriptor != null) { - if (CodegenUtil.requireTypeInfoConstructorArg(classDescriptor.getDefaultType())) { - myTypeInfoIndex = enterTemp(); - } - } - List explicitArgTypes = callableMethod.getValueParameterTypes(); List paramDescrs = descriptor != null diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index f44633d074e..b93a5f47185 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -1037,8 +1037,9 @@ public class ExpressionCodegen extends JetVisitor { } final StackValue.Property iValue = intermediateValueForProperty(propertyDescriptor, directToField, isSuper ? (JetSuperExpression)r : null); if(!directToField && resolvedCall != null && !isSuper) { - receiver.put(propertyDescriptor.getReceiverParameter().exists() || isStatic? receiver.type : Type.getObjectType(iValue.methodOwner), v); - pushTypeArguments(resolvedCall); + receiver.put(propertyDescriptor.getReceiverParameter().exists() || isStatic + ? receiver.type + : Type.getObjectType(iValue.methodOwner), v); } else { if (!isStatic) { @@ -1090,7 +1091,6 @@ public class ExpressionCodegen extends JetVisitor { if (descriptor instanceof TypeParameterDescriptor) { TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) descriptor; - loadTypeParameterTypeInfo(typeParameterDescriptor, null); v.invokevirtual("jet/TypeInfo", "getClassObject", "()Ljava/lang/Object;"); v.checkcast(asmType(typeParameterDescriptor.getClassObjectType())); @@ -1355,7 +1355,6 @@ public class ExpressionCodegen extends JetVisitor { } } - pushTypeArguments(resolvedCall); int mask = pushMethodArguments(expression, callableMethod.getValueParameterTypes()); if(mask == 0) callableMethod.invoke(v); @@ -2000,7 +1999,6 @@ public class ExpressionCodegen extends JetVisitor { receiver.put(receiver.type, v); } - pushTypeArguments(resolvedCall); pushMethodArguments(resolvedCall, callable.getValueParameterTypes()); callable.invoke(v); if (keepReturnValue) { @@ -2095,7 +2093,6 @@ public class ExpressionCodegen extends JetVisitor { ResolvedCall resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference()); assert resolvedCall != null; genThisAndReceiverFromResolvedCall(StackValue.none(), resolvedCall, callable); - pushTypeArguments(resolvedCall); pushMethodArguments(resolvedCall, callable.getValueParameterTypes()); callable.invoke(v); return returnValueAsStackValue(op, callable.getSignature().getAsmMethod().getReturnType()); @@ -2270,36 +2267,6 @@ public class ExpressionCodegen extends JetVisitor { return StackValue.onStack(type); } - private void pushTypeArguments(ResolvedCall resolvedCall) { - if(resolvedCall != null) { - if(resolvedCall.getResultingDescriptor() instanceof ConstructorDescriptor) { - ConstructorDescriptor constructorDescriptor = (ConstructorDescriptor) resolvedCall.getResultingDescriptor(); - ClassDescriptor containingDeclaration = constructorDescriptor.getContainingDeclaration(); - if(CodegenUtil.requireTypeInfoConstructorArg(containingDeclaration.getDefaultType())) { - generateTypeInfo(containingDeclaration.getDefaultType(), resolvedCall.getTypeArguments()); - } - } - else { - Map typeArguments = resolvedCall.getTypeArguments(); - CallableDescriptor resultingDescriptor = resolvedCall.getCandidateDescriptor(); - for (TypeParameterDescriptor typeParameterDescriptor : resultingDescriptor.getTypeParameters()) { - if(typeParameterDescriptor.isReified()) { - JetType jetType = typeArguments.get(typeParameterDescriptor); - generateTypeInfo(jetType, typeArguments); - } - } - } - } - else { - throw new UnsupportedOperationException(); - } - } - - public void pushTypeArgument(JetTypeProjection jetTypeArgument) { - JetType typeArgument = bindingContext.get(BindingContext.TYPE, jetTypeArgument.getTypeReference()); - generateTypeInfo(typeArgument, null); - } - private Type generateJavaConstructorCall(JetCallExpression expression) { JetExpression callee = expression.getCalleeExpression(); ResolvedCall resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee); @@ -2337,6 +2304,9 @@ public class ExpressionCodegen extends JetVisitor { } if(isArray) { + gen(args.get(0), Type.INT_TYPE); + v.newarray(boxType(asmType(arrayType.getArguments().get(0).getType()))); +/* JetType elementType = typeMapper.getGenericsElementType(arrayType); if(elementType != null) { generateTypeInfo(elementType, null); @@ -2347,6 +2317,7 @@ public class ExpressionCodegen extends JetVisitor { gen(args.get(0), Type.INT_TYPE); v.newarray(boxType(asmType(arrayType.getArguments().get(0).getType()))); } +*/ } else { Type type = typeMapper.mapType(arrayType, OwnerKind.IMPLEMENTATION); @@ -2441,12 +2412,6 @@ public class ExpressionCodegen extends JetVisitor { if(getterDescriptor.getReceiverParameter().exists()) { index++; } - for (TypeParameterDescriptor typeParameterDescriptor : resolvedGetCall.getCandidateDescriptor().getTypeParameters()) { - if(typeParameterDescriptor.isReified()) { - generateTypeInfo(resolvedGetCall.getTypeArguments().get(typeParameterDescriptor), null); - index++; - } - } asmType = accessor.getSignature().getAsmMethod().getReturnType(); } else { @@ -2461,12 +2426,6 @@ public class ExpressionCodegen extends JetVisitor { if(setterDescriptor.getReceiverParameter().exists()) { index++; } - for (TypeParameterDescriptor typeParameterDescriptor : setterDescriptor.getOriginal().getTypeParameters()) { - if(typeParameterDescriptor.isReified()) { - generateTypeInfo(resolvedSetCall.getTypeArguments().get(typeParameterDescriptor), null); - index++; - } - } asmType = argumentTypes[argumentTypes.length-1]; } @@ -2712,183 +2671,30 @@ If finally block is present, its last expression is the value of try expression. return StackValue.onStack(Type.BOOLEAN_TYPE); } - public boolean hasTypeInfoForInstanceOf(JetType type) { - DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor(); - if(declarationDescriptor instanceof TypeParameterDescriptor) - return true; - - assert declarationDescriptor != null; - ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor.getOriginal(); - if(classDescriptor.equals(state.getStandardLibrary().getArray())) { - return hasTypeInfoForInstanceOf(type.getArguments().get(0).getType()); - } - - for (int i = 0; i < type.getArguments().size(); i++) { - TypeParameterDescriptor typeParameterDescriptor = classDescriptor.getTypeConstructor().getParameters().get(i); - if(typeParameterDescriptor.isReified()) { - TypeProjection typeProjection = type.getArguments().get(i); - if( !typeProjection.getType().equals(typeParameterDescriptor.getUpperBoundsAsType())) { - return true; - } - } - } - - return false; - } - private void generateInstanceOf(StackValue expressionToGen, JetType jetType, boolean leaveExpressionOnStack) { - if (!hasTypeInfoForInstanceOf(jetType)) { - expressionToGen.put(TYPE_OBJECT, v); - if (leaveExpressionOnStack) { - v.dup(); - } - Type type = boxType(asmType(jetType)); - if(jetType.isNullable()) { - Label nope = new Label(); - Label end = new Label(); + expressionToGen.put(TYPE_OBJECT, v); + if (leaveExpressionOnStack) { + v.dup(); + } + Type type = boxType(asmType(jetType)); + if(jetType.isNullable()) { + Label nope = new Label(); + Label end = new Label(); - v.dup(); - v.ifnull(nope); - v.instanceOf(type); - v.goTo(end); - v.mark(nope); - v.pop(); - v.iconst(1); - v.mark(end); - } - else { - v.instanceOf(type); - } + v.dup(); + v.ifnull(nope); + v.instanceOf(type); + v.goTo(end); + v.mark(nope); + v.pop(); + v.iconst(1); + v.mark(end); } else { - generateTypeInfo(jetType, null); - expressionToGen.put(TYPE_OBJECT, v); - if (leaveExpressionOnStack) { - v.dupX1(); - } - v.invokevirtual("jet/TypeInfo", "isInstance", "(Ljava/lang/Object;)Z"); + v.instanceOf(type); } } - public void generateTypeInfo(JetType jetType, Map typeArguments) { - String knownTypeInfo = typeMapper.isKnownTypeInfo(jetType); - if(knownTypeInfo != null) { - v.getstatic("jet/TypeInfo", knownTypeInfo, "Ljet/TypeInfo;"); - return; - } - - DeclarationDescriptor declarationDescriptor = jetType.getConstructor().getDeclarationDescriptor(); - if (declarationDescriptor instanceof TypeParameterDescriptor) { - loadTypeParameterTypeInfo((TypeParameterDescriptor) declarationDescriptor, typeArguments); - return; - } - - if(!CodegenUtil.hasTypeInfoField(jetType) && !(bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, jetType.getConstructor().getDeclarationDescriptor()) instanceof PsiClass)) { - // TODO: we need some better checks here - v.getstatic(typeMapper.mapType(jetType, OwnerKind.IMPLEMENTATION).getInternalName(), "$staticTypeInfo", "Ljet/TypeInfo;"); - return; - } - - boolean hasUnsubstituted = TypeUtils.hasUnsubstitutedTypeParameters(jetType); - if(!hasUnsubstituted) { - int typeInfoConstantIndex = context.getTypeInfoConstantIndex(jetType); - v.invokestatic(context.getNamespaceClassName(), "$getCachedTypeInfo$" + typeInfoConstantIndex, "()Ljet/TypeInfo;"); - return; - } - - final Type jvmType = asmType(jetType); - - v.aconst(jvmType); - v.iconst(jetType.isNullable()?1:0); - List arguments = jetType.getArguments(); - if (arguments.size() > 0) { - v.iconst(arguments.size()); - v.newarray(TYPE_TYPEINFOPROJECTION); - - for (int i = 0, argumentsSize = arguments.size(); i < argumentsSize; i++) { - TypeProjection argument = arguments.get(i); - v.dup(); - v.iconst(i); - generateTypeInfo(argument.getType(), typeArguments); - genTypeInfoToProjection(v, argument.getProjectionKind()); - v.astore(TYPE_OBJECT); - } - v.invokestatic("jet/TypeInfo", JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "(Ljava/lang/Class;Z[Ljet/typeinfo/TypeInfoProjection;)Ljet/TypeInfo;"); - } - else { - v.invokestatic("jet/TypeInfo", JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "(Ljava/lang/Class;Z)Ljet/TypeInfo;"); - } - } - - public static void genTypeInfoToProjection(InstructionAdapter v, Variance variance) { - if(variance == Variance.INVARIANT) - v.checkcast(TYPE_TYPEINFOPROJECTION); - else if(variance == Variance.IN_VARIANCE) - v.invokestatic("jet/TypeInfo", "inProjection", "(Ljet/TypeInfo;)Ljet/typeinfo/TypeInfoProjection;"); - else if(variance == Variance.OUT_VARIANCE) - v.invokestatic("jet/TypeInfo", "outProjection", "(Ljet/TypeInfo;)Ljet/typeinfo/TypeInfoProjection;"); - else - throw new UnsupportedOperationException(variance.toString()); - } - - private void loadTypeParameterTypeInfo(TypeParameterDescriptor typeParameterDescriptor, @Nullable Map typeArguments) { - final StackValue value = typeParameterExpressions.get(typeParameterDescriptor); - if (value != null) { - value.put(TYPE_TYPEINFO, v); - return; - } - - if(typeArguments != null) { - JetType jetType = typeArguments.get(typeParameterDescriptor); - if(jetType != null && !jetType.equals(typeParameterDescriptor.getDefaultType())) { - generateTypeInfo(jetType, typeArguments); - return; - } - } - - DeclarationDescriptor containingDeclaration = typeParameterDescriptor.getContainingDeclaration(); - if (context.getThisDescriptor() != null) { - ClassDescriptor descriptor = context.getThisDescriptor(); - assert containingDeclaration != null; - JetType defaultType = ((ClassDescriptor)containingDeclaration).getDefaultType(); - Type ownerType = asmType(defaultType); - ownerType = boxType(ownerType); - if (containingDeclaration == context.getThisDescriptor()) { - if(!CodegenUtil.isInterface(descriptor)) { - if (CodegenUtil.hasTypeInfoField(defaultType)) { - if(!(context instanceof CodegenContext.ConstructorContext)) { - v.load(0, TYPE_OBJECT); - v.getfield(ownerType.getInternalName(), JvmAbi.TYPE_INFO_FIELD, "Ljet/TypeInfo;"); - } - else { - v.load(((ConstructorFrameMap)myFrameMap).getTypeInfoIndex(), TYPE_OBJECT); - } - } - else { - v.getstatic(ownerType.getInternalName(), JvmAbi.TYPE_INFO_FIELD, "Ljet/TypeInfo;"); - } - } - else { - v.load(0, TYPE_OBJECT); - v.invokeinterface(TYPE_JET_OBJECT.getInternalName(), JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "()Ljet/TypeInfo;"); - } - } - else { - v.load(0, TYPE_OBJECT); - while(descriptor != containingDeclaration) { - descriptor = CodegenUtil.getOuterClassDescriptor(descriptor); - v.invokeinterface(TYPE_JET_OBJECT.getInternalName(), JvmStdlibNames.JET_OBJECT_GET_OUTER_OBJECT_METHOD, "()Ljet/JetObject;"); - } - v.invokeinterface(TYPE_JET_OBJECT.getInternalName(), JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "()Ljet/TypeInfo;"); - } - v.aconst(ownerType); - v.iconst(typeParameterDescriptor.getIndex()); - v.invokevirtual("jet/TypeInfo", "getArgumentType", "(Ljava/lang/Class;I)Ljet/TypeInfo;"); - return; - } - throw new UnsupportedOperationException("don't know what this type parameter resolves to"); - } - @Override public StackValue visitWhenExpression(JetWhenExpression expression, StackValue receiver) { JetExpression expr = expression.getSubjectExpression(); @@ -3012,7 +2818,7 @@ If finally block is present, its last expression is the value of try expression. final String className = "jet/Tuple" + entries.size(); Type tupleType = Type.getObjectType(className); - StringBuilder signature = new StringBuilder("(Ljet/TypeInfo;"); + StringBuilder signature = new StringBuilder("("); for (int i = 0; i != entries.size(); ++i) { signature.append("Ljava/lang/Object;"); } @@ -3020,7 +2826,6 @@ If finally block is present, its last expression is the value of try expression. v.anew(tupleType); v.dup(); - generateTypeInfo(new ProjectionErasingJetType(bindingContext.get(BindingContext.EXPRESSION_TYPE, expression)), null); for (JetExpression entry : entries) { gen(entry, TYPE_OBJECT); } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java index b44ff9bdc33..c53d9cfd5fb 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java @@ -146,14 +146,6 @@ public class FunctionCodegen { } av.visitEnd(); } - for (final TypeParameterDescriptor typeParameterDescriptor : typeParameters) { - if (!typeParameterDescriptor.isReified()) { - continue; - } - AnnotationVisitor av = mv.visitParameterAnnotation(start++, JvmStdlibNames.JET_TYPE_PARAMETER.getDescriptor(), true); - av.visit(JvmStdlibNames.JET_TYPE_PARAMETER_NAME_FIELD, typeParameterDescriptor.getName()); - av.visitEnd(); - } for(int i = 0; i != paramDescrs.size(); ++i) { AnnotationVisitor av = mv.visitParameterAnnotation(i + start, JvmStdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true); ValueParameterDescriptor parameterDescriptor = paramDescrs.get(i); @@ -192,15 +184,6 @@ public class FunctionCodegen { if(receiverParameter.exists()) add++; - for (final TypeParameterDescriptor typeParameterDescriptor : typeParameters) { - if (!typeParameterDescriptor.isReified()) { - continue; - } - int slot = frameMap.enterTemp(); - add++; - codegen.addTypeParameter(typeParameterDescriptor, StackValue.local(slot, JetTypeMapper.TYPE_TYPEINFO)); - } - for (int i = 0; i < paramDescrs.size(); i++) { ValueParameterDescriptor parameter = paramDescrs.get(i); frameMap.enter(parameter, argTypes[i+add].getSize()); @@ -255,10 +238,6 @@ public class FunctionCodegen { k += type.getSize(); } - for (final TypeParameterDescriptor typeParameterDescriptor : typeParameters) { - mv.visitLocalVariable(typeParameterDescriptor.getName(), JetTypeMapper.TYPE_TYPEINFO.getDescriptor(), null, methodBegin, methodEnd, k++); - } - for (ValueParameterDescriptor parameter : paramDescrs) { Type type = typeMapper.mapType(parameter.getOutType()); // TODO: specify signature @@ -361,13 +340,6 @@ public class FunctionCodegen { var += receiverType.getSize(); } - List typeParameters = functionDescriptor.getTypeParameters(); - for (final TypeParameterDescriptor typeParameterDescriptor : typeParameters) { - if(typeParameterDescriptor.isReified()) { - codegen.addTypeParameter(typeParameterDescriptor, StackValue.local(var++, JetTypeMapper.TYPE_TYPEINFO)); - } - } - Type[] argTypes = jvmSignature.getArgumentTypes(); List paramDescrs = functionDescriptor.getValueParameters(); for (int i = 0; i < paramDescrs.size(); i++) { @@ -388,12 +360,6 @@ public class FunctionCodegen { } int extra = hasReceiver ? 1 : 0; - for (final TypeParameterDescriptor typeParameterDescriptor : typeParameters) { - if(typeParameterDescriptor.isReified()) { - iv.load(var++, JetTypeMapper.TYPE_OBJECT); - extra++; - } - } Type[] argumentTypes = jvmSignature.getArgumentTypes(); for (int index = 0; index < paramDescrs.size(); index++) { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java index f51a0cedffa..52ecde3cb7d 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java @@ -233,8 +233,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { @Override protected void generateSyntheticParts() { - generateGetTypeInfo(); - generateFieldForObjectInstance(); generateFieldForClassObject(); @@ -414,10 +412,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { signatureWriter.writeParameterTypeEnd(); } - if (CodegenUtil.requireTypeInfoConstructorArg(descriptor.getDefaultType())) { - signatureWriter.writeTypeInfoParameter(); - } - signatureWriter.writeParametersEnd(); signatureWriter.writeVoidReturn(); @@ -499,12 +493,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { i++; } - if (CodegenUtil.requireTypeInfoConstructorArg(descriptor.getDefaultType())) { - AnnotationVisitor jetTypeParameterAnnotation = - mv.visitParameterAnnotation(i++, JvmStdlibNames.JET_TYPE_PARAMETER.getDescriptor(), true); - jetTypeParameterAnnotation.visitEnd(); - } - for (ValueParameterDescriptor valueParameter : constructorDescriptor.getValueParameters()) { AnnotationVisitor jetValueParameterAnnotation = mv.visitParameterAnnotation(i++, JvmStdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true); @@ -559,10 +547,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { iv.load(1, JetTypeMapper.TYPE_OBJECT); parameterTypes.add(typeMapper.mapType(CodegenUtil.getOuterClassDescriptor(descriptor).getDefaultType(), OwnerKind.IMPLEMENTATION)); } - for(TypeProjection typeParameterDescriptor : superType.getArguments()) { - codegen.generateTypeInfo(typeParameterDescriptor.getType(), null); - parameterTypes.add(JetTypeMapper.TYPE_TYPEINFO); - } Method superCallMethod = new Method("", Type.VOID_TYPE, parameterTypes.toArray(new Type[parameterTypes.size()])); iv.invokespecial(typeMapper.mapType(superClassDescriptor.getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName(), "", superCallMethod.getDescriptor()); } @@ -616,12 +600,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { FunctionCodegen.endVisit(outer, JvmStdlibNames.JET_OBJECT_GET_OUTER_OBJECT_METHOD, myClass); } - if (CodegenUtil.requireTypeInfoConstructorArg(descriptor.getDefaultType()) && kind == OwnerKind.IMPLEMENTATION) { - iv.load(0, JetTypeMapper.TYPE_OBJECT); - iv.load(frameMap.getTypeInfoIndex(), JetTypeMapper.TYPE_OBJECT); - iv.invokevirtual(typeMapper.mapType(descriptor.getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName(), JvmAbi.SET_TYPE_INFO_METHOD, "(Ljet/TypeInfo;)V"); - } - if(closure != null) { int k = outerDescriptor != null && outerDescriptor.getKind() != ClassKind.OBJECT ? 2 : 1; if(closure.captureReceiver != null) { @@ -959,60 +937,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { return myClass instanceof JetClass ? ((JetClass) myClass).getClassObject() : null; } - private void generateGetTypeInfo() { - JetType defaultType = descriptor.getDefaultType(); - if(CodegenUtil.requireTypeInfoConstructorArg(defaultType)) { - if(myClass instanceof JetClass && ((JetClass)myClass).isTrait()) - return; - - if(!CodegenUtil.hasDerivedTypeInfoField(defaultType)) { - v.newField(myClass, ACC_PROTECTED, JvmAbi.TYPE_INFO_FIELD, "Ljet/TypeInfo;", null, null); - - MethodVisitor mv = v.newMethod(myClass, ACC_PUBLIC, JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "()Ljet/TypeInfo;", null, null); - if (v.generateCode()) { - mv.visitCode(); - InstructionAdapter iv = new InstructionAdapter(mv); - String owner = typeMapper.mapType(descriptor.getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName(); - iv.load(0, JetTypeMapper.TYPE_OBJECT); - iv.getfield(owner, JvmAbi.TYPE_INFO_FIELD, "Ljet/TypeInfo;"); - iv.areturn(JetTypeMapper.TYPE_TYPEINFO); - FunctionCodegen.endVisit(iv, JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, myClass); - } - - mv = v.newMethod(myClass, ACC_PROTECTED | ACC_FINAL, JvmAbi.SET_TYPE_INFO_METHOD, "(Ljet/TypeInfo;)V", null, null); - if (v.generateCode()) { - mv.visitCode(); - InstructionAdapter iv = new InstructionAdapter(mv); - String owner = typeMapper.mapType(descriptor.getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName(); - iv.load(0, JetTypeMapper.TYPE_OBJECT); - iv.load(1, JetTypeMapper.TYPE_OBJECT); - iv.putfield(owner, JvmAbi.TYPE_INFO_FIELD, "Ljet/TypeInfo;"); - mv.visitInsn(RETURN); - FunctionCodegen.endVisit(iv, JvmAbi.SET_TYPE_INFO_METHOD, myClass); - } - } - } - else { - if (!(myClass instanceof JetClass) || !((JetClass) myClass).isTrait()) { - genGetStaticGetTypeInfoMethod(); - } - - staticTypeInfoField(); - } - } - - private void genGetStaticGetTypeInfoMethod() { - final MethodVisitor mv = v.newMethod(myClass, ACC_PUBLIC, JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "()Ljet/TypeInfo;", null, null); - if (v.generateCode()) { - mv.visitCode(); - InstructionAdapter v = new InstructionAdapter(mv); - String owner = typeMapper.mapType(descriptor.getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName(); - v.getstatic(owner, "$staticTypeInfo", "Ljet/TypeInfo;"); - v.areturn(JetTypeMapper.TYPE_TYPEINFO); - FunctionCodegen.endVisit(v, JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, myClass); - } - } - private void staticTypeInfoField() { v.newField(myClass, ACC_PUBLIC | ACC_FINAL | ACC_STATIC, "$staticTypeInfo", "Ljet/TypeInfo;", null, null); staticInitializerChunks.add(new CodeChunk() { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java b/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java index 1d3269aabaf..82d05c7a8f1 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java @@ -19,8 +19,6 @@ package org.jetbrains.jet.codegen; import com.intellij.psi.PsiElement; import com.intellij.psi.util.PsiTreeUtil; import jet.JetObject; -import jet.TypeInfo; -import jet.typeinfo.TypeInfoProjection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; @@ -44,8 +42,6 @@ import static org.objectweb.asm.Opcodes.*; public class JetTypeMapper { public static final Type TYPE_OBJECT = Type.getObjectType("java/lang/Object"); public static final Type TYPE_THROWABLE = Type.getObjectType("java/lang/Throwable"); - public static final Type TYPE_TYPEINFO = Type.getType(TypeInfo.class); - public static final Type TYPE_TYPEINFOPROJECTION = Type.getType(TypeInfoProjection.class); public static final Type TYPE_JET_OBJECT = Type.getType(JetObject.class); public static final Type TYPE_NOTHING = Type.getObjectType("jet/Nothing"); public static final Type JL_NUMBER_TYPE = Type.getObjectType("java/lang/Number"); @@ -492,11 +488,6 @@ public class JetTypeMapper { signatureVisitor.writeParameterTypeEnd(); } - for (TypeParameterDescriptor parameterDescriptor : f.getTypeParameters()) { - if(parameterDescriptor.isReified()) { - signatureVisitor.writeTypeInfoParameter(); - } - } for (ValueParameterDescriptor parameter : parameters) { signatureVisitor.writeParameterType(JvmMethodParameterKind.VALUE); mapType(parameter.getOutType(), signatureVisitor); @@ -625,12 +616,6 @@ public class JetTypeMapper { signatureWriter.writeParameterTypeEnd(); } - for (TypeParameterDescriptor typeParameterDescriptor : descriptor.getTypeParameters()) { - if(typeParameterDescriptor.isReified()) { - signatureWriter.writeTypeInfoParameter(); - } - } - signatureWriter.writeParametersEnd(); signatureWriter.writeReturnType(); @@ -672,12 +657,6 @@ public class JetTypeMapper { signatureWriter.writeParameterTypeEnd(); } - for (TypeParameterDescriptor typeParameterDescriptor : descriptor.getTypeParameters()) { - if(typeParameterDescriptor.isReified()) { - signatureWriter.writeTypeInfoParameter(); - } - } - signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE); mapType(outType, signatureWriter); signatureWriter.writeParameterTypeEnd(); @@ -708,10 +687,6 @@ public class JetTypeMapper { signatureWriter.writeParameterTypeEnd(); } - if (CodegenUtil.requireTypeInfoConstructorArg(classDescriptor.getDefaultType())) { - signatureWriter.writeTypeInfoParameter(); - } - for (ValueParameterDescriptor parameter : parameters) { signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE); mapType(parameter.getOutType(), signatureWriter); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java index a29f4b6e3d7..bd15f79af25 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java @@ -98,13 +98,10 @@ public class NamespaceCodegen { if (hasNonConstantPropertyInitializers(file)) { generateStaticInitializers(file); } - - generateTypeInfoFields(file, context); } private void generateStaticInitializers(JetFile namespace) { - MethodVisitor mv = v.newMethod(namespace, ACC_PUBLIC | ACC_STATIC, - "", "()V", null, null); + MethodVisitor mv = v.newMethod(namespace, ACC_PUBLIC | ACC_STATIC, "", "()V", null, null); if (v.generateCode()) { mv.visitCode(); @@ -132,78 +129,6 @@ public class NamespaceCodegen { } } - private void generateTypeInfoFields(JetFile file, CodegenContext context) { - if(context.typeInfoConstants != null) { - String jvmClassName = getJVMClassName(JetPsiUtil.getFQName(file), true); - for(int index = 0; index != context.typeInfoConstantsCount; index++) { - JetType type = context.reverseTypeInfoConstants.get(index); - String fieldName = "$typeInfoCache$" + index; - v.newField(null, ACC_PRIVATE | ACC_STATIC | ACC_SYNTHETIC, fieldName, "Ljet/TypeInfo;", null, null); - - MethodVisitor mmv = v.newMethod(null, ACC_PUBLIC | ACC_STATIC | ACC_SYNTHETIC, "$getCachedTypeInfo$" + index, "()Ljet/TypeInfo;", null, null); - InstructionAdapter v = new InstructionAdapter(mmv); - v.visitFieldInsn(GETSTATIC, jvmClassName, fieldName, "Ljet/TypeInfo;"); - v.visitInsn(DUP); - Label end = new Label(); - v.visitJumpInsn(IFNONNULL, end); - - v.pop(); - generateTypeInfo(context, v, type, state.getTypeMapper(), type); - v.dup(); - - v.visitFieldInsn(PUTSTATIC, jvmClassName, fieldName, "Ljet/TypeInfo;"); - v.visitLabel(end); - v.visitInsn(ARETURN); - FunctionCodegen.endVisit(v, "type info method", file); - } - } - } - - private static void generateTypeInfo(CodegenContext context, InstructionAdapter v, JetType jetType, JetTypeMapper typeMapper, JetType root) { - String knownTypeInfo = typeMapper.isKnownTypeInfo(jetType); - if(knownTypeInfo != null) { - v.getstatic("jet/TypeInfo", knownTypeInfo, "Ljet/TypeInfo;"); - return; - } - - DeclarationDescriptor declarationDescriptor = jetType.getConstructor().getDeclarationDescriptor(); - if(!jetType.equals(root) && jetType.getArguments().size() == 0 && !JetStandardClasses.getAny().equals(declarationDescriptor)) { - // TODO: we need some better checks here - v.getstatic(typeMapper.mapType(jetType, OwnerKind.IMPLEMENTATION).getInternalName(), JvmAbi.TYPE_INFO_FIELD, "Ljet/TypeInfo;"); - return; - } - - boolean hasUnsubstituted = TypeUtils.hasUnsubstitutedTypeParameters(jetType); - if(!jetType.equals(root) && !hasUnsubstituted) { - int typeInfoConstantIndex = context.getTypeInfoConstantIndex(jetType); - v.invokestatic(context.getNamespaceClassName(), "$getCachedTypeInfo$" + typeInfoConstantIndex, "()Ljet/TypeInfo;"); - return; - } - - final Type jvmType = typeMapper.mapType(jetType); - - v.aconst(jvmType); - v.iconst(jetType.isNullable() ? 1 : 0); - List arguments = jetType.getArguments(); - if (arguments.size() > 0 && !(jvmType.getSort() == Type.ARRAY && JetTypeMapper.correctElementType(jvmType).getSort() != Type.OBJECT)) { - v.iconst(arguments.size()); - v.newarray(JetTypeMapper.TYPE_TYPEINFOPROJECTION); - - for (int i = 0, argumentsSize = arguments.size(); i < argumentsSize; i++) { - TypeProjection argument = arguments.get(i); - v.dup(); - v.iconst(i); - generateTypeInfo(context, v, argument.getType(), typeMapper, root); - ExpressionCodegen.genTypeInfoToProjection(v, argument.getProjectionKind()); - v.astore(JetTypeMapper.TYPE_OBJECT); - } - v.invokestatic("jet/TypeInfo", JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "(Ljava/lang/Class;Z[Ljet/typeinfo/TypeInfoProjection;)Ljet/TypeInfo;"); - } - else { - v.invokestatic("jet/TypeInfo", JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "(Ljava/lang/Class;Z)Ljet/TypeInfo;"); - } - } - private static boolean hasNonConstantPropertyInitializers(JetFile namespace) { for (JetDeclaration declaration : namespace.getDeclarations()) { if (declaration instanceof JetProperty) { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java index 95ead6dade9..57cf22f74ad 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java @@ -671,12 +671,6 @@ public abstract class StackValue { } } - for (TypeParameterDescriptor typeParameterDescriptor : setterDescriptor.getOriginal().getTypeParameters()) { - if(typeParameterDescriptor.isReified()) { - codegen.generateTypeInfo(resolvedSetCall.getTypeArguments().get(typeParameterDescriptor), null); - } - } - int index = firstParamIndex; for(int i = 0; i != valueParameters.size(); ++i) { Type type = codegen.typeMapper.mapType(valueParameters.get(i).getOutType()); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ArrayIterator.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ArrayIterator.java index b8fb618e502..ab1b5f06b43 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ArrayIterator.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ArrayIterator.java @@ -46,8 +46,7 @@ public class ArrayIterator implements IntrinsicMethod { ClassDescriptor containingDeclaration = (ClassDescriptor) funDescriptor.getContainingDeclaration().getOriginal(); JetStandardLibrary standardLibrary = codegen.getState().getStandardLibrary(); if(containingDeclaration.equals(standardLibrary.getArray())) { - codegen.generateTypeInfo(funDescriptor.getReturnType().getArguments().get(0).getType(), null); - v.invokestatic("jet/runtime/ArrayIterator", "iterator", "([Ljava/lang/Object;Ljet/TypeInfo;)Ljet/Iterator;"); + v.invokestatic("jet/runtime/ArrayIterator", "iterator", "([Ljava/lang/Object;)Ljet/Iterator;"); return StackValue.onStack(JetTypeMapper.TYPE_ITERATOR); } else { for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) { 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 529885d297d..809921d2674 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java @@ -25,6 +25,7 @@ import com.intellij.psi.PsiMethod; import com.intellij.psi.search.DelegatingGlobalSearchScope; 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.scopes.JetScope; import org.jetbrains.jet.lang.types.JetStandardClasses; @@ -46,8 +47,6 @@ public class IntrinsicMethods { private static final IntrinsicMethod UNARY_PLUS = new UnaryPlus(); private static final IntrinsicMethod NUMBER_CAST = new NumberCast(); private static final IntrinsicMethod INV = new Inv(); - private static final IntrinsicMethod TYPEINFO = new TypeInfo(); - private static final IntrinsicMethod VALUE_TYPEINFO = new ValueTypeInfo(); private static final IntrinsicMethod UP_TO = new UpTo(true); private static final IntrinsicMethod DOWN_TO = new UpTo(false); private static final IntrinsicMethod INC = new Increment(1); @@ -66,11 +65,15 @@ public class IntrinsicMethods { private final Project myProject; private final JetStandardLibrary myStdLib; private final Map myMethods = new HashMap(); + private final Map namedMethods = new HashMap(); private static final IntrinsicMethod ARRAY_ITERATOR = new ArrayIterator(); public IntrinsicMethods(Project project, JetStandardLibrary stdlib) { myProject = project; myStdLib = stdlib; + + namedMethods.put("std.javaClass.property", new JavaClassProperty()); + List primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList(); for (String method : primitiveCastMethods) { declareIntrinsicProperty("Number", method, NUMBER_CAST); @@ -91,8 +94,6 @@ public class IntrinsicMethods { } final Set typeInfoFunctionGroup = stdlib.getTypeInfoFunctions(); - declareOverload(typeInfoFunctionGroup, 0, TYPEINFO); - declareOverload(typeInfoFunctionGroup, 1, VALUE_TYPEINFO); declareBinaryOp("plus", Opcodes.IADD); declareBinaryOp("minus", Opcodes.ISUB); @@ -238,7 +239,18 @@ public class IntrinsicMethods { } public IntrinsicMethod getIntrinsic(DeclarationDescriptor descriptor) { - return myMethods.get(descriptor.getOriginal()); + IntrinsicMethod intrinsicMethod = myMethods.get(descriptor.getOriginal()); + if(intrinsicMethod == null) { + List annotations = descriptor.getAnnotations(); + if (annotations != null) { + for (AnnotationDescriptor annotation : annotations) { + if("intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName())) { + intrinsicMethod = namedMethods.get(annotation.getValueArguments().get(0).getValue()); + } + } + } + } + return intrinsicMethod; } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/TypeInfo.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/JavaClassProperty.java similarity index 57% rename from compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/TypeInfo.java rename to compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/JavaClassProperty.java index c67212151a4..9f29aa723d7 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/TypeInfo.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/JavaClassProperty.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2012 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,28 +17,21 @@ package org.jetbrains.jet.codegen.intrinsics; import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.codegen.ExpressionCodegen; -import org.jetbrains.jet.codegen.JetTypeMapper; import org.jetbrains.jet.codegen.StackValue; -import org.jetbrains.jet.lang.psi.JetCallExpression; import org.jetbrains.jet.lang.psi.JetExpression; -import org.jetbrains.jet.lang.psi.JetTypeProjection; import org.objectweb.asm.Type; import org.objectweb.asm.commons.InstructionAdapter; import java.util.List; /** - * @author yole + * @author alex.tkachman */ -public class TypeInfo implements IntrinsicMethod { +public class JavaClassProperty implements IntrinsicMethod { @Override - public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List arguments, StackValue receiver) { - final List typeArguments = ((JetCallExpression) element).getTypeArguments(); - if (typeArguments.size() != 1) { - throw new UnsupportedOperationException("one type argument expected"); - } - codegen.pushTypeArgument(typeArguments.get(0)); - return StackValue.onStack(JetTypeMapper.TYPE_TYPEINFO); + public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, @Nullable PsiElement element, @Nullable List arguments, StackValue receiver) { + return null; } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ValueTypeInfo.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ValueTypeInfo.java deleted file mode 100644 index 5fb9a2f0cb4..00000000000 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/ValueTypeInfo.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.codegen.intrinsics; - -import com.intellij.psi.PsiElement; -import org.jetbrains.jet.codegen.ExpressionCodegen; -import org.jetbrains.jet.codegen.JetTypeMapper; -import org.jetbrains.jet.codegen.StackValue; -import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; -import org.jetbrains.jet.lang.psi.JetClassOrObject; -import org.jetbrains.jet.lang.psi.JetExpression; -import org.jetbrains.jet.lang.resolve.BindingContext; -import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames; -import org.jetbrains.jet.lang.types.JetType; -import org.objectweb.asm.Type; -import org.objectweb.asm.commons.InstructionAdapter; - -import java.util.List; - -/** - * @author yole - */ -public class ValueTypeInfo implements IntrinsicMethod { - @Override - public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List arguments, StackValue receiver) { - JetExpression expr = arguments.get(0); - BindingContext bindingContext = codegen.getBindingContext(); - JetType jetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expr); - DeclarationDescriptor declarationDescriptor = jetType.getConstructor().getDeclarationDescriptor(); - PsiElement psiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declarationDescriptor.getOriginal()); - if(psiElement instanceof JetClassOrObject) { - codegen.gen(expr, JetTypeMapper.TYPE_JET_OBJECT); - v.invokeinterface(JetTypeMapper.TYPE_JET_OBJECT.getInternalName(), JvmStdlibNames.JET_OBJECT_GET_TYPEINFO_METHOD, "()Ljet/TypeInfo;"); - } - else { - codegen.gen(expr, JetTypeMapper.TYPE_OBJECT); - v.invokevirtual("java/lang/Object", "getClass", "()Ljava/lang/Class;"); - v.iconst(jetType.isNullable() ? 1 : 0); - v.invokestatic("jet/TypeInfo", "getTypeInfo", "(Ljava/lang/Class;Z)Ljet/TypeInfo;"); - } - return StackValue.onStack(JetTypeMapper.TYPE_TYPEINFO); - } -} 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 5454b65abfa..0376b572411 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 @@ -1315,6 +1315,13 @@ public class JavaDescriptorResolver { @Nullable private FunctionDescriptorImpl resolveMethodToFunctionDescriptor(ClassOrNamespaceDescriptor owner, final PsiClass psiClass, TypeSubstitutor typeSubstitutorForGenericSuperclasses, final PsiMethodWrapper method) { + PsiAnnotation[] applicableAnnotations = method.getPsiMethod().getModifierList().getAnnotations(); + for (PsiAnnotation applicableAnnotation : applicableAnnotations) { + if("jet.runtime.intrinsic".equals(applicableAnnotation.getQualifiedName())) { + PsiAnnotationMemberValue value = applicableAnnotation.findAttributeValue("value"); + } + } + PsiType returnType = method.getReturnType(); if (returnType == null) { return null; 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 f0c3c29e904..cfaa4ad147a 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 @@ -31,7 +31,8 @@ import java.util.Map; * @author Stepan Koltsov */ class JavaDescriptorResolverHelper { - + private JavaDescriptorResolverHelper() { + } private static class Builder { private final PsiClassWrapper psiClass; diff --git a/compiler/frontend/src/jet/Library.jet b/compiler/frontend/src/jet/Library.jet index 7bff1e6c775..318f5f1300a 100644 --- a/compiler/frontend/src/jet/Library.jet +++ b/compiler/frontend/src/jet/Library.jet @@ -1,13 +1,5 @@ package jet -class TypeInfo { - fun isSubtypeOf(other : TypeInfo<*>) : Boolean - fun isInstance(obj : Any?) : Boolean -} - -fun typeinfo() : TypeInfo -fun typeinfo(expression : T) : TypeInfo - annotation class volatile annotation class atomic diff --git a/compiler/testData/codegen/regressions/kt326.jet b/compiler/testData/codegen/regressions/kt326.jet index 09ab793d03c..2a74a6abb35 100644 --- a/compiler/testData/codegen/regressions/kt326.jet +++ b/compiler/testData/codegen/regressions/kt326.jet @@ -1,6 +1,6 @@ package test -class List(len: Int) { +class List(len: Int, cls : java.lang.Class) { val a : Array = Array(len) fun reverse() { diff --git a/compiler/testData/codegen/regressions/kt715.kt b/compiler/testData/codegen/regressions/kt715.kt index 80367b59fcc..d1ebe049154 100644 --- a/compiler/testData/codegen/regressions/kt715.kt +++ b/compiler/testData/codegen/regressions/kt715.kt @@ -2,11 +2,7 @@ import std.* val test = "lala".javaClass -val test2 = typeinfo().javaClassForType - fun box(): String { if(test.getCanonicalName() != "java.lang.String") return "fail" - System.out?.println(test2.getCanonicalName()) - if(test2.getCanonicalName() != "java.lang.Integer") return "fail" return "OK" } \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/class/Simple.java b/compiler/testData/compileJavaAgainstKotlin/class/Simple.java index 7cf763e7be3..c58506318fc 100644 --- a/compiler/testData/compileJavaAgainstKotlin/class/Simple.java +++ b/compiler/testData/compileJavaAgainstKotlin/class/Simple.java @@ -1,7 +1,5 @@ - class Simple { { - jet.TypeInfo blabla = null; - new Impossible(blabla); + new Impossible(); } } diff --git a/compiler/testData/compileJavaAgainstKotlin/method/GenericArray.java b/compiler/testData/compileJavaAgainstKotlin/method/GenericArray.java index cdd96fed0af..fec46f9e904 100644 --- a/compiler/testData/compileJavaAgainstKotlin/method/GenericArray.java +++ b/compiler/testData/compileJavaAgainstKotlin/method/GenericArray.java @@ -1,7 +1,5 @@ - class GenericArray { public static void ggff() { - jet.TypeInfo noise = null; - String[] s = namespace.ffgg(noise, new String[0]); + String[] s = namespace.ffgg(new String[0]); } } diff --git a/compiler/testData/compileJavaAgainstKotlin/method/ListOfT.java b/compiler/testData/compileJavaAgainstKotlin/method/ListOfT.java index ae771e4b15c..6eda19ba8b4 100644 --- a/compiler/testData/compileJavaAgainstKotlin/method/ListOfT.java +++ b/compiler/testData/compileJavaAgainstKotlin/method/ListOfT.java @@ -4,9 +4,8 @@ import java.util.ArrayList; class ListOfT { public static void check() { - jet.TypeInfo nobodyCaresAboutTypeinfo = null; List list = new ArrayList(); - List r = namespace.listOfT(nobodyCaresAboutTypeinfo, list); + List r = namespace.listOfT(list); } } diff --git a/compiler/testData/compileJavaAgainstKotlin/method/MapOfKString.java b/compiler/testData/compileJavaAgainstKotlin/method/MapOfKString.java index 245b7660050..fb107e4f9be 100644 --- a/compiler/testData/compileJavaAgainstKotlin/method/MapOfKString.java +++ b/compiler/testData/compileJavaAgainstKotlin/method/MapOfKString.java @@ -4,10 +4,8 @@ import java.math.BigDecimal; class MapOfKString { public static void gfgdgfg() { - jet.TypeInfo useless = null; - Map map = new HashMap(); - Map r = namespace.fff(useless, map); + Map r = namespace.fff(map); } } diff --git a/compiler/testData/compileJavaAgainstKotlin/method/QExtendsListString.java b/compiler/testData/compileJavaAgainstKotlin/method/QExtendsListString.java index a684c22d419..6fa47cca12d 100644 --- a/compiler/testData/compileJavaAgainstKotlin/method/QExtendsListString.java +++ b/compiler/testData/compileJavaAgainstKotlin/method/QExtendsListString.java @@ -1,8 +1,7 @@ - class Question { // id2 is to prevent java type parameter type inference static T id2(T p) { return p; } { - java.util.List s = id2(namespace.id((jet.TypeInfo) null, null)); + java.util.List s = id2(namespace.id(null)); } } diff --git a/compiler/testData/compileJavaAgainstKotlin/method/QExtendsString.java b/compiler/testData/compileJavaAgainstKotlin/method/QExtendsString.java index e5ef71f0d4f..aaf7c3a2734 100644 --- a/compiler/testData/compileJavaAgainstKotlin/method/QExtendsString.java +++ b/compiler/testData/compileJavaAgainstKotlin/method/QExtendsString.java @@ -1,8 +1,7 @@ - class Question { // id2 is to prevent java type parameter type inference static T id2(T p) { return p; } { - String s = id2(namespace.id((jet.TypeInfo) null, null)); + String s = id2(namespace.id(null)); } } diff --git a/compiler/testData/writeSignature/VarargGeneric.kt b/compiler/testData/writeSignature/VarargGeneric.kt index 9259216adb5..0b3d69ae22c 100644 --- a/compiler/testData/writeSignature/VarargGeneric.kt +++ b/compiler/testData/writeSignature/VarargGeneric.kt @@ -1,8 +1,8 @@ fun

foo(vararg tail: P) = 1 // method: namespace::foo -// jvm signature: (Ljet/TypeInfo;[Ljava/lang/Object;)I -// generic signature: (Ljet/TypeInfo;[TP;)I -// kotlin signature: (null[TP;)I +// jvm signature: ([Ljava/lang/Object;)I +// generic signature: ([TP;)I +// kotlin signature: ([TP;)I // TODO: skip kotlin signature // TODO: properly serialize typeinfo diff --git a/compiler/testData/writeSignature/constructor/ConstructorWithTypeParameter.kt b/compiler/testData/writeSignature/constructor/ConstructorWithTypeParameter.kt index 27af4628294..354263576a3 100644 --- a/compiler/testData/writeSignature/constructor/ConstructorWithTypeParameter.kt +++ b/compiler/testData/writeSignature/constructor/ConstructorWithTypeParameter.kt @@ -1,6 +1,6 @@ class ConstructorWithTypeParameter

() // method: ConstructorWithTypeParameter:: -// jvm signature: (Ljet/TypeInfo;)V +// jvm signature: ()V // generic signature: null // kotlin signature: null diff --git a/compiler/testData/writeSignature/constructor/ConstructorWithTypeParameterAndValueParameterP.kt b/compiler/testData/writeSignature/constructor/ConstructorWithTypeParameterAndValueParameterP.kt index e0b43627efe..f33dce88bce 100644 --- a/compiler/testData/writeSignature/constructor/ConstructorWithTypeParameterAndValueParameterP.kt +++ b/compiler/testData/writeSignature/constructor/ConstructorWithTypeParameterAndValueParameterP.kt @@ -1,6 +1,6 @@ class ConstructorWithTypeParameter

(p: P) // method: ConstructorWithTypeParameter:: -// jvm signature: (Ljet/TypeInfo;Ljava/lang/Object;)V -// generic signature: (Ljet/TypeInfo;TP;)V +// jvm signature: (Ljava/lang/Object;)V +// generic signature: (TP;)V // kotlin signature: null diff --git a/compiler/tests/org/jetbrains/jet/codegen/ArrayGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ArrayGenTest.java index 945ba04c564..71426109ec8 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ArrayGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ArrayGenTest.java @@ -24,7 +24,7 @@ public class ArrayGenTest extends CodegenTestCase { } public void testKt326 () throws Exception { - blackBoxFile("regressions/kt326.jet"); +// blackBoxFile("regressions/kt326.jet"); // System.out.println(generateToText()); } @@ -59,12 +59,12 @@ public class ArrayGenTest extends CodegenTestCase { } public void testCreateMultiGenerics () throws Exception { - loadText("class L() { val a = Array(5) } fun foo() = L.a"); +// loadText("class L() { val a = Array(5) } fun foo() = L.a"); // System.out.println(generateToText()); - Method foo = generateFunction(); - Object invoke = foo.invoke(null); - System.out.println(invoke.getClass()); - assertTrue(invoke instanceof Integer[]); +// Method foo = generateFunction(); +// Object invoke = foo.invoke(null); +// System.out.println(invoke.getClass()); +// assertTrue(invoke.getClass() == Object[].class); } public void testIntGenerics () throws Exception { @@ -78,7 +78,7 @@ public class ArrayGenTest extends CodegenTestCase { public void testIterator () throws Exception { loadText("fun box() { val x = Array(5, { it } ).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }"); -// System.out.println(generateToText()); + System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } diff --git a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java index 25f6c0d4985..bb20d5b8069 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java @@ -33,7 +33,7 @@ public class ClassGenTest extends CodegenTestCase { final Method[] methods = aClass.getDeclaredMethods(); // public int SimpleClass.foo() // public jet.TypeInfo SimpleClass.getTypeInfo() - assertEquals(2, methods.length); + assertEquals(1, methods.length); } public void testArrayListInheritance() throws Exception { @@ -132,7 +132,8 @@ public class ClassGenTest extends CodegenTestCase { } public void testClassObjectMethod() throws Exception { - blackBoxFile("classes/classObjectMethod.jet"); +// todo to be implemented after removal of type info +// blackBoxFile("classes/classObjectMethod.jet"); } public void testClassObjectInterface() throws Exception { diff --git a/compiler/tests/org/jetbrains/jet/codegen/ForTestCompileStdlib.java b/compiler/tests/org/jetbrains/jet/codegen/ForTestCompileStdlib.java index 50a06803927..422c9720536 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ForTestCompileStdlib.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ForTestCompileStdlib.java @@ -55,8 +55,9 @@ public class ForTestCompileStdlib { File classesDir = new File(tmpDir, "classes"); - compileKotlinPartOfStdlib(classesDir); + FileUtil.createParentDirs(new File(classesDir, "dummy")); compileJavaPartOfStdlib(classesDir); + compileKotlinPartOfStdlib(classesDir); FileOutputStream stdlibJar = new FileOutputStream(jarFile); try { @@ -98,7 +99,7 @@ public class ForTestCompileStdlib { private static void compileKotlinPartOfStdlib(File destdir) throws IOException { // lame - KotlinCompiler.exec("-output", destdir.getPath(), "-src", "./stdlib/ktSrc"); + KotlinCompiler.exec("-output", destdir.getPath(), "-src", "./stdlib/ktSrc", "-stdlib", destdir.getAbsolutePath()); } private static List javaFilesInDir(File dir) { diff --git a/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java index 6ec8cd157d4..8c443232ad6 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java @@ -19,7 +19,6 @@ package org.jetbrains.jet.codegen; import jet.IntRange; import jet.Tuple2; import jet.Tuple4; -import jet.TypeInfo; import java.awt.*; import java.lang.reflect.InvocationTargetException; @@ -513,7 +512,7 @@ public class NamespaceGenTest extends CodegenTestCase { loadText("fun E.foo(extra: java.util.List) = #(1, \"foo\", this, extra)"); // System.out.println(generateToText()); final Method main = generateFunction(); - Tuple4 tuple4 = (Tuple4) main.invoke(null, "aaa", TypeInfo.STRING_TYPE_INFO, TypeInfo.INT_TYPE_INFO, Arrays.asList(10)); + Tuple4 tuple4 = (Tuple4) main.invoke(null, "aaa", Arrays.asList(10)); assertEquals(1, tuple4._1); assertEquals("foo", tuple4._2); assertEquals("aaa", tuple4._3); diff --git a/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java b/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java index 4714b1a82e5..9c1e048c9b0 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java @@ -105,13 +105,13 @@ public class PatternMatchingTest extends CodegenTestCase { Method foo = generateFunction(); final Object result; try { - result = foo.invoke(null, new Tuple2(null, 1, 2)); + result = foo.invoke(null, new Tuple2(1, 2)); } catch (Exception e) { System.out.println(generateToText()); throw e; } assertEquals("one,two", result); - assertEquals("something", foo.invoke(null, new Tuple2(null, "not", "tuple"))); + assertEquals("something", foo.invoke(null, new Tuple2("not", "tuple"))); } // Commented for KT-621 @@ -135,8 +135,8 @@ public class PatternMatchingTest extends CodegenTestCase { public void testNames() throws Exception { loadText("fun foo(x: #(Any, Any)) = when(x) { is #(val a is String, *) -> a; else -> \"something\" }"); Method foo = generateFunction(); - assertEquals("JetBrains", foo.invoke(null, new Tuple2(null, "JetBrains", "s.r.o."))); - assertEquals("something", foo.invoke(null, new Tuple2(null, 1, 2))); + assertEquals("JetBrains", foo.invoke(null, new Tuple2("JetBrains", "s.r.o."))); + assertEquals("something", foo.invoke(null, new Tuple2(1, 2))); } public void testMultipleConditions() throws Exception { diff --git a/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java index 418066102f7..c4cd84a8dbd 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java @@ -34,7 +34,7 @@ public class PropertyGenTest extends CodegenTestCase { loadFile(); final Class aClass = loadImplementationClass(generateClassesInFile(), "PrivateVal"); final Field[] fields = aClass.getDeclaredFields(); - assertEquals(2, fields.length); // $typeInfo, prop + assertEquals(1, fields.length); // prop final Field field = fields[0]; assertEquals("prop", field.getName()); } diff --git a/compiler/tests/org/jetbrains/jet/codegen/TupleGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/TupleGenTest.java index 49c9e6afc25..eb9dc3f29b0 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/TupleGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/TupleGenTest.java @@ -19,6 +19,6 @@ package org.jetbrains.jet.codegen; public class TupleGenTest extends CodegenTestCase { public void testBasic() { blackBoxFile("/tuples/basic.jet"); -// System.out.println(generateToText()); + System.out.println(generateToText()); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/TypeInfoTest.java b/compiler/tests/org/jetbrains/jet/codegen/TypeInfoTest.java index ed418ee1315..c3fe85738f1 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/TypeInfoTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/TypeInfoTest.java @@ -18,12 +18,12 @@ package org.jetbrains.jet.codegen; import jet.JetObject; import jet.TypeCastException; -import jet.TypeInfo; import java.lang.reflect.Method; /** * @author yole + * @author alex.tkachman */ public class TypeInfoTest extends CodegenTestCase { @Override @@ -31,28 +31,6 @@ public class TypeInfoTest extends CodegenTestCase { return "typeInfo"; } - public void testGetTypeInfo() throws Exception { - loadFile(); - Method foo = generateFunction(); - JetObject jetObject = (JetObject) foo.invoke(null); - TypeInfo typeInfo = jetObject.getTypeInfo(); - assertNotNull(typeInfo); - } - - public void testOneArgTypeinfo() throws Exception { - loadFile(); - Method foo = generateFunction(); - TypeInfo typeInfo = (TypeInfo) foo.invoke(null); - assertNotNull(typeInfo); - } - - public void testNoArgTypeinfo() throws Exception { - loadText("fun foo() = typeinfo()"); - Method foo = generateFunction(); - TypeInfo typeInfo = (TypeInfo) foo.invoke(null); - assertSame(TypeInfo.INT_TYPE_INFO, typeInfo); - } - public void testAsSafeOperator() throws Exception { loadText("fun foo(x: Any) = x as? Runnable"); Method foo = generateFunction(); @@ -94,19 +72,22 @@ public class TypeInfoTest extends CodegenTestCase { } public void testIsWithGenericParameters() throws Exception { - loadFile(); - Method foo = generateFunction(); - assertFalse((Boolean) foo.invoke(null)); +// todo: obsolete with typeinfo removal +// loadFile(); +// Method foo = generateFunction(); +// assertFalse((Boolean) foo.invoke(null)); } public void testIsTypeParameter() throws Exception { - blackBoxFile("typeInfo/isTypeParameter.jet"); +// todo: obsolete with typeinfo removal +// blackBoxFile("typeInfo/isTypeParameter.jet"); } public void testAsSafeWithGenerics() throws Exception { - loadFile(); - Method foo = generateFunction(); - assertNull(foo.invoke(null)); +// todo: obsolete with typeinfo removal +// loadFile(); +// Method foo = generateFunction(); +// assertNull(foo.invoke(null)); } public void testAsInLoop() throws Exception { @@ -119,18 +100,22 @@ public class TypeInfoTest extends CodegenTestCase { } public void testNullability() throws Exception { - blackBoxFile("typeInfo/nullability.jet"); +// todo: obsolete with typeinfo removal +// blackBoxFile("typeInfo/nullability.jet"); } public void testGenericFunction() throws Exception { - blackBoxFile("typeInfo/genericFunction.jet"); +// todo: obsolete with typeinfo removal +// blackBoxFile("typeInfo/genericFunction.jet"); } public void testForwardTypeParameter() throws Exception { - blackBoxFile("typeInfo/forwardTypeParameter.jet"); +// todo: obsolete with typeinfo removal +// blackBoxFile("typeInfo/forwardTypeParameter.jet"); } public void testClassObjectInTypeInfo() throws Exception { + /* loadFile(); // System.out.println(generateToText()); Method foo = generateFunction(); @@ -139,6 +124,7 @@ public class TypeInfoTest extends CodegenTestCase { final Object object = typeInfo.getClassObject(); final Method classObjFoo = object.getClass().getMethod("foo"); assertNotNull(classObjFoo); + */ } private Runnable newRunnable() { @@ -150,7 +136,8 @@ public class TypeInfoTest extends CodegenTestCase { } public void testKt259() throws Exception { - blackBoxFile("regressions/kt259.jet"); +// todo: obsolete with typeinfo removal +// blackBoxFile("regressions/kt259.jet"); // System.out.println(generateToText()); } @@ -170,7 +157,8 @@ public class TypeInfoTest extends CodegenTestCase { } public void testkt1113() throws Exception { - blackBoxFile("regressions/kt1113.kt"); - System.out.println(generateToText()); +// todo: obsolete with typeinfo removal +// blackBoxFile("regressions/kt1113.kt"); +// System.out.println(generateToText()); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java b/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java index cd3818a0f39..ce498615358 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java @@ -78,7 +78,7 @@ public class VarArgTest extends CodegenTestCase { public void testArrayT () throws InvocationTargetException, IllegalAccessException { loadText("fun test() = _array(2, 4); fun _array(vararg elements : T) = elements"); -// System.out.println(generateToText()); + System.out.println(generateToText()); final Method main = generateFunction("test"); Object res = main.invoke(null); assertTrue(((Integer[])res).length == 2); diff --git a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java index 7992233e35a..740895682fd 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java @@ -108,8 +108,9 @@ public class JetTypeCheckerTest extends JetLiteFixture { } public void testTypeInfo() throws Exception { - assertType("typeinfo", "TypeInfo"); - assertType("typeinfo>", "TypeInfo>"); +// todo: obsolete since removal of typeinfo +// assertType("typeinfo", "TypeInfo"); +// assertType("typeinfo>", "TypeInfo>"); } public void testJumps() throws Exception { diff --git a/stdlib/ktSrc/JavaLang.kt b/stdlib/ktSrc/JavaLang.kt index 66009d500cf..6e237d57f32 100644 --- a/stdlib/ktSrc/JavaLang.kt +++ b/stdlib/ktSrc/JavaLang.kt @@ -3,12 +3,9 @@ package std import java.lang.Class import java.lang.Object -val T.javaClass : Class - get() = jet.runtime.Intrinsics.getJavaClass(this) as Class +import jet.runtime.intrinsic -fun javaClass() : Class = (typeinfo() as org.jetbrains.jet.rt.TypeInfoImpl).getJavaClass().sure() +val T.javaClass : Class + [intrinsic("std.javaClass.property")] get() = (this as java.lang.Object).getClass() as Class -val TypeInfo.javaClassForType : Class - get() { - return (this as org.jetbrains.jet.rt.TypeInfoImpl).getJavaClass().sure() - } +[intrinsic("std.javaClass.function")] fun javaClass() : Class = null as Class diff --git a/stdlib/src/jet/BooleanIterator.java b/stdlib/src/jet/BooleanIterator.java index 4bb4f706830..965be4a3097 100644 --- a/stdlib/src/jet/BooleanIterator.java +++ b/stdlib/src/jet/BooleanIterator.java @@ -20,12 +20,6 @@ package jet; * @author alex.tkachman */ public abstract class BooleanIterator implements Iterator { - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(BooleanIterator.class, false); - - public TypeInfo getTypeInfo () { - return typeInfo; - } - public final Boolean next() { return nextBoolean(); } diff --git a/stdlib/src/jet/ByteIterator.java b/stdlib/src/jet/ByteIterator.java index 3418e033db8..beb51aaf9af 100644 --- a/stdlib/src/jet/ByteIterator.java +++ b/stdlib/src/jet/ByteIterator.java @@ -20,12 +20,6 @@ package jet; * @author alex.tkachman */ public abstract class ByteIterator implements Iterator { - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ByteIterator.class, false); - - public TypeInfo getTypeInfo () { - return typeInfo; - } - public final Byte next() { return nextByte(); } diff --git a/stdlib/src/jet/ByteRange.java b/stdlib/src/jet/ByteRange.java index 6cd6f9fa97d..f6b5d883d91 100644 --- a/stdlib/src/jet/ByteRange.java +++ b/stdlib/src/jet/ByteRange.java @@ -17,8 +17,6 @@ package jet; public final class ByteRange implements Range, ByteIterable, JetObject { - private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(ByteRange.class, false); - private final byte start; private final int count; @@ -74,11 +72,6 @@ public final class ByteRange implements Range, ByteIterable, JetObject { return new MyIterator(start, count, 1); } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; @@ -89,8 +82,6 @@ public final class ByteRange implements Range, ByteIterable, JetObject { } private static class MyIterator extends ByteIterator { - private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false); - private byte cur; private int step; private int count; @@ -129,11 +120,6 @@ public final class ByteRange implements Range, ByteIterable, JetObject { } } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; diff --git a/stdlib/src/jet/CharIterator.java b/stdlib/src/jet/CharIterator.java index 6de9489be81..e60ad4dde7e 100644 --- a/stdlib/src/jet/CharIterator.java +++ b/stdlib/src/jet/CharIterator.java @@ -20,12 +20,6 @@ package jet; * @author alex.tkachman */ public abstract class CharIterator implements Iterator { - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(CharIterator.class, false); - - public TypeInfo getTypeInfo () { - return typeInfo; - } - public final Character next() { return nextChar(); } diff --git a/stdlib/src/jet/CharRange.java b/stdlib/src/jet/CharRange.java index baa7f41df0b..970a7a96781 100644 --- a/stdlib/src/jet/CharRange.java +++ b/stdlib/src/jet/CharRange.java @@ -17,8 +17,6 @@ package jet; public final class CharRange implements Range, CharIterable, JetObject { - private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(CharRange.class, false); - private final char start; private final int count; @@ -74,11 +72,6 @@ public final class CharRange implements Range, CharIterable, JetObjec return new MyIterator(start, count, 1); } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; @@ -89,8 +82,6 @@ public final class CharRange implements Range, CharIterable, JetObjec } private static class MyIterator extends CharIterator { - private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false); - private char cur; private int step; private int count; @@ -129,11 +120,6 @@ public final class CharRange implements Range, CharIterable, JetObjec } } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; diff --git a/stdlib/src/jet/DefaultJetObject.java b/stdlib/src/jet/DefaultJetObject.java index dfb497a1127..cf2c5af2440 100644 --- a/stdlib/src/jet/DefaultJetObject.java +++ b/stdlib/src/jet/DefaultJetObject.java @@ -20,24 +20,9 @@ package jet; * @author alex.tkachman */ public class DefaultJetObject implements JetObject { - private TypeInfo typeInfo; - protected DefaultJetObject() { } - protected DefaultJetObject(TypeInfo typeInfo) { - this.typeInfo = typeInfo; - } - - protected final void $setTypeInfo(TypeInfo typeInfo) { - this.typeInfo = typeInfo; - } - - @Override - public final TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; diff --git a/stdlib/src/jet/DoubleIterator.java b/stdlib/src/jet/DoubleIterator.java index 32156bacd9f..92eebfd1b53 100644 --- a/stdlib/src/jet/DoubleIterator.java +++ b/stdlib/src/jet/DoubleIterator.java @@ -20,12 +20,6 @@ package jet; * @author alex.tkachman */ public abstract class DoubleIterator implements Iterator { - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(DoubleIterator.class, false); - - public TypeInfo getTypeInfo () { - return typeInfo; - } - public final Double next() { return nextDouble(); } diff --git a/stdlib/src/jet/DoubleRange.java b/stdlib/src/jet/DoubleRange.java index 8c381d3f365..4ade6d94b3b 100644 --- a/stdlib/src/jet/DoubleRange.java +++ b/stdlib/src/jet/DoubleRange.java @@ -17,8 +17,6 @@ package jet; public final class DoubleRange implements Range, JetObject { - private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(DoubleRange.class, false); - private final double start; private final double size; @@ -63,11 +61,6 @@ public final class DoubleRange implements Range, JetObject { return new DoubleRange(getEnd(), -size); } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; @@ -78,8 +71,6 @@ public final class DoubleRange implements Range, JetObject { } private static class MyIterator extends DoubleIterator { - private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false); - private double cur; private double step; private final double end; @@ -120,11 +111,6 @@ public final class DoubleRange implements Range, JetObject { } } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; diff --git a/stdlib/src/jet/ExtensionFunction0.java b/stdlib/src/jet/ExtensionFunction0.java index 1b93fbac719..3b9eab1b411 100644 --- a/stdlib/src/jet/ExtensionFunction0.java +++ b/stdlib/src/jet/ExtensionFunction0.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction0 extends DefaultJetObject { - protected ExtensionFunction0(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction0() { + super(); } public abstract R invoke(E receiver); diff --git a/stdlib/src/jet/ExtensionFunction1.java b/stdlib/src/jet/ExtensionFunction1.java index e67449fba44..7cb401baf38 100644 --- a/stdlib/src/jet/ExtensionFunction1.java +++ b/stdlib/src/jet/ExtensionFunction1.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction1 extends DefaultJetObject { - protected ExtensionFunction1(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction1() { + super(); } public abstract R invoke(E receiver, D1 d1); diff --git a/stdlib/src/jet/ExtensionFunction10.java b/stdlib/src/jet/ExtensionFunction10.java index 1575146f3a7..75564078ae2 100644 --- a/stdlib/src/jet/ExtensionFunction10.java +++ b/stdlib/src/jet/ExtensionFunction10.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction10 extends DefaultJetObject { - protected ExtensionFunction10(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction10() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10); diff --git a/stdlib/src/jet/ExtensionFunction11.java b/stdlib/src/jet/ExtensionFunction11.java index a5e7552a75b..92090c5de21 100644 --- a/stdlib/src/jet/ExtensionFunction11.java +++ b/stdlib/src/jet/ExtensionFunction11.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction11 extends DefaultJetObject { - protected ExtensionFunction11(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction11() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11); diff --git a/stdlib/src/jet/ExtensionFunction12.java b/stdlib/src/jet/ExtensionFunction12.java index 0cca1fafbfc..63be427f490 100644 --- a/stdlib/src/jet/ExtensionFunction12.java +++ b/stdlib/src/jet/ExtensionFunction12.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction12 extends DefaultJetObject { - protected ExtensionFunction12(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction12() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12); diff --git a/stdlib/src/jet/ExtensionFunction13.java b/stdlib/src/jet/ExtensionFunction13.java index e2e96c804d8..a7df63b8124 100644 --- a/stdlib/src/jet/ExtensionFunction13.java +++ b/stdlib/src/jet/ExtensionFunction13.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction13 extends DefaultJetObject { - protected ExtensionFunction13(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction13() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13); diff --git a/stdlib/src/jet/ExtensionFunction14.java b/stdlib/src/jet/ExtensionFunction14.java index d34283debb3..7a3bb0694de 100644 --- a/stdlib/src/jet/ExtensionFunction14.java +++ b/stdlib/src/jet/ExtensionFunction14.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction14 extends DefaultJetObject { - protected ExtensionFunction14(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction14() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14); diff --git a/stdlib/src/jet/ExtensionFunction15.java b/stdlib/src/jet/ExtensionFunction15.java index 190ed4ec82f..dc6b9916773 100644 --- a/stdlib/src/jet/ExtensionFunction15.java +++ b/stdlib/src/jet/ExtensionFunction15.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction15 extends DefaultJetObject { - protected ExtensionFunction15(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction15() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15); diff --git a/stdlib/src/jet/ExtensionFunction16.java b/stdlib/src/jet/ExtensionFunction16.java index 0da721ad90d..f95ce8cd6f6 100644 --- a/stdlib/src/jet/ExtensionFunction16.java +++ b/stdlib/src/jet/ExtensionFunction16.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction16 extends DefaultJetObject { - protected ExtensionFunction16(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction16() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16); diff --git a/stdlib/src/jet/ExtensionFunction17.java b/stdlib/src/jet/ExtensionFunction17.java index f113b6d3efd..332f10d1a62 100644 --- a/stdlib/src/jet/ExtensionFunction17.java +++ b/stdlib/src/jet/ExtensionFunction17.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction17 extends DefaultJetObject { - protected ExtensionFunction17(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction17() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17); diff --git a/stdlib/src/jet/ExtensionFunction18.java b/stdlib/src/jet/ExtensionFunction18.java index 5954824b3bc..0418e9ccda6 100644 --- a/stdlib/src/jet/ExtensionFunction18.java +++ b/stdlib/src/jet/ExtensionFunction18.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction18 extends DefaultJetObject { - protected ExtensionFunction18(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction18() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18); diff --git a/stdlib/src/jet/ExtensionFunction19.java b/stdlib/src/jet/ExtensionFunction19.java index 54d1f00e74a..06b4b7db85a 100644 --- a/stdlib/src/jet/ExtensionFunction19.java +++ b/stdlib/src/jet/ExtensionFunction19.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction19 extends DefaultJetObject { - protected ExtensionFunction19(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction19() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19); diff --git a/stdlib/src/jet/ExtensionFunction2.java b/stdlib/src/jet/ExtensionFunction2.java index 48e9b53eec3..8ba87672e94 100644 --- a/stdlib/src/jet/ExtensionFunction2.java +++ b/stdlib/src/jet/ExtensionFunction2.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction2 extends DefaultJetObject { - protected ExtensionFunction2(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction2() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2); diff --git a/stdlib/src/jet/ExtensionFunction20.java b/stdlib/src/jet/ExtensionFunction20.java index 013ac6e1f8b..ccc2e5060e0 100644 --- a/stdlib/src/jet/ExtensionFunction20.java +++ b/stdlib/src/jet/ExtensionFunction20.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction20 extends DefaultJetObject { - protected ExtensionFunction20(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction20() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19, D20 d20); diff --git a/stdlib/src/jet/ExtensionFunction21.java b/stdlib/src/jet/ExtensionFunction21.java index 00317f82941..6b0653fd94f 100644 --- a/stdlib/src/jet/ExtensionFunction21.java +++ b/stdlib/src/jet/ExtensionFunction21.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction21 extends DefaultJetObject { - protected ExtensionFunction21(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction21() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19, D20 d20, D21 d21); diff --git a/stdlib/src/jet/ExtensionFunction22.java b/stdlib/src/jet/ExtensionFunction22.java index cf83af4c836..8dac4dca000 100644 --- a/stdlib/src/jet/ExtensionFunction22.java +++ b/stdlib/src/jet/ExtensionFunction22.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction22 extends DefaultJetObject { - protected ExtensionFunction22(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction22() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19, D20 d20, D21 d21, D22 d22); diff --git a/stdlib/src/jet/ExtensionFunction3.java b/stdlib/src/jet/ExtensionFunction3.java index 37d02049141..8e7fd145364 100644 --- a/stdlib/src/jet/ExtensionFunction3.java +++ b/stdlib/src/jet/ExtensionFunction3.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction3 extends DefaultJetObject { - protected ExtensionFunction3(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction3() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3); diff --git a/stdlib/src/jet/ExtensionFunction4.java b/stdlib/src/jet/ExtensionFunction4.java index c1d815463d5..53198276f76 100644 --- a/stdlib/src/jet/ExtensionFunction4.java +++ b/stdlib/src/jet/ExtensionFunction4.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction4 extends DefaultJetObject { - protected ExtensionFunction4(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction4() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4); diff --git a/stdlib/src/jet/ExtensionFunction5.java b/stdlib/src/jet/ExtensionFunction5.java index c48096bd735..29d9c588752 100644 --- a/stdlib/src/jet/ExtensionFunction5.java +++ b/stdlib/src/jet/ExtensionFunction5.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction5 extends DefaultJetObject { - protected ExtensionFunction5(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction5() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5); diff --git a/stdlib/src/jet/ExtensionFunction6.java b/stdlib/src/jet/ExtensionFunction6.java index b08c3a7dc3f..93f746c36d4 100644 --- a/stdlib/src/jet/ExtensionFunction6.java +++ b/stdlib/src/jet/ExtensionFunction6.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction6 extends DefaultJetObject { - protected ExtensionFunction6(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction6() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6); diff --git a/stdlib/src/jet/ExtensionFunction7.java b/stdlib/src/jet/ExtensionFunction7.java index 6e954bd4523..6a01d9ae340 100644 --- a/stdlib/src/jet/ExtensionFunction7.java +++ b/stdlib/src/jet/ExtensionFunction7.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction7 extends DefaultJetObject { - protected ExtensionFunction7(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction7() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7); diff --git a/stdlib/src/jet/ExtensionFunction8.java b/stdlib/src/jet/ExtensionFunction8.java index 33a4913eb2d..b4a7b03b644 100644 --- a/stdlib/src/jet/ExtensionFunction8.java +++ b/stdlib/src/jet/ExtensionFunction8.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction8 extends DefaultJetObject { - protected ExtensionFunction8(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction8() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8); diff --git a/stdlib/src/jet/ExtensionFunction9.java b/stdlib/src/jet/ExtensionFunction9.java index eb6da0c105a..338450078b7 100644 --- a/stdlib/src/jet/ExtensionFunction9.java +++ b/stdlib/src/jet/ExtensionFunction9.java @@ -20,8 +20,8 @@ package jet; public abstract class ExtensionFunction9 extends DefaultJetObject { - protected ExtensionFunction9(TypeInfo typeInfo) { - super(typeInfo); + protected ExtensionFunction9() { + super(); } public abstract R invoke(E receiver, D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9); diff --git a/stdlib/src/jet/FloatIterator.java b/stdlib/src/jet/FloatIterator.java index fc63260ce14..a6ac8ccd14a 100644 --- a/stdlib/src/jet/FloatIterator.java +++ b/stdlib/src/jet/FloatIterator.java @@ -20,12 +20,6 @@ package jet; * @author alex.tkachman */ public abstract class FloatIterator implements Iterator { - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(FloatIterator.class, false); - - public TypeInfo getTypeInfo () { - return typeInfo; - } - public final Float next() { return nextFloat(); } diff --git a/stdlib/src/jet/FloatRange.java b/stdlib/src/jet/FloatRange.java index 6950ff85855..66879c741cd 100644 --- a/stdlib/src/jet/FloatRange.java +++ b/stdlib/src/jet/FloatRange.java @@ -17,8 +17,6 @@ package jet; public final class FloatRange implements Range, JetObject { - private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(FloatRange.class, false); - private final float start; private final float size; @@ -63,10 +61,6 @@ public final class FloatRange implements Range, JetObject { return new FloatRange(getEnd(), -size); } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } @Override public JetObject getOuterObject() { @@ -78,8 +72,6 @@ public final class FloatRange implements Range, JetObject { } private static class MyIterator extends FloatIterator { - private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false); - private float cur; private float step; private final float end; @@ -120,11 +112,6 @@ public final class FloatRange implements Range, JetObject { } } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; diff --git a/stdlib/src/jet/Function0.java b/stdlib/src/jet/Function0.java index f8255721a78..852720707a9 100644 --- a/stdlib/src/jet/Function0.java +++ b/stdlib/src/jet/Function0.java @@ -20,10 +20,6 @@ package jet; public abstract class Function0 extends DefaultJetObject { - protected Function0(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(); @Override diff --git a/stdlib/src/jet/Function1.java b/stdlib/src/jet/Function1.java index e46affc9ab3..c29a3b051d9 100644 --- a/stdlib/src/jet/Function1.java +++ b/stdlib/src/jet/Function1.java @@ -20,10 +20,6 @@ package jet; public abstract class Function1 extends DefaultJetObject { - protected Function1(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1); @Override diff --git a/stdlib/src/jet/Function10.java b/stdlib/src/jet/Function10.java index 0ec2c03d05a..5cbdd9507ba 100644 --- a/stdlib/src/jet/Function10.java +++ b/stdlib/src/jet/Function10.java @@ -20,10 +20,6 @@ package jet; public abstract class Function10 extends DefaultJetObject { - protected Function10(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10); @Override diff --git a/stdlib/src/jet/Function11.java b/stdlib/src/jet/Function11.java index 2670f646cf5..72d208a9095 100644 --- a/stdlib/src/jet/Function11.java +++ b/stdlib/src/jet/Function11.java @@ -20,10 +20,6 @@ package jet; public abstract class Function11 extends DefaultJetObject { - protected Function11(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11); @Override diff --git a/stdlib/src/jet/Function12.java b/stdlib/src/jet/Function12.java index d383988bec2..00fe410d664 100644 --- a/stdlib/src/jet/Function12.java +++ b/stdlib/src/jet/Function12.java @@ -20,10 +20,6 @@ package jet; public abstract class Function12 extends DefaultJetObject { - protected Function12(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12); @Override diff --git a/stdlib/src/jet/Function13.java b/stdlib/src/jet/Function13.java index 35905c361b1..f08f37c6cb5 100644 --- a/stdlib/src/jet/Function13.java +++ b/stdlib/src/jet/Function13.java @@ -20,10 +20,6 @@ package jet; public abstract class Function13 extends DefaultJetObject { - protected Function13(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13); @Override diff --git a/stdlib/src/jet/Function14.java b/stdlib/src/jet/Function14.java index 85f00b93ea6..d4d6b240951 100644 --- a/stdlib/src/jet/Function14.java +++ b/stdlib/src/jet/Function14.java @@ -20,10 +20,6 @@ package jet; public abstract class Function14 extends DefaultJetObject { - protected Function14(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14); @Override diff --git a/stdlib/src/jet/Function15.java b/stdlib/src/jet/Function15.java index d59ca94c92b..ef2857e1f1f 100644 --- a/stdlib/src/jet/Function15.java +++ b/stdlib/src/jet/Function15.java @@ -20,10 +20,6 @@ package jet; public abstract class Function15 extends DefaultJetObject { - protected Function15(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15); @Override diff --git a/stdlib/src/jet/Function16.java b/stdlib/src/jet/Function16.java index 19b7215afc5..50d6cc40123 100644 --- a/stdlib/src/jet/Function16.java +++ b/stdlib/src/jet/Function16.java @@ -20,10 +20,6 @@ package jet; public abstract class Function16 extends DefaultJetObject { - protected Function16(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16); @Override diff --git a/stdlib/src/jet/Function17.java b/stdlib/src/jet/Function17.java index 8cab064c304..a1c3c8bad13 100644 --- a/stdlib/src/jet/Function17.java +++ b/stdlib/src/jet/Function17.java @@ -20,10 +20,6 @@ package jet; public abstract class Function17 extends DefaultJetObject { - protected Function17(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17); @Override diff --git a/stdlib/src/jet/Function18.java b/stdlib/src/jet/Function18.java index 7498349058c..e34417acf51 100644 --- a/stdlib/src/jet/Function18.java +++ b/stdlib/src/jet/Function18.java @@ -20,10 +20,6 @@ package jet; public abstract class Function18 extends DefaultJetObject { - protected Function18(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18); @Override diff --git a/stdlib/src/jet/Function19.java b/stdlib/src/jet/Function19.java index de817153b9b..a6fc2c5740a 100644 --- a/stdlib/src/jet/Function19.java +++ b/stdlib/src/jet/Function19.java @@ -20,10 +20,6 @@ package jet; public abstract class Function19 extends DefaultJetObject { - protected Function19(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19); @Override diff --git a/stdlib/src/jet/Function2.java b/stdlib/src/jet/Function2.java index ce591a4e296..64dcde7955b 100644 --- a/stdlib/src/jet/Function2.java +++ b/stdlib/src/jet/Function2.java @@ -20,10 +20,6 @@ package jet; public abstract class Function2 extends DefaultJetObject { - protected Function2(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2); @Override diff --git a/stdlib/src/jet/Function20.java b/stdlib/src/jet/Function20.java index 4e523b9a966..2c76484c852 100644 --- a/stdlib/src/jet/Function20.java +++ b/stdlib/src/jet/Function20.java @@ -20,10 +20,6 @@ package jet; public abstract class Function20 extends DefaultJetObject { - protected Function20(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19, D20 d20); @Override diff --git a/stdlib/src/jet/Function21.java b/stdlib/src/jet/Function21.java index 61af0cb0394..145f3983df5 100644 --- a/stdlib/src/jet/Function21.java +++ b/stdlib/src/jet/Function21.java @@ -20,10 +20,6 @@ package jet; public abstract class Function21 extends DefaultJetObject { - protected Function21(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19, D20 d20, D21 d21); @Override diff --git a/stdlib/src/jet/Function22.java b/stdlib/src/jet/Function22.java index 0a4f2fc5258..0bce51b67be 100644 --- a/stdlib/src/jet/Function22.java +++ b/stdlib/src/jet/Function22.java @@ -20,10 +20,6 @@ package jet; public abstract class Function22 extends DefaultJetObject { - protected Function22(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9, D10 d10, D11 d11, D12 d12, D13 d13, D14 d14, D15 d15, D16 d16, D17 d17, D18 d18, D19 d19, D20 d20, D21 d21, D22 d22); @Override diff --git a/stdlib/src/jet/Function3.java b/stdlib/src/jet/Function3.java index 7a450a00815..0a306922590 100644 --- a/stdlib/src/jet/Function3.java +++ b/stdlib/src/jet/Function3.java @@ -20,10 +20,6 @@ package jet; public abstract class Function3 extends DefaultJetObject { - protected Function3(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3); @Override diff --git a/stdlib/src/jet/Function4.java b/stdlib/src/jet/Function4.java index a6cb079d84d..91cc1a3cdde 100644 --- a/stdlib/src/jet/Function4.java +++ b/stdlib/src/jet/Function4.java @@ -20,10 +20,6 @@ package jet; public abstract class Function4 extends DefaultJetObject { - protected Function4(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4); @Override diff --git a/stdlib/src/jet/Function5.java b/stdlib/src/jet/Function5.java index 3388f5c8431..0afa3431745 100644 --- a/stdlib/src/jet/Function5.java +++ b/stdlib/src/jet/Function5.java @@ -20,10 +20,6 @@ package jet; public abstract class Function5 extends DefaultJetObject { - protected Function5(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5); @Override diff --git a/stdlib/src/jet/Function6.java b/stdlib/src/jet/Function6.java index 3bb8c7b2807..9032b8656df 100644 --- a/stdlib/src/jet/Function6.java +++ b/stdlib/src/jet/Function6.java @@ -20,9 +20,6 @@ package jet; public abstract class Function6 extends DefaultJetObject { - protected Function6(TypeInfo typeInfo) { - super(typeInfo); - } public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6); diff --git a/stdlib/src/jet/Function7.java b/stdlib/src/jet/Function7.java index 2fab7119b82..5159f24f0b7 100644 --- a/stdlib/src/jet/Function7.java +++ b/stdlib/src/jet/Function7.java @@ -20,10 +20,6 @@ package jet; public abstract class Function7 extends DefaultJetObject { - protected Function7(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7); @Override diff --git a/stdlib/src/jet/Function8.java b/stdlib/src/jet/Function8.java index f81943c9466..a0fe28e32a5 100644 --- a/stdlib/src/jet/Function8.java +++ b/stdlib/src/jet/Function8.java @@ -20,10 +20,6 @@ package jet; public abstract class Function8 extends DefaultJetObject { - protected Function8(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8); @Override diff --git a/stdlib/src/jet/Function9.java b/stdlib/src/jet/Function9.java index 260283a7b3e..f265598f27a 100644 --- a/stdlib/src/jet/Function9.java +++ b/stdlib/src/jet/Function9.java @@ -20,10 +20,6 @@ package jet; public abstract class Function9 extends DefaultJetObject { - protected Function9(TypeInfo typeInfo) { - super(typeInfo); - } - public abstract R invoke(D1 d1, D2 d2, D3 d3, D4 d4, D5 d5, D6 d6, D7 d7, D8 d8, D9 d9); @Override diff --git a/stdlib/src/jet/IntIterator.java b/stdlib/src/jet/IntIterator.java index ae55b9387e0..a29b43d6c2f 100644 --- a/stdlib/src/jet/IntIterator.java +++ b/stdlib/src/jet/IntIterator.java @@ -20,12 +20,6 @@ package jet; * @author alex.tkachman */ public abstract class IntIterator implements Iterator { - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(IntIterator.class, false); - - public TypeInfo getTypeInfo () { - return typeInfo; - } - public final Integer next() { return nextInt(); } diff --git a/stdlib/src/jet/IntRange.java b/stdlib/src/jet/IntRange.java index 19300e44e80..9889909d5f7 100644 --- a/stdlib/src/jet/IntRange.java +++ b/stdlib/src/jet/IntRange.java @@ -17,8 +17,6 @@ package jet; public final class IntRange implements Range, IntIterable, JetObject { - private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(IntRange.class, false); - private final int start; private final int count; @@ -74,11 +72,6 @@ public final class IntRange implements Range, IntIterable, JetObject { return new MyIterator(start, count, 1); } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; @@ -89,8 +82,6 @@ public final class IntRange implements Range, IntIterable, JetObject { } private static class MyIterator extends IntIterator { - private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false); - private int cur; private int step; private int count; @@ -129,11 +120,6 @@ public final class IntRange implements Range, IntIterable, JetObject { } } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; diff --git a/stdlib/src/jet/JetObject.java b/stdlib/src/jet/JetObject.java index d5e752ace66..38ce3ee8776 100644 --- a/stdlib/src/jet/JetObject.java +++ b/stdlib/src/jet/JetObject.java @@ -21,6 +21,5 @@ package jet; * @author alex.tkachman */ public interface JetObject { - TypeInfo getTypeInfo(); JetObject getOuterObject(); } diff --git a/stdlib/src/jet/LongIterator.java b/stdlib/src/jet/LongIterator.java index 0c0c5df86d6..7449f1f44ec 100644 --- a/stdlib/src/jet/LongIterator.java +++ b/stdlib/src/jet/LongIterator.java @@ -20,12 +20,6 @@ package jet; * @author alex.tkachman */ public abstract class LongIterator implements Iterator { - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(LongIterator.class, false); - - public TypeInfo getTypeInfo () { - return typeInfo; - } - public final Long next() { return nextLong(); } diff --git a/stdlib/src/jet/LongRange.java b/stdlib/src/jet/LongRange.java index b3d56d81e17..7f6a89b9dd5 100644 --- a/stdlib/src/jet/LongRange.java +++ b/stdlib/src/jet/LongRange.java @@ -17,8 +17,6 @@ package jet; public final class LongRange implements Range, LongIterable, JetObject { - private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(IntRange.class, false); - private final long start; private final long count; @@ -74,11 +72,6 @@ public final class LongRange implements Range, LongIterable, JetObject { return new MyIterator(start, count, 1); } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; @@ -89,8 +82,6 @@ public final class LongRange implements Range, LongIterable, JetObject { } private static class MyIterator extends LongIterator { - private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false); - private long cur; private long step; private long count; @@ -129,11 +120,6 @@ public final class LongRange implements Range, LongIterable, JetObject { } } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; diff --git a/stdlib/src/jet/ShortIterator.java b/stdlib/src/jet/ShortIterator.java index 6acce7b7bbb..a4a9cf66bc7 100644 --- a/stdlib/src/jet/ShortIterator.java +++ b/stdlib/src/jet/ShortIterator.java @@ -20,12 +20,6 @@ package jet; * @author alex.tkachman */ public abstract class ShortIterator implements Iterator { - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ShortIterator.class, false); - - public TypeInfo getTypeInfo () { - return typeInfo; - } - public final Short next() { return nextShort(); } diff --git a/stdlib/src/jet/ShortRange.java b/stdlib/src/jet/ShortRange.java index 3605286d203..f184b1e41e5 100644 --- a/stdlib/src/jet/ShortRange.java +++ b/stdlib/src/jet/ShortRange.java @@ -17,8 +17,6 @@ package jet; public final class ShortRange implements Range, ShortIterable, JetObject { - private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(ShortRange.class, false); - private final short start; private final int count; @@ -74,11 +72,6 @@ public final class ShortRange implements Range, ShortIterable, JetObject return new MyIterator(start, count, 1); } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; @@ -89,8 +82,6 @@ public final class ShortRange implements Range, ShortIterable, JetObject } private static class MyIterator extends ShortIterator { - private final static TypeInfo typeInfo = TypeInfo.getTypeInfo(MyIterator.class, false); - private short cur; private int step; private int count; @@ -129,11 +120,6 @@ public final class ShortRange implements Range, ShortIterable, JetObject } } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; diff --git a/stdlib/src/jet/Tuple0.java b/stdlib/src/jet/Tuple0.java index 328933ed5dc..2272a4e9cc9 100644 --- a/stdlib/src/jet/Tuple0.java +++ b/stdlib/src/jet/Tuple0.java @@ -21,7 +21,6 @@ package jet; */ public class Tuple0 implements JetObject { public static final Tuple0 INSTANCE = new Tuple0(); - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(Tuple0.class, false); private Tuple0() { } @@ -41,11 +40,6 @@ public class Tuple0 implements JetObject { return 239; } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; diff --git a/stdlib/src/jet/Tuple1.java b/stdlib/src/jet/Tuple1.java index 02c614c5505..161b0c6415c 100644 --- a/stdlib/src/jet/Tuple1.java +++ b/stdlib/src/jet/Tuple1.java @@ -19,8 +19,7 @@ package jet; public class Tuple1 extends DefaultJetObject { public final T1 _1; - public Tuple1(TypeInfo typeInfo, T1 t1) { - super(typeInfo); + public Tuple1(T1 t1) { _1 = t1; } diff --git a/stdlib/src/jet/Tuple10.java b/stdlib/src/jet/Tuple10.java index 0da6d5afaf1..d9a37828dfc 100644 --- a/stdlib/src/jet/Tuple10.java +++ b/stdlib/src/jet/Tuple10.java @@ -28,8 +28,7 @@ public class Tuple10 extends DefaultJet public final T9 _9; public final T10 _10; - public Tuple10(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10) { - super(typeInfo); + public Tuple10(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10) { _1 = t1; _2 = t2; _3 = t3; diff --git a/stdlib/src/jet/Tuple11.java b/stdlib/src/jet/Tuple11.java index f38857b9035..5dd11aeabc3 100644 --- a/stdlib/src/jet/Tuple11.java +++ b/stdlib/src/jet/Tuple11.java @@ -29,8 +29,7 @@ public class Tuple11 extends Defau public final T10 _10; public final T11 _11; - public Tuple11(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11) { - super(typeInfo); + public Tuple11(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11) { _1 = t1; _2 = t2; _3 = t3; diff --git a/stdlib/src/jet/Tuple12.java b/stdlib/src/jet/Tuple12.java index a0462112dae..ac213c7b9b3 100644 --- a/stdlib/src/jet/Tuple12.java +++ b/stdlib/src/jet/Tuple12.java @@ -30,8 +30,7 @@ public class Tuple12 extends public final T11 _11; public final T12 _12; - public Tuple12(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12) { - super(typeInfo); + public Tuple12(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12) { _1 = t1; _2 = t2; _3 = t3; diff --git a/stdlib/src/jet/Tuple13.java b/stdlib/src/jet/Tuple13.java index c476a83699e..135e31aff6a 100644 --- a/stdlib/src/jet/Tuple13.java +++ b/stdlib/src/jet/Tuple13.java @@ -31,8 +31,7 @@ public class Tuple13 ext public final T12 _12; public final T13 _13; - public Tuple13(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13) { - super(typeInfo); + public Tuple13(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13) { _1 = t1; _2 = t2; _3 = t3; diff --git a/stdlib/src/jet/Tuple14.java b/stdlib/src/jet/Tuple14.java index c767b81180a..7cea8fd85d0 100644 --- a/stdlib/src/jet/Tuple14.java +++ b/stdlib/src/jet/Tuple14.java @@ -32,8 +32,7 @@ public class Tuple14 extends DefaultJetObject { public final T1 _1; public final T2 _2; - public Tuple2(TypeInfo typeInfo, T1 t1, T2 t2) { - super(typeInfo); + public Tuple2(T1 t1, T2 t2) { _1 = t1; _2 = t2; } diff --git a/stdlib/src/jet/Tuple20.java b/stdlib/src/jet/Tuple20.java index 943d85f1ecc..880451376e7 100644 --- a/stdlib/src/jet/Tuple20.java +++ b/stdlib/src/jet/Tuple20.java @@ -38,8 +38,7 @@ public class Tuple20 extends DefaultJetObject { public final T2 _2; public final T3 _3; - public Tuple3(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3) { - super(typeInfo); + public Tuple3(T1 t1, T2 t2, T3 t3) { _1 = t1; _2 = t2; _3 = t3; diff --git a/stdlib/src/jet/Tuple4.java b/stdlib/src/jet/Tuple4.java index 0cc257d741b..ace5ee317a2 100644 --- a/stdlib/src/jet/Tuple4.java +++ b/stdlib/src/jet/Tuple4.java @@ -22,8 +22,7 @@ public class Tuple4 extends DefaultJetObject { public final T3 _3; public final T4 _4; - public Tuple4(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4) { - super(typeInfo); + public Tuple4(T1 t1, T2 t2, T3 t3, T4 t4) { _1 = t1; _2 = t2; _3 = t3; diff --git a/stdlib/src/jet/Tuple5.java b/stdlib/src/jet/Tuple5.java index ea41455853e..723dae0146d 100644 --- a/stdlib/src/jet/Tuple5.java +++ b/stdlib/src/jet/Tuple5.java @@ -23,8 +23,7 @@ public class Tuple5 extends DefaultJetObject { public final T4 _4; public final T5 _5; - public Tuple5(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) { - super(typeInfo); + public Tuple5(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) { _1 = t1; _2 = t2; _3 = t3; diff --git a/stdlib/src/jet/Tuple6.java b/stdlib/src/jet/Tuple6.java index b6e6fbf2450..9f42ef3b406 100644 --- a/stdlib/src/jet/Tuple6.java +++ b/stdlib/src/jet/Tuple6.java @@ -24,8 +24,7 @@ public class Tuple6 extends DefaultJetObject { public final T5 _5; public final T6 _6; - public Tuple6(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) { - super(typeInfo); + public Tuple6(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) { _1 = t1; _2 = t2; _3 = t3; diff --git a/stdlib/src/jet/Tuple7.java b/stdlib/src/jet/Tuple7.java index 649c74c2f4f..4c1832ec72e 100644 --- a/stdlib/src/jet/Tuple7.java +++ b/stdlib/src/jet/Tuple7.java @@ -25,8 +25,7 @@ public class Tuple7 extends DefaultJetObject { public final T6 _6; public final T7 _7; - public Tuple7(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) { - super(typeInfo); + public Tuple7(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) { _1 = t1; _2 = t2; _3 = t3; diff --git a/stdlib/src/jet/Tuple8.java b/stdlib/src/jet/Tuple8.java index 8999193c933..3fe38a1ecf3 100644 --- a/stdlib/src/jet/Tuple8.java +++ b/stdlib/src/jet/Tuple8.java @@ -26,8 +26,7 @@ public class Tuple8 extends DefaultJetObject { public final T7 _7; public final T8 _8; - public Tuple8(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) { - super(typeInfo); + public Tuple8(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) { _1 = t1; _2 = t2; _3 = t3; diff --git a/stdlib/src/jet/Tuple9.java b/stdlib/src/jet/Tuple9.java index 3a6b1c992bb..c7f2814453a 100644 --- a/stdlib/src/jet/Tuple9.java +++ b/stdlib/src/jet/Tuple9.java @@ -27,8 +27,7 @@ public class Tuple9 extends DefaultJetObject public final T8 _8; public final T9 _9; - public Tuple9(TypeInfo typeInfo, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9) { - super(typeInfo); + public Tuple9(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9) { _1 = t1; _2 = t2; _3 = t3; diff --git a/stdlib/src/jet/TypeInfo.java b/stdlib/src/jet/TypeInfo.java deleted file mode 100644 index ab92477adc5..00000000000 --- a/stdlib/src/jet/TypeInfo.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jet; - -import jet.typeinfo.TypeInfoProjection; -import jet.typeinfo.TypeInfoVariance; -import org.jetbrains.jet.rt.TypeInfoImpl; -import org.jetbrains.jet.rt.TypeInfoProjectionImpl; - -/** - * @author abreslav - * @author yole - * @author alex.tkachman - */ -public abstract class TypeInfo implements JetObject { - - public static final TypeInfo ANY_TYPE_INFO = getTypeInfo(Object.class, false); - public static final TypeInfo BYTE_TYPE_INFO = getTypeInfo(Byte.class, false); - public static final TypeInfo SHORT_TYPE_INFO = getTypeInfo(Short.class, false); - public static final TypeInfo INT_TYPE_INFO = getTypeInfo(Integer.class, false); - public static final TypeInfo LONG_TYPE_INFO = getTypeInfo(Long.class, false); - public static final TypeInfo CHAR_TYPE_INFO = getTypeInfo(Character.class, false); - public static final TypeInfo BOOLEAN_TYPE_INFO = getTypeInfo(Boolean.class, false); - public static final TypeInfo FLOAT_TYPE_INFO = getTypeInfo(Float.class, false); - public static final TypeInfo DOUBLE_TYPE_INFO = getTypeInfo(Double.class, false); - - public static final TypeInfo BYTE_ARRAY_TYPE_INFO = getTypeInfo(byte[].class, false); - public static final TypeInfo SHORT_ARRAY_TYPE_INFO = getTypeInfo(short[].class, false); - public static final TypeInfo INT_ARRAY_TYPE_INFO = getTypeInfo(int[].class, false); - public static final TypeInfo LONG_ARRAY_TYPE_INFO = getTypeInfo(long[].class, false); - public static final TypeInfo CHAR_ARRAY_TYPE_INFO = getTypeInfo(char[].class, false); - public static final TypeInfo BOOL_ARRAY_TYPE_INFO = getTypeInfo(boolean[].class, false); - public static final TypeInfo FLOAT_ARRAY_TYPE_INFO = getTypeInfo(float[].class, false); - public static final TypeInfo DOUBLE_ARRAY_TYPE_INFO = getTypeInfo(double[].class, false); - - public static final TypeInfo STRING_TYPE_INFO = getTypeInfo(String.class, false); - public static final TypeInfo TUPLE0_TYPE_INFO = getTypeInfo(Tuple0.class, false); - - public static final TypeInfo NULLABLE_ANY_TYPE_INFO = getTypeInfo(Object.class, true); - public static final TypeInfo NULLABLE_BYTE_TYPE_INFO = getTypeInfo(Byte.class, true); - public static final TypeInfo NULLABLE_SHORT_TYPE_INFO = getTypeInfo(Short.class, true); - public static final TypeInfo NULLABLE_INT_TYPE_INFO = getTypeInfo(Integer.class, true); - public static final TypeInfo NULLABLE_LONG_TYPE_INFO = getTypeInfo(Long.class, true); - public static final TypeInfo NULLABLE_CHAR_TYPE_INFO = getTypeInfo(Character.class, true); - public static final TypeInfo NULLABLE_BOOL_TYPE_INFO = getTypeInfo(Boolean.class, true); - public static final TypeInfo NULLABLE_FLOAT_TYPE_INFO = getTypeInfo(Float.class, true); - public static final TypeInfo NULLABLE_DOUBLE_TYPE_INFO = getTypeInfo(Double.class, true); - public static final TypeInfo NULLABLE_STRING_TYPE_INFO = getTypeInfo(String.class, true); - public static final TypeInfo NULLABLE_TUPLE0_TYPE_INFO = getTypeInfo(Tuple0.class, true); - - public abstract Object [] newArray(int length); - - public static TypeInfoProjection invariantProjection(final TypeInfo typeInfo) { - return (TypeInfoProjection) typeInfo; - } - - public static TypeInfoProjection inProjection(TypeInfo typeInfo) { - return new TypeInfoProjectionImpl(typeInfo) { -// @NotNull - @Override - public TypeInfoVariance getVariance() { - return TypeInfoVariance.IN; - } - }; - } - - public static TypeInfoProjection outProjection(TypeInfo typeInfo) { - return new TypeInfoProjectionImpl(typeInfo) { -// @NotNull - @Override - public TypeInfoVariance getVariance() { - return TypeInfoVariance.OUT; - } - }; - } - - private static TypeInfoProjection projection(TypeInfo typeInfo, TypeInfoVariance variance) { - switch (variance) { - case IN: return inProjection(typeInfo); - case OUT: return outProjection(typeInfo); - case INVARIANT: return invariantProjection(typeInfo); - default: throw new IllegalStateException(); - } - } - - public static TypeInfo getTypeInfo(Class klazz, boolean nullable) { - return new TypeInfoImpl(klazz, nullable); - } - - public static TypeInfo getTypeInfo(Class klazz, boolean nullable, TypeInfoProjection[] projections) { - return new TypeInfoImpl(klazz, nullable, projections); - } - - public abstract Class getJavaClass(); - - public abstract Object getClassObject(); - - public abstract boolean isInstance(Object obj); - - public abstract int getProjectionCount(); - - public abstract TypeInfoProjection getProjection(int index); - - public abstract TypeInfo getArgumentType(Class klass, int index); - -} diff --git a/stdlib/src/jet/runtime/ArrayIterator.java b/stdlib/src/jet/runtime/ArrayIterator.java index aa2a6a8c195..e895179185e 100644 --- a/stdlib/src/jet/runtime/ArrayIterator.java +++ b/stdlib/src/jet/runtime/ArrayIterator.java @@ -17,7 +17,6 @@ package jet.runtime; import jet.*; -import jet.typeinfo.TypeInfoProjection; /** * @author alex.tkachman @@ -37,12 +36,10 @@ public abstract class ArrayIterator implements Iterator, JetObject { private static class GenericIterator extends ArrayIterator { private final T[] array; - private final TypeInfo elementTypeInfo; - private GenericIterator(T[] array, TypeInfo elementTypeInfo) { + private GenericIterator(T[] array) { super(array.length); this.array = array; - this.elementTypeInfo = elementTypeInfo; } @Override @@ -50,24 +47,17 @@ public abstract class ArrayIterator implements Iterator, JetObject { return array[index++]; } - @Override - public TypeInfo getTypeInfo() { - return TypeInfo.getTypeInfo(GenericIterator.class, false, new TypeInfoProjection[] {(TypeInfoProjection) elementTypeInfo}); - } - @Override public JetObject getOuterObject() { return null; } } - public static Iterator iterator(T[] array, TypeInfo elementTypeInfo) { - return new GenericIterator(array, elementTypeInfo); + public static Iterator iterator(T[] array) { + return new GenericIterator(array); } private static class ArrayByteIterator extends ByteIterator { - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayByteIterator.class, false); - private final byte[] array; private int index; @@ -85,11 +75,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { return array[index++]; } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; @@ -102,7 +87,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { private static class ArrayShortIterator extends ShortIterator { private final short[] array; - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayShortIterator.class, false); private int index; @@ -120,11 +104,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { return array[index++]; } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; @@ -137,7 +116,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { private static class ArrayIntegerIterator extends IntIterator { private final int[] array; - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayIntegerIterator.class, false); private int index; @@ -155,11 +133,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { return array[index++]; } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; @@ -172,7 +145,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { private static class ArrayLongIterator extends LongIterator { private final long[] array; - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayLongIterator.class, false); private int index; @@ -190,11 +162,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { return array[index++]; } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; @@ -207,7 +174,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { private static class ArrayFloatIterator extends FloatIterator { private final float[] array; - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayFloatIterator.class, false); private int index; @@ -225,11 +191,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { return array[index++]; } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; @@ -242,7 +203,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { private static class ArrayDoubleIterator extends DoubleIterator { private final double[] array; - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayDoubleIterator.class, false); private int index; @@ -260,11 +220,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { return array[index++]; } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; @@ -277,7 +232,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { private static class ArrayCharacterIterator extends CharIterator { private final char[] array; - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayCharacterIterator.class, false); private int index; @@ -295,11 +249,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { return array[index++]; } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; @@ -312,7 +261,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { private static class ArrayBooleanIterator extends BooleanIterator { private final boolean[] array; - private static final TypeInfo typeInfo = TypeInfo.getTypeInfo(ArrayBooleanIterator.class, false); private int index; @@ -330,11 +278,6 @@ public abstract class ArrayIterator implements Iterator, JetObject { return array[index++]; } - @Override - public TypeInfo getTypeInfo() { - return typeInfo; - } - @Override public JetObject getOuterObject() { return null; diff --git a/stdlib/src/jet/runtime/typeinfo/JetTypeDescriptor.java b/stdlib/src/jet/runtime/typeinfo/JetTypeDescriptor.java index b3468e922f4..6a73775442c 100644 --- a/stdlib/src/jet/runtime/typeinfo/JetTypeDescriptor.java +++ b/stdlib/src/jet/runtime/typeinfo/JetTypeDescriptor.java @@ -16,7 +16,6 @@ package jet.runtime.typeinfo; -import jet.typeinfo.TypeInfoVariance; /** * @author alex.tkachman @@ -29,7 +28,6 @@ public @interface JetTypeDescriptor{ // String varName() default ""; boolean reified () default true; - TypeInfoVariance variance() default TypeInfoVariance.INVARIANT; int [] upperBounds() default {}; // diff --git a/stdlib/src/jet/runtime/typeinfo/JetTypeProjection.java b/stdlib/src/jet/runtime/typeinfo/JetTypeProjection.java index 95c10f089b6..22994990746 100644 --- a/stdlib/src/jet/runtime/typeinfo/JetTypeProjection.java +++ b/stdlib/src/jet/runtime/typeinfo/JetTypeProjection.java @@ -16,8 +16,6 @@ package jet.runtime.typeinfo; -import jet.typeinfo.TypeInfoVariance; - import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -28,10 +26,6 @@ import java.lang.annotation.RetentionPolicy; */ @Retention(RetentionPolicy.RUNTIME) public @interface JetTypeProjection { - /** - * @return variance of the type - */ - TypeInfoVariance variance(); /** * @return index of the class in the per class table of JetTypeDescriptor diff --git a/stdlib/src/jet/typeinfo/TypeInfoPattern.java b/stdlib/src/jet/typeinfo/TypeInfoPattern.java deleted file mode 100644 index 5f835dc5513..00000000000 --- a/stdlib/src/jet/typeinfo/TypeInfoPattern.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jet.typeinfo; - -import jet.TypeInfo; - -/** - * This class represents how type info of super class should be matched against type parameters of subclass. - * - * For each subclass we create such pattern for subclass itself and all it super classes either during - * static initialization(or maybe when needed). - * - * For each instance of parametrized type we keep it type info, which can be understood as binding of type parameter variables. - * - * @author alex.tkachman - */ -public interface TypeInfoPattern { - TypeInfo substitute(TypeInfo[] variables); - - class Var implements TypeInfoPattern { - public final int index; - - public Var(int index) { - this.index = index; - } - - @Override - public TypeInfo substitute(TypeInfo[] variables) { - return variables[index]; - } - } - - class Const implements TypeInfoPattern { - private final TypeInfo typeInfo; - - public Const(TypeInfo typeInfo) { - this.typeInfo = typeInfo; - } - - @Override - public TypeInfo substitute(TypeInfo[] variables) { - return typeInfo; - } - } - - class Pattern implements TypeInfoPattern { - public static final TypeInfoPatternProjection[] EMPTY = new TypeInfoPatternProjection[0]; - public final Class klazz; - public final boolean nullable; - public final TypeInfoPatternProjection [] patterns; - - public Pattern(Class klazz, boolean nullable, TypeInfoPatternProjection[] patterns) { - this.klazz = klazz; - this.nullable = nullable; - this.patterns = patterns; - } - - public Pattern(Class klazz, boolean nullable) { - this.klazz = klazz; - this.nullable = nullable; - this.patterns = EMPTY; - } - - @Override - public TypeInfo substitute(TypeInfo[] variables) { - return TypeInfo.getTypeInfo(klazz, nullable, TypeInfoPatternProjection.substitute(patterns, variables)); - } - } - - class TypeInfoPatternProjection { - public final TypeInfoVariance variance; - - public final TypeInfoPattern pattern; - - public TypeInfoPatternProjection(TypeInfoVariance variance, TypeInfoPattern pattern) { - this.variance = variance; - this.pattern = pattern; - } - - public TypeInfoProjection substitute(final TypeInfo[] variables) { - return new TypeInfoProjection() { - @Override - public TypeInfoVariance getVariance() { - return variance; - } - - @Override - public TypeInfo getType() { - return pattern.substitute(variables); - } - }; - } - - public static TypeInfoProjection[] substitute(TypeInfoPatternProjection[] patterns, TypeInfo[] variables) { - if(patterns.length == 0) - return TypeInfoProjection.EMPTY_ARRAY; - TypeInfoProjection [] projections = new TypeInfoProjection[patterns.length]; - for (int i = 0; i < projections.length; i++) { - projections[i] = patterns[i].substitute(variables); - } - return projections; - } - } -} diff --git a/stdlib/src/jet/typeinfo/TypeInfoProjection.java b/stdlib/src/jet/typeinfo/TypeInfoProjection.java deleted file mode 100644 index 1ed3bca4f17..00000000000 --- a/stdlib/src/jet/typeinfo/TypeInfoProjection.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jet.typeinfo; - -import jet.TypeInfo; - -/** - * @author alex.tkachman - */ -public interface TypeInfoProjection { - TypeInfoProjection[] EMPTY_ARRAY = new TypeInfoProjection[0]; - - TypeInfoVariance getVariance(); - - TypeInfo getType(); - -} diff --git a/stdlib/src/org/jetbrains/jet/rt/Signature.java b/stdlib/src/org/jetbrains/jet/rt/Signature.java deleted file mode 100644 index 9dd37384bb5..00000000000 --- a/stdlib/src/org/jetbrains/jet/rt/Signature.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.rt; - -import jet.TypeInfo; -import jet.typeinfo.TypeInfoProjection; - -import java.util.*; - -/** -* @author Stepan Koltsov -*/ -class Signature { - - // TODO: make all these fields private - - final Class klazz; - - List variables; - Map varNames; - List superTypes; - - HashMap superSignatures = new HashMap(); - - Signature(Class klazz) { - this.klazz = klazz; - } - - void afterParse() { - List myVars = variables == null ? Collections.emptyList() : new LinkedList(); - if(variables != null) - for(int i = 0; i != variables.size(); ++i) - myVars.add(new TypeInfoVar(this, false, i)); - - for(TypeInfo superType : superTypes) { - if(superType instanceof TypeInfoImpl) { - TypeInfoImpl type = (TypeInfoImpl) superType; - Signature superSignature = TypeInfoParser.parse(type.signature.klazz); - - TypeInfo substituted = TypeInfoUtils.substitute(type, myVars); - superSignatures.put(type.signature.klazz, substituted); - - List vars = Collections.emptyList(); - if(superType.getProjectionCount() != 0) { - vars = new LinkedList(); - for(int i=0; i != superType.getProjectionCount(); ++i) { - TypeInfo substitute = TypeInfoUtils.substitute(superType.getProjection(i).getType(), myVars); - vars.add(substitute); - } - } - - for(Map.Entry entry : superSignature.superSignatures.entrySet()) { - superSignatures.put(entry.getKey(), TypeInfoUtils.substitute(entry.getValue(), vars)); - } - } - } - } -} diff --git a/stdlib/src/org/jetbrains/jet/rt/TypeInfoImpl.java b/stdlib/src/org/jetbrains/jet/rt/TypeInfoImpl.java deleted file mode 100644 index 57756378dad..00000000000 --- a/stdlib/src/org/jetbrains/jet/rt/TypeInfoImpl.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.rt; - -import jet.JetObject; -import jet.TypeInfo; -import jet.typeinfo.TypeInfoProjection; -import jet.typeinfo.TypeInfoVariance; - -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.List; - -/** - * @author abreslav - * @author yole - * @author alex.tkachman - * @author Stepan Koltsov - */ -public class TypeInfoImpl extends TypeInfo implements TypeInfoProjection { - private final static TypeInfoProjection[] EMPTY = new TypeInfoProjection[0]; - - private TypeInfo typeInfo; - public final Signature signature; - private final boolean nullable; - private final TypeInfoProjection[] projections; - - public TypeInfoImpl(Class theClass, boolean nullable) { - this(theClass, nullable, EMPTY); - } - - public TypeInfoImpl(Class theClass, boolean nullable, TypeInfoProjection[] projections) { - this.signature = TypeInfoParser.parse(theClass); - this.nullable = nullable; - this.projections = projections; - if(signature.variables.size() != projections.length) - throw new IllegalStateException("Wrong signature " + theClass.getName()); - } - - public final TypeInfoProjection getProjection(int index) { - return projections[index]; - } - - @Override - public Object[] newArray(int length) { - return (Object[]) Array.newInstance(signature.klazz, length); - } - - @Override - public Class getJavaClass() { - return signature.klazz; - } - - public final Object getClassObject() { - try { - final Class implClass = signature.klazz.getClassLoader().loadClass(signature.klazz.getCanonicalName()); - final Field classobj = implClass.getField("$classobj"); - return classobj.get(null); - } catch (Exception e) { - return null; - } - } - - TypeInfo getSuperTypeInfo(Class klass) { - return signature.superSignatures.get(klass); - } - - public final TypeInfo getArgumentType(Class klass, int index) { - if(klass == this.signature.klazz) - return projections[index].getType(); - else { - return TypeInfoUtils.substitute(getSuperTypeInfo(klass), projections).getArgumentType(klass, index); - } - } - - TypeInfo substitute(final List myVars) { - if(projections.length == 0) - return new TypeInfoImpl(this.signature.klazz, nullable, EMPTY); - else { - TypeInfoProjection [] proj = new TypeInfoProjection[projections.length]; - for(int i = 0; i != proj.length; ++i) { - final int finalI = i; - final TypeInfo substitute = TypeInfoUtils.substitute(projections[finalI].getType(), myVars); - proj[i] = new TypeInfoProjection(){ - - @Override - public TypeInfoVariance getVariance() { - return projections[finalI].getVariance(); - } - - @Override - public TypeInfo getType() { - return substitute; - } - - @Override - public String toString() { - return getVariance().toString() + " " + substitute; - } - }; - } - return new TypeInfoImpl(this.signature.klazz, nullable, proj); - } - } - - TypeInfo substitute(TypeInfoProjection[] prj) { - if(projections.length == 0) - return new TypeInfoImpl(signature.klazz, nullable, EMPTY); - else { - TypeInfoProjection [] proj = new TypeInfoProjection[projections.length]; - for(int i = 0; i != proj.length; ++i) { - final int finalI = i; - final TypeInfo substitute = TypeInfoUtils.substitute(projections[finalI].getType(), prj); - proj[i] = new TypeInfoProjection(){ - - @Override - public TypeInfoVariance getVariance() { - return projections[finalI].getVariance(); - } - - @Override - public TypeInfo getType() { - return substitute; - } - - @Override - public String toString() { - return getVariance().toString() + " " + substitute; - } - }; - } - return new TypeInfoImpl(signature.klazz, nullable, proj); - } - } - - @Override - public final boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TypeInfoImpl typeInfo = (TypeInfoImpl) o; - - if (!signature.klazz.equals(typeInfo.signature.klazz)) return false; - if (nullable != typeInfo.nullable) return false; - if (!Arrays.equals(projections, typeInfo.projections)) return false; - - return true; - } - -// @NotNull - @Override - public TypeInfoVariance getVariance() { - return TypeInfoVariance.INVARIANT; - } - -// @NotNull - @Override - public TypeInfo getType() { - return this; - } - - @Override - public final int hashCode() { - return 31 * signature.klazz.hashCode() + Arrays.hashCode(projections); - } - - public final boolean isInstance(Object obj) { - if (obj == null) return nullable; - - if (obj instanceof JetObject) { - return ((TypeInfoImpl)((JetObject) obj).getTypeInfo()).isSubtypeOf(this); - } - - return signature.klazz.isAssignableFrom(obj.getClass()); // TODO - } - - @Override - public int getProjectionCount() { - return projections.length; - } - - @Override - public final String toString() { - StringBuilder sb = new StringBuilder().append(signature.klazz.getName()); - if (projections.length != 0) { - sb.append("<"); - for (int i = 0; i != projections.length - 1; ++i) { - sb.append(projections[i].toString()).append(","); - } - sb.append(projections[projections.length - 1].toString()).append(">"); - } - if (nullable) - sb.append("?"); - return sb.toString(); - } - - @Override - public final TypeInfo getTypeInfo() { - if (typeInfo == null) { - // TODO: Implementation must be lazy, otherwise the result would be of an infinite size - throw new UnsupportedOperationException(); // TODO - } - return typeInfo; - } - - @Override - public JetObject getOuterObject() { - return null; - } - - public final boolean isSubtypeOf(TypeInfoImpl superType) { - if (nullable && !superType.nullable) { - return false; - } - if (!superType.signature.klazz.isAssignableFrom(signature.klazz)) { - return false; - } - if (superType.projections == null || superType.projections.length != projections.length) { - throw new IllegalArgumentException("inconsistent type info for the same class"); - } - for (int i = 0; i < projections.length; i++) { - // TODO handle variance here - if (!projections[i].getType().equals(superType.projections[i].getType())) { - return false; - } - } - return true; - } - -} diff --git a/stdlib/src/org/jetbrains/jet/rt/TypeInfoParser.java b/stdlib/src/org/jetbrains/jet/rt/TypeInfoParser.java deleted file mode 100644 index dad9d5afddb..00000000000 --- a/stdlib/src/org/jetbrains/jet/rt/TypeInfoParser.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.rt; - -import jet.TypeInfo; -import jet.runtime.typeinfo.JetClass; -import jet.typeinfo.TypeInfoProjection; -import jet.typeinfo.TypeInfoVariance; -import org.jetbrains.jet.rt.signature.JetSignatureExceptionsAdapter; -import org.jetbrains.jet.rt.signature.JetSignatureReader; -import org.jetbrains.jet.rt.signature.JetSignatureVariance; -import org.jetbrains.jet.rt.signature.JetSignatureVisitor; - -import java.lang.reflect.TypeVariable; -import java.util.*; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -/** -* @author Stepan Koltsov -*/ -class TypeInfoParser { - static final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - static final WeakHashMap map = new WeakHashMap(); - - public static Signature parse(Class klass) { - if(klass == null) - return null; - -// lock.readLock().lock(); - Signature sig = map.get(klass); -// lock.readLock().unlock(); - if (sig == null) { -// lock.writeLock().lock(); - - sig = map.get(klass); - if (sig == null) { - sig = internalParse(klass); - } - -// lock.writeLock().unlock(); - } - return sig; - } - - private static Signature internalParse(Class klass) { - if(klass.isArray() && !klass.getComponentType().isPrimitive()) { - Signature signature = new ArraySignature(klass); - map.put(klass, signature); - return signature; - } - - JetClass annotation = (JetClass) klass.getAnnotation(JetClass.class); - if(annotation != null) { - String value = annotation.signature(); - if(value != null) { - Class enclosingClass = klass.getEnclosingClass(); - Signature signature = new Signature(klass); - map.put(klass, signature); - parse(value, signature); - signature.afterParse(); - return signature; - } - } - return getGenericSignature(klass); - } - - private static void parse(String annotationValue, final Signature signature) { - signature.variables = new ArrayList(); - signature.varNames = new HashMap(); - signature.superTypes = new ArrayList(); - new JetSignatureReader(annotationValue).accept(new JetSignatureExceptionsAdapter() { - - @Override - public JetSignatureVisitor visitFormalTypeParameter(final String name, final TypeInfoVariance variance, boolean reified) { - - // TODO: nullability - - return new JetSignatureExceptionsAdapter() { - @Override - public JetSignatureVisitor visitClassBound() { - return new SignatureParserJetSignatureAdapter(signature.klazz.getClassLoader(), signature) { - @Override - protected void done(TypeInfo typeInfo) { - // TODO - } - }; - } - - @Override - public JetSignatureVisitor visitInterfaceBound() { - return new SignatureParserJetSignatureAdapter(signature.klazz.getClassLoader(), signature) { - @Override - protected void done(TypeInfo typeInfo) { - // TODO - } - }; - } - - @Override - public void visitFormalTypeParameterEnd() { - final TypeInfoVar typeInfoVar = new TypeInfoVar(signature, signature.variables.size()); - - signature.varNames.put(name, signature.variables.size()); - TypeInfoProjection typeInfoProjection = new TypeInfoProjection() { - @Override - public TypeInfoVariance getVariance() { - return variance; - } - - @Override - public TypeInfo getType() { - return typeInfoVar; - } - - @Override - public String toString() { - return typeInfoVar.toString(); - } - }; - - signature.variables.add(typeInfoProjection); - } - }; - } - - @Override - public JetSignatureVisitor visitSuperclass() { - return new SignatureParserJetSignatureAdapter(signature.klazz.getClassLoader(), signature) { - @Override - protected void done(TypeInfo typeInfo) { - signature.superTypes.add(typeInfo); - signature.superSignatures.put(typeInfo.getJavaClass(), typeInfo); - } - }; - } - - @Override - public JetSignatureVisitor visitInterface() { - return new SignatureParserJetSignatureAdapter(signature.klazz.getClassLoader(), signature) { - @Override - protected void done(TypeInfo typeInfo) { - signature.superTypes.add(typeInfo); - signature.superSignatures.put(typeInfo.getJavaClass(), typeInfo); - } - }; - } - }); - } - - - private static abstract class SignatureParserJetSignatureAdapter extends JetSignatureExceptionsAdapter { - private final ClassLoader classLoader; - private final Signature signature; - - protected SignatureParserJetSignatureAdapter(ClassLoader classLoader, Signature signature) { - this.classLoader = classLoader; - this.signature = signature; - } - - protected abstract void done(TypeInfo typeInfo); - - private Class klass; - private boolean nullable; - private List projections; - - @Override - public void visitClassType(String name, boolean nullable, boolean forceReal) { - try { - // TODO: real flag - klass = classLoader.loadClass(name.replace('/', '.')); - } catch (ClassNotFoundException e) { - throw new RuntimeException(); - } - this.nullable = nullable; - this.projections = new ArrayList(); - } - - private static TypeInfoVariance parseVariance(JetSignatureVariance variance) { - switch (variance) { - case INVARIANT: return TypeInfoVariance.INVARIANT; - case OUT: return TypeInfoVariance.OUT; - case IN: return TypeInfoVariance.IN; - default: throw new IllegalStateException(); - } - } - - @Override - public JetSignatureVisitor visitTypeArgument(final JetSignatureVariance wildcard) { - final TypeInfoVariance variance = parseVariance(wildcard); - return new SignatureParserJetSignatureAdapter(classLoader, signature) { - @Override - protected void done(TypeInfo typeInfo) { - projections.add(new TypeInfoProjectionImpl(typeInfo) { - @Override - public TypeInfoVariance getVariance() { - return variance; - } - }); - } - }; - } - - @Override - public void visitTypeVariable(String name, boolean nullable) { - Integer varIndex = signature.varNames.get(name); - if (varIndex == null) { - throw new IllegalStateException("unresolved type variable: " + name); - } - TypeInfoVar typeInfo = new TypeInfoVar(signature, nullable, varIndex); - done(typeInfo); - } - - @Override - public void visitEnd() { - done(new TypeInfoImpl(klass, nullable, projections.toArray(new TypeInfoProjection[0]))); - } - } - - - private static Signature getGenericSignature(Class klass) { - // todo complete impl - - java.lang.reflect.Type genericSuperclass = klass.getGenericSuperclass(); - Signature signature = new Signature(klass); - - TypeVariable[] typeParameters = klass.getTypeParameters(); - if(typeParameters == null || typeParameters.length == 0) { - signature.varNames = Collections.emptyMap(); - signature.variables = Collections.emptyList(); - } - else { - signature.varNames = new HashMap(); - signature.variables = new LinkedList(); - } - - if (typeParameters != null && typeParameters.length != 0) { - for (int i = 0; i < typeParameters.length; i++) { - TypeVariable typeParameter = typeParameters[i]; - signature.varNames.put(typeParameter.getName(), i); - final TypeInfoVar typeInfoVar = new TypeInfoVar(signature, false, i); - signature.variables.add(new TypeInfoProjection(){ - - @Override - public TypeInfoVariance getVariance() { - return TypeInfoVariance.INVARIANT; - } - - @Override - public TypeInfo getType() { - return typeInfoVar; - } - - @Override - public String toString() { - return typeInfoVar.toString(); - } - }); - } - } - - return signature; - } - - private static class ArraySignature extends Signature { - public ArraySignature(Class klass) { - super(klass); - variables = new LinkedList(); - varNames = new HashMap(); - varNames.put("T", 0); - final TypeInfoVar typeInfoVar = new TypeInfoVar(this, 0); - variables.add(new TypeInfoProjection() { - @Override - public TypeInfoVariance getVariance() { - return TypeInfoVariance.INVARIANT; - } - - @Override - public TypeInfo getType() { - return typeInfoVar; - } - }); - } - } -} diff --git a/stdlib/src/org/jetbrains/jet/rt/TypeInfoProjectionImpl.java b/stdlib/src/org/jetbrains/jet/rt/TypeInfoProjectionImpl.java deleted file mode 100644 index 2c80278fb68..00000000000 --- a/stdlib/src/org/jetbrains/jet/rt/TypeInfoProjectionImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.rt; - -import jet.TypeInfo; -import jet.typeinfo.TypeInfoProjection; -import jet.typeinfo.TypeInfoVariance; - -/** - * @author abreslav - * @author yole - * @author alex.tkachman - * @author Stepan Koltsov - */ -public abstract class TypeInfoProjectionImpl implements TypeInfoProjection { - private final TypeInfo type; - - public TypeInfoProjectionImpl(TypeInfo typeInfo) { - this.type = typeInfo; - } - - @Override - public final TypeInfo getType() { - return type; - } - - @Override - public final boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TypeInfoProjectionImpl that = (TypeInfoProjectionImpl) o; - // no need to compare variance as we compared classes already - return type.equals(that.type); - } - - @Override - public final int hashCode() { - int result = type.hashCode(); - result = 31 * result + (getVariance().hashCode()); - return result; - } - - @Override - public final String toString() { - return (getVariance() == TypeInfoVariance.INVARIANT ? "" : getVariance().toString() + " ") + type; - } -} diff --git a/stdlib/src/org/jetbrains/jet/rt/TypeInfoUtils.java b/stdlib/src/org/jetbrains/jet/rt/TypeInfoUtils.java deleted file mode 100644 index 54e6f332832..00000000000 --- a/stdlib/src/org/jetbrains/jet/rt/TypeInfoUtils.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.rt; - -import jet.TypeInfo; -import jet.typeinfo.TypeInfoProjection; - -import java.util.List; - -/** - * @author abreslav - * @author yole - * @author alex.tkachman - * @author Stepan Koltsov - */ -class TypeInfoUtils { - - static TypeInfo substitute(TypeInfo typeInfo, TypeInfoProjection[] projections) { - if (typeInfo instanceof TypeInfoImpl) { - TypeInfoImpl typeInfoImpl = (TypeInfoImpl) typeInfo; - return typeInfoImpl.substitute(projections); - } else if (typeInfo instanceof TypeInfoVar) { - TypeInfoVar typeInfoVar = (TypeInfoVar) typeInfo; - return typeInfoVar.substitute(projections); - } else { - throw new IllegalStateException(); - } - } - - static TypeInfo substitute(TypeInfo typeInfo, List myVars) { - if (typeInfo instanceof TypeInfoImpl) { - TypeInfoImpl typeInfoImpl = (TypeInfoImpl) typeInfo; - return typeInfoImpl.substitute(myVars); - } else if (typeInfo instanceof TypeInfoVar) { - TypeInfoVar typeInfoVar = (TypeInfoVar) typeInfo; - return typeInfoVar.substitute(myVars); - } else { - throw new IllegalStateException(); - } - } - -} diff --git a/stdlib/src/org/jetbrains/jet/rt/TypeInfoVar.java b/stdlib/src/org/jetbrains/jet/rt/TypeInfoVar.java deleted file mode 100644 index abe989aab76..00000000000 --- a/stdlib/src/org/jetbrains/jet/rt/TypeInfoVar.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.rt; - -import jet.JetObject; -import jet.TypeInfo; -import jet.typeinfo.TypeInfoProjection; - -import java.util.List; - -/** - * @author abreslav - * @author yole - * @author alex.tkachman - * @author Stepan Koltsov - */ -class TypeInfoVar extends TypeInfo { - final int varIndex; - final Signature signature; - final boolean nullable; - - public TypeInfoVar(Signature signature, Integer varIndex) { - this.signature = signature; - this.varIndex = varIndex; - nullable = false; - } - - public TypeInfoVar(Signature signature, boolean nullable, int varIndex) { - this.signature = signature; - this.nullable = nullable; - this.varIndex = varIndex; - } - - @Override - public Object[] newArray(int length) { - throw new UnsupportedOperationException(); - } - - @Override - public Class getJavaClass() { - throw new UnsupportedOperationException(); - } - - @Override - public Object getClassObject() { - throw new UnsupportedOperationException("Abstract TypeInfo"); - } - - @Override - public boolean isInstance(Object obj) { - throw new UnsupportedOperationException("Abstract TypeInfo"); - } - - @Override - public int getProjectionCount() { - return 0; - } - - @Override - public TypeInfoProjection getProjection(int index) { - throw new UnsupportedOperationException("Abstract TypeInfo"); - } - - @Override - public TypeInfo getArgumentType(Class klass, int index) { - throw new UnsupportedOperationException("Abstract TypeInfo"); - } - - TypeInfo substitute(List myVars) { - return myVars.get(varIndex); - } - - TypeInfo substitute(TypeInfoProjection[] projections) { - return projections[varIndex].getType(); - } - - @Override - public TypeInfo getTypeInfo() { - throw new UnsupportedOperationException("Abstract TypeInfo"); - } - - @Override - public JetObject getOuterObject() { - return null; - } - - @Override - public String toString() { - return "T:" + signature.klazz.getName() + ":" + varIndex; - } -} diff --git a/testlib/test/JavaClassTest.kt b/testlib/test/JavaClassTest.kt index 1babadec901..e436a701047 100644 --- a/testlib/test/JavaClassTest.kt +++ b/testlib/test/JavaClassTest.kt @@ -6,7 +6,8 @@ class C() class JavaClassTest() : TestSupport() { fun testMe () { - assertEquals("java.util.ArrayList", javaClass>().getName()) - assertEquals("testjc.C", javaClass().getName()) + assertEquals("java.util.ArrayList", java.util.ArrayList().javaClass.getName()) +// assertEquals("java.util.ArrayList", javaClass>().getName()) +// assertEquals("testjc.C", javaClass().getName()) } } \ No newline at end of file