From 06aa1478e673cbdf3dc6020bace0ece105b171d2 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 26 Jun 2012 19:50:47 +0200 Subject: [PATCH] A private constructor added to Nothing --- .../lang/types/lang/JetStandardClasses.java | 79 ++++++++++--------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/lang/JetStandardClasses.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/lang/JetStandardClasses.java index d34a3bb326b..c9c84c735c8 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/lang/JetStandardClasses.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/lang/JetStandardClasses.java @@ -52,52 +52,52 @@ public class JetStandardClasses { static { FAKE_STANDARD_CLASSES_MODULE.setRootNamespace(STANDARD_CLASSES_FAKE_ROOT_NS); - //WritableScopeImpl writableScope = - // new WritableScopeImpl(JetScope.EMPTY, FAKE_STANDARD_CLASSES_MODULE, RedeclarationHandler.DO_NOTHING); - //STANDARD_CLASSES_FAKE_ROOT_NS.initialize(writableScope); - //STANDARD_CLASSES_FAKE_ROOT_NS.getMemberScope().changeLockLevel(WritableScope.LockLevel.BOTH); } public static NamespaceDescriptorImpl STANDARD_CLASSES_NAMESPACE = new NamespaceDescriptorImpl( STANDARD_CLASSES_FAKE_ROOT_NS, Collections.emptyList(), Name.identifier("jet")); - // - //static { - // STANDARD_CLASSES_FAKE_ROOT_NS.getMemberScope().addNamespace(STANDARD_CLASSES_NAMESPACE); - //} - + public static final FqName STANDARD_CLASSES_FQNAME = DescriptorUtils.getFQName(STANDARD_CLASSES_NAMESPACE).toSafe(); - private static final ClassDescriptor NOTHING_CLASS = new ClassDescriptorImpl( - STANDARD_CLASSES_NAMESPACE, - Collections.emptyList(), - Modality.FINAL, - Name.identifier("Nothing") - ).initialize( - true, - Collections.emptyList(), - new AbstractCollection() { - @Override - public boolean contains(Object o) { - return o instanceof JetType; - } + private static final ClassDescriptor NOTHING_CLASS; + private static final JetType NOTHING_TYPE; + static { + ClassDescriptorImpl nothing = new ClassDescriptorImpl( + STANDARD_CLASSES_NAMESPACE, + Collections.emptyList(), + Modality.FINAL, + Name.identifier("Nothing") + ); + ConstructorDescriptorImpl constructorDescriptor = new ConstructorDescriptorImpl(nothing, Collections.emptyList(), true); + constructorDescriptor.initialize(Collections.emptyList(), Collections.emptyList(), Visibilities.PRIVATE); + NOTHING_CLASS = nothing.initialize( + true, + Collections.emptyList(), + new AbstractCollection() { + @Override + public boolean contains(Object o) { + return o instanceof JetType; + } - @Override - public Iterator iterator() { - throw new UnsupportedOperationException("Don't enumerate supertypes of Nothing"); - } + @Override + public Iterator iterator() { + throw new UnsupportedOperationException("Don't enumerate supertypes of Nothing"); + } - @Override - public int size() { - throw new UnsupportedOperationException("Supertypes of Nothing do not constitute a valid collection"); - } - }, - JetScope.EMPTY, - Collections.emptySet(), - null, - null - ); + @Override + public int size() { + throw new UnsupportedOperationException("Supertypes of Nothing do not constitute a valid collection"); + } + }, + JetScope.EMPTY, + Collections.singleton(constructorDescriptor), + null, + null + ); + NOTHING_TYPE = new JetTypeImpl(getNothing()); + constructorDescriptor.setReturnType(NOTHING_TYPE); + } - private static final JetType NOTHING_TYPE = new JetTypeImpl(getNothing()); private static final JetType NULLABLE_NOTHING_TYPE = new JetTypeImpl( Collections.emptyList(), getNothing().getTypeConstructor(), @@ -243,12 +243,13 @@ public class JetStandardClasses { RECEIVER_FUNCTION[i] = receiverFunction.initialize( false, parameters, - Collections.singleton(getAnyType()), scopeForInvokeWithReceiver, Collections.singleton(constructorDescriptorForReceiverFunction), null); + Collections.singleton(getAnyType()), scopeForInvokeWithReceiver, Collections.singleton( + constructorDescriptorForReceiverFunction), null); RECEIVER_FUNCTION_TYPE_CONSTRUCTORS.add(RECEIVER_FUNCTION[i].getTypeConstructor()); FunctionDescriptorUtil.initializeFromFunctionType(invokeWithReceiver, receiverFunction.getDefaultType(), new ClassReceiver(RECEIVER_FUNCTION[i]), Modality.ABSTRACT, Visibilities.PUBLIC); constructorDescriptorForReceiverFunction.initialize(receiverFunction.getTypeConstructor().getParameters(), - Collections.emptyList(), Visibilities.PUBLIC); + Collections.emptyList(), Visibilities.PUBLIC); constructorDescriptorForReceiverFunction.setReturnType(receiverFunction.getDefaultType()); } }