jet.Any: modality and constructor straightened
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -25,14 +24,13 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
|
||||
@@ -78,6 +76,7 @@ public class ClosureAnnotator {
|
||||
classDescriptor = new ClassDescriptorImpl(
|
||||
funDescriptor,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Modality.FINAL,
|
||||
Name.special("<closure>"));
|
||||
recordName(classDescriptor, name);
|
||||
classDescriptor.initialize(
|
||||
@@ -102,6 +101,7 @@ public class ClosureAnnotator {
|
||||
ClassDescriptorImpl classDescriptor = new ClassDescriptorImpl(
|
||||
scriptDescriptor,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Modality.FINAL,
|
||||
Name.special("<script-" + className + ">"));
|
||||
recordName(classDescriptor, className);
|
||||
classDescriptor.initialize(
|
||||
|
||||
@@ -39,12 +39,15 @@ public class ClassDescriptorImpl extends DeclarationDescriptorNonRootImpl implem
|
||||
private Set<ConstructorDescriptor> constructors;
|
||||
private ConstructorDescriptor primaryConstructor;
|
||||
private ReceiverDescriptor implicitReceiver;
|
||||
private final Modality modality;
|
||||
|
||||
public ClassDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
@NotNull Modality modality,
|
||||
@NotNull Name name) {
|
||||
super(containingDeclaration, annotations, name);
|
||||
this.modality = modality;
|
||||
}
|
||||
|
||||
public final ClassDescriptorImpl initialize(boolean sealed,
|
||||
@@ -155,7 +158,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorNonRootImpl implem
|
||||
@Override
|
||||
@NotNull
|
||||
public Modality getModality() {
|
||||
return Modality.FINAL;
|
||||
return modality;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -118,7 +118,7 @@ public class ErrorUtils {
|
||||
|
||||
}
|
||||
|
||||
private static final ClassDescriptorImpl ERROR_CLASS = new ClassDescriptorImpl(ERROR_MODULE, Collections.<AnnotationDescriptor>emptyList(), Name.special("<ERROR CLASS>")) {
|
||||
private static final ClassDescriptorImpl ERROR_CLASS = new ClassDescriptorImpl(ERROR_MODULE, Collections.<AnnotationDescriptor>emptyList(), Modality.OPEN, Name.special("<ERROR CLASS>")) {
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ConstructorDescriptor> getConstructors() {
|
||||
|
||||
@@ -70,6 +70,7 @@ public class JetStandardClasses {
|
||||
private static final ClassDescriptor NOTHING_CLASS = new ClassDescriptorImpl(
|
||||
STANDARD_CLASSES_NAMESPACE,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Modality.FINAL,
|
||||
Name.identifier("Nothing")
|
||||
).initialize(
|
||||
true,
|
||||
@@ -106,31 +107,41 @@ public class JetStandardClasses {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private static final ClassDescriptor ANY = new ClassDescriptorImpl(
|
||||
STANDARD_CLASSES_NAMESPACE,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Name.identifier("Any")).initialize(
|
||||
false,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.<JetType>emptySet(),
|
||||
JetScope.EMPTY,
|
||||
Collections.<ConstructorDescriptor>emptySet(),
|
||||
null,
|
||||
null
|
||||
);
|
||||
private static final ClassDescriptor ANY;
|
||||
private static final JetType ANY_TYPE;
|
||||
|
||||
private static final JetType ANY_TYPE = new JetTypeImpl(ANY.getTypeConstructor(), new JetScopeImpl() {
|
||||
@NotNull
|
||||
@Override
|
||||
public DeclarationDescriptor getContainingDeclaration() {
|
||||
return STANDARD_CLASSES_NAMESPACE;
|
||||
}
|
||||
static {
|
||||
ClassDescriptorImpl any = new ClassDescriptorImpl(
|
||||
STANDARD_CLASSES_NAMESPACE,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Modality.OPEN,
|
||||
Name.identifier("Any")
|
||||
);
|
||||
ConstructorDescriptorImpl constructorDescriptor = new ConstructorDescriptorImpl(any, Collections.<AnnotationDescriptor>emptyList(), true);
|
||||
constructorDescriptor.initialize(Collections.<TypeParameterDescriptor>emptyList(), Collections.<ValueParameterDescriptor>emptyList(), Visibilities.PUBLIC);
|
||||
ANY = any.initialize(
|
||||
false,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.<JetType>emptySet(),
|
||||
JetScope.EMPTY,
|
||||
Collections.<ConstructorDescriptor>singleton(constructorDescriptor),
|
||||
null,
|
||||
null
|
||||
);
|
||||
ANY_TYPE = new JetTypeImpl(ANY.getTypeConstructor(), new JetScopeImpl() {
|
||||
@NotNull
|
||||
@Override
|
||||
public DeclarationDescriptor getContainingDeclaration() {
|
||||
return STANDARD_CLASSES_NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Scope for Any";
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Scope for Any";
|
||||
}
|
||||
});
|
||||
constructorDescriptor.setReturnType(ANY_TYPE);
|
||||
}
|
||||
private static final JetType NULLABLE_ANY_TYPE = new JetTypeImpl(ANY_TYPE.getAnnotations(), ANY_TYPE.getConstructor(), true, ANY_TYPE.getArguments(), ANY_TYPE.getMemberScope());
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -154,6 +165,7 @@ public class JetStandardClasses {
|
||||
ClassDescriptorImpl classDescriptor = new ClassDescriptorImpl(
|
||||
STANDARD_CLASSES_NAMESPACE,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Modality.FINAL,
|
||||
Name.identifier("Tuple" + i));
|
||||
WritableScopeImpl writableScope = new WritableScopeImpl(JetScope.EMPTY, classDescriptor, RedeclarationHandler.THROW_EXCEPTION, "tuples");
|
||||
for (int j = 0; j < i; j++) {
|
||||
@@ -196,6 +208,7 @@ public class JetStandardClasses {
|
||||
ClassDescriptorImpl function = new ClassDescriptorImpl(
|
||||
STANDARD_CLASSES_NAMESPACE,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Modality.OPEN,
|
||||
Name.identifier("Function" + i));
|
||||
|
||||
SimpleFunctionDescriptorImpl invoke = new SimpleFunctionDescriptorImpl(function, Collections.<AnnotationDescriptor>emptyList(), Name.identifier("invoke"), CallableMemberDescriptor.Kind.DECLARATION);
|
||||
@@ -211,6 +224,7 @@ public class JetStandardClasses {
|
||||
ClassDescriptorImpl receiverFunction = new ClassDescriptorImpl(
|
||||
STANDARD_CLASSES_NAMESPACE,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Modality.OPEN,
|
||||
Name.identifier("ExtensionFunction" + i));
|
||||
SimpleFunctionDescriptorImpl invokeWithReceiver = new SimpleFunctionDescriptorImpl(receiverFunction, Collections.<AnnotationDescriptor>emptyList(), Name.identifier("invoke"), CallableMemberDescriptor.Kind.DECLARATION);
|
||||
WritableScope scopeForInvokeWithReceiver = createScopeForInvokeFunction(receiverFunction, invokeWithReceiver);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//KT-1249 IllegalStateException invoking function property
|
||||
class TestClass(val body : () -> Unit) : Any {
|
||||
class TestClass(val body : () -> Unit) : Any() {
|
||||
fun run() {
|
||||
body()
|
||||
}
|
||||
|
||||
@@ -689,6 +689,7 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
final ClassDescriptorImpl classDescriptor = new ClassDescriptorImpl(
|
||||
scope.getContainingDeclaration(),
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Modality.FINAL,
|
||||
JetPsiUtil.safeName(classElement.getName()));
|
||||
|
||||
BindingTrace trace = JetTestUtils.DUMMY_TRACE;
|
||||
|
||||
Reference in New Issue
Block a user