diff --git a/compiler/tests/org/jetbrains/jet/checkers/LazyOperationsLog.kt b/compiler/tests/org/jetbrains/jet/checkers/LazyOperationsLog.kt index 65302cd0a89..ae9a52a8e52 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/LazyOperationsLog.kt +++ b/compiler/tests/org/jetbrains/jet/checkers/LazyOperationsLog.kt @@ -155,7 +155,7 @@ class LazyOperationsLog( javaClass.getPsi().getName().appendQuoted() } o.javaClass.getSimpleName() == "DeserializedType" -> { - val typeDeserializer = o.field("this\$0") + val typeDeserializer = o.field("typeDeserializer") val context = typeDeserializer.field("context") val typeProto = o.field("typeProto") val text = when (typeProto.getConstructor().getKind()) { diff --git a/core/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java b/core/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java index ab077cbe34a..8356846cb68 100644 --- a/core/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java +++ b/core/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java @@ -82,18 +82,22 @@ public class TypeDeserializer { String id = context.getNameResolver().getString(proto.getFlexibleTypeCapabilitiesId()); FlexibleTypeCapabilities capabilities = getComponents().getFlexibleTypeCapabilitiesDeserializer().capabilitiesById(id); - if (capabilities == null) return ErrorUtils.createErrorType(new DeserializedType(proto) + ": Capabilities not found for id " + id); + if (capabilities == null) { + return ErrorUtils.createErrorType(new DeserializedType(context, proto) + ": Capabilities not found for id " + id); + } return DelegatingFlexibleType.create( - new DeserializedType(proto), - new DeserializedType(proto.getFlexibleUpperBound()), + new DeserializedType(context, proto), + new DeserializedType(context, proto.getFlexibleUpperBound()), capabilities ); } - return new DeserializedType(proto); + + return new DeserializedType(context, proto); } - private TypeConstructor typeConstructor(ProtoBuf.Type proto) { + @NotNull + public TypeConstructor typeConstructor(@NotNull ProtoBuf.Type proto) { ProtoBuf.Type.Constructor constructorProto = proto.getConstructor(); int id = constructorProto.getId(); TypeConstructor typeConstructor = typeConstructor(constructorProto); @@ -101,7 +105,7 @@ public class TypeDeserializer { String message = constructorProto.getKind() == ProtoBuf.Type.Constructor.Kind.CLASS ? context.getNameResolver().getClassId(id).asSingleFqName().asString() : "Unknown type parameter " + id; - typeConstructor = ErrorUtils.createErrorType(message).getConstructor(); + return ErrorUtils.createErrorType(message).getConstructor(); } return typeConstructor; } @@ -142,7 +146,8 @@ public class TypeDeserializer { ); } - private List typeArguments(List protos) { + @NotNull + public List typeArguments(@NotNull List protos) { List result = new ArrayList(protos.size()); for (ProtoBuf.Type.Argument proto : protos) { result.add(typeProjection(proto)); @@ -154,43 +159,30 @@ public class TypeDeserializer { return new TypeProjectionImpl(variance(proto.getProjection()), type(proto.getType())); } - @NotNull - private static JetScope getTypeMemberScope(@NotNull TypeConstructor constructor, @NotNull List typeArguments) { - ClassifierDescriptor descriptor = constructor.getDeclarationDescriptor(); - if (descriptor instanceof TypeParameterDescriptor) { - TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) descriptor; - return typeParameterDescriptor.getDefaultType().getMemberScope(); - } - else if (descriptor instanceof ClassDescriptor) { - return ((ClassDescriptor) descriptor).getMemberScope(typeArguments); - } - else { - throw new IllegalStateException("Unsupported classifier: " + descriptor); - } - } - @Override public String toString() { return debugName; } - private class DeserializedType extends AbstractJetType implements LazyType { + private static class DeserializedType extends AbstractJetType implements LazyType { + private final TypeDeserializer typeDeserializer; private final ProtoBuf.Type typeProto; private final NotNullLazyValue constructor; private final List arguments; private final NotNullLazyValue memberScope; - public DeserializedType(@NotNull ProtoBuf.Type proto) { + public DeserializedType(@NotNull DeserializationContext context, @NotNull ProtoBuf.Type proto) { + this.typeDeserializer = context.getTypeDeserializer(); this.typeProto = proto; - this.arguments = typeArguments(proto.getArgumentList()); + this.arguments = typeDeserializer.typeArguments(proto.getArgumentList()); - this.constructor = getComponents().getStorageManager().createLazyValue(new Function0() { + this.constructor = context.getComponents().getStorageManager().createLazyValue(new Function0() { @Override public TypeConstructor invoke() { - return typeConstructor(typeProto); + return typeDeserializer.typeConstructor(typeProto); } }); - this.memberScope = getComponents().getStorageManager().createLazyValue(new Function0() { + this.memberScope = context.getComponents().getStorageManager().createLazyValue(new Function0() { @Override public JetScope invoke() { return computeMemberScope(); @@ -225,6 +217,21 @@ public class TypeDeserializer { } } + @NotNull + private static JetScope getTypeMemberScope(@NotNull TypeConstructor constructor, @NotNull List typeArguments) { + ClassifierDescriptor descriptor = constructor.getDeclarationDescriptor(); + if (descriptor instanceof TypeParameterDescriptor) { + TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) descriptor; + return typeParameterDescriptor.getDefaultType().getMemberScope(); + } + else if (descriptor instanceof ClassDescriptor) { + return ((ClassDescriptor) descriptor).getMemberScope(typeArguments); + } + else { + throw new IllegalStateException("Unsupported classifier: " + descriptor); + } + } + @NotNull @Override public JetScope getMemberScope() {