diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java index 6d233d48012..9bf2ec44d19 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java @@ -144,7 +144,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen { function = function.initialize( false, Collections.emptyList(), - Collections.singleton((funDescriptor.getReceiverParameter().exists() ? JetStandardClasses.getReceiverFunction(arity) : JetStandardClasses.getFunction(arity)).getDefaultType()), JetScope.EMPTY, Collections.emptySet(), null); + Collections.singleton((funDescriptor.getReceiverParameter().exists() ? JetStandardClasses.getReceiverFunction(arity) : JetStandardClasses.getFunction(arity)).getDefaultType()), JetScope.EMPTY, Collections.emptySet(), null); final CodegenContext.ClosureContext closureContext = context.intoClosure(funDescriptor, function, name, this); FunctionCodegen fc = new FunctionCodegen(closureContext, cv, state); diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassDescriptor.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassDescriptor.java index 4327be71475..3ffed2fa4ff 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassDescriptor.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassDescriptor.java @@ -21,7 +21,7 @@ public class JavaClassDescriptor extends MutableDeclarationDescriptor implements private TypeConstructor typeConstructor; private JavaClassMembersScope unsubstitutedMemberScope; // private JetType classObjectType; - private final Set constructors = Sets.newLinkedHashSet(); + private final Set constructors = Sets.newLinkedHashSet(); private Modality modality; private Visibility visibility; private JetType superclassType; @@ -97,7 +97,7 @@ public class JavaClassDescriptor extends MutableDeclarationDescriptor implements @NotNull @Override - public Set getConstructors() { + public Set getConstructors() { return constructors; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptor.java index cf468bee683..7a72b505b27 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptor.java @@ -26,7 +26,7 @@ public interface ClassDescriptor extends ClassifierDescriptor, MemberDescriptor JetType getSuperclassType(); @NotNull - Set getConstructors(); + Set getConstructors(); @Nullable ConstructorDescriptor getUnsubstitutedPrimaryConstructor(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.java index 962ec21cd3f..059215e2f9f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassDescriptorImpl.java @@ -21,7 +21,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements Cl private TypeConstructor typeConstructor; private JetScope memberDeclarations; - private Set constructors; + private Set constructors; private ConstructorDescriptor primaryConstructor; private JetType superclassType; private ReceiverDescriptor implicitReceiver; @@ -37,7 +37,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements Cl @NotNull List typeParameters, @NotNull Collection supertypes, @NotNull JetScope memberDeclarations, - @NotNull Set constructors, + @NotNull Set constructors, @Nullable ConstructorDescriptor primaryConstructor) { return initialize(sealed, typeParameters, supertypes, memberDeclarations, constructors, primaryConstructor, getClassType(supertypes)); } @@ -46,7 +46,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements Cl @NotNull List typeParameters, @NotNull Collection supertypes, @NotNull JetScope memberDeclarations, - @NotNull Set constructors, + @NotNull Set constructors, @Nullable ConstructorDescriptor primaryConstructor, @Nullable JetType superclassType) { this.typeConstructor = new TypeConstructorImpl(this, getAnnotations(), sealed, getName(), typeParameters, supertypes); @@ -103,7 +103,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements Cl @NotNull @Override - public Set getConstructors() { + public Set getConstructors() { return constructors; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.java index 084e5004cdf..6275222ef9a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ConstructorDescriptorImpl.java @@ -30,9 +30,9 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements @Override @Deprecated - public FunctionDescriptorImpl initialize(@Nullable JetType receiverType, @NotNull ReceiverDescriptor expectedThisObject, @NotNull List typeParameters, @NotNull List unsubstitutedValueParameters, @Nullable JetType unsubstitutedReturnType, Modality modality, @NotNull Visibility visibility) { + public ConstructorDescriptorImpl initialize(@Nullable JetType receiverType, @NotNull ReceiverDescriptor expectedThisObject, @NotNull List typeParameters, @NotNull List unsubstitutedValueParameters, @Nullable JetType unsubstitutedReturnType, Modality modality, @NotNull Visibility visibility) { assert receiverType == null; - return super.initialize(null, expectedThisObject, typeParameters, unsubstitutedValueParameters, unsubstitutedReturnType, modality, visibility); + return (ConstructorDescriptorImpl) super.initialize(null, expectedThisObject, typeParameters, unsubstitutedValueParameters, unsubstitutedReturnType, modality, visibility); } public ConstructorDescriptorImpl initialize(@NotNull List typeParameters, @NotNull List unsubstitutedValueParameters, Modality modality, Visibility visibility) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.java index 1ac7c0efcf6..84d1946f13b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/LazySubstitutingClassDescriptor.java @@ -104,7 +104,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor { @NotNull @Override - public Set getConstructors() { + public Set getConstructors() { throw new UnsupportedOperationException(); // TODO } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java index 0a32795967a..872cb0e9b97 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java @@ -22,7 +22,7 @@ import java.util.*; */ public class MutableClassDescriptor extends MutableDeclarationDescriptor implements ClassDescriptor, NamespaceLike { private ConstructorDescriptor primaryConstructor; - private final Set constructors = Sets.newLinkedHashSet(); + private final Set constructors = Sets.newLinkedHashSet(); private final Set callableMembers = Sets.newHashSet(); private final Set properties = Sets.newHashSet(); private final Set functions = Sets.newHashSet(); @@ -224,7 +224,7 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme @NotNull @Override - public Set getConstructors() { + public Set getConstructors() { return constructors; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java index 3973c18854d..f9bedad327d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java @@ -144,12 +144,12 @@ public class CallResolver { DeclarationDescriptor declarationDescriptor = constructedType.getConstructor().getDeclarationDescriptor(); if (declarationDescriptor instanceof ClassDescriptor) { ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor; - Set constructors = classDescriptor.getConstructors(); + Set constructors = classDescriptor.getConstructors(); if (constructors.isEmpty()) { trace.report(NO_CONSTRUCTOR.on(reportAbsenceOn)); return checkArgumentTypesAndFail(trace, scope, call); } - prioritizedTasks.add(new ResolutionTask(TaskPrioritizer.convertWithImpliedThis(scope, Collections.singletonList(NO_RECEIVER), constructors), call, DataFlowInfo.EMPTY)); + prioritizedTasks.add(new ResolutionTask(TaskPrioritizer.convertWithImpliedThis(scope, Collections.singletonList(NO_RECEIVER), constructors), call, DataFlowInfo.EMPTY)); } else { trace.report(NOT_A_CLASS.on(calleeExpression)); @@ -162,12 +162,12 @@ public class CallResolver { assert containingDeclaration instanceof ClassDescriptor; ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration; - Set constructors = classDescriptor.getConstructors(); + Set constructors = classDescriptor.getConstructors(); if (constructors.isEmpty()) { trace.report(NO_CONSTRUCTOR.on(reportAbsenceOn)); return checkArgumentTypesAndFail(trace, scope, call); } - prioritizedTasks = Collections.singletonList(new ResolutionTask(ResolvedCallImpl.convertCollection(constructors), call, DataFlowInfo.EMPTY)); + prioritizedTasks = Collections.singletonList(new ResolutionTask(ResolvedCallImpl.convertCollection(constructors), call, DataFlowInfo.EMPTY)); } else if (calleeExpression != null) { // Here we handle the case where the callee expression must be something of type function, e.g. (foo.bar())(1, 2) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolvedCallImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolvedCallImpl.java index bf95a59a1c1..01813c4d3bd 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolvedCallImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolvedCallImpl.java @@ -43,7 +43,7 @@ public class ResolvedCallImpl implements ResolvedC } @NotNull - public static List> convertCollection(@NotNull Collection descriptors) { + public static List> convertCollection(@NotNull Collection descriptors) { List> result = Lists.newArrayList(); for (D descriptor : descriptors) { result.add(create(descriptor)); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizer.java index 3b02eb27f0e..2edca62eb75 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizer.java @@ -183,7 +183,7 @@ import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor // return result; } - public static Collection> convertWithImpliedThis(JetScope scope, Iterable receiverParameters, Collection descriptors) { + public static Collection> convertWithImpliedThis(JetScope scope, Iterable receiverParameters, Collection descriptors) { Collection> result = Lists.newArrayList(); for (ReceiverDescriptor receiverParameter : receiverParameters) { for (D extension : descriptors) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java index 522a1b0d156..5cfbbc1301f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java @@ -75,8 +75,8 @@ public class ErrorUtils { private static final ClassDescriptorImpl ERROR_CLASS = new ClassDescriptorImpl(ERROR_MODULE, Collections.emptyList(), "") { @NotNull @Override - public Set getConstructors() { - return ERROR_FUNCTION_GROUP; + public Set getConstructors() { + return ERROR_CONSTRUCTOR_GROUP; } @NotNull @@ -87,11 +87,12 @@ public class ErrorUtils { }; private static final Set ERROR_FUNCTION_GROUP = Collections.singleton(createErrorFunction(0, Collections.emptyList())); + private static final Set ERROR_CONSTRUCTOR_GROUP = Collections.singleton(createErrorConstructor(0, Collections.emptyList())); private static final ConstructorDescriptor ERROR_CONSTRUCTOR = new ConstructorDescriptorImpl(ERROR_CLASS, Collections.emptyList(), true); static { ERROR_CLASS.initialize( - true, Collections.emptyList(), Collections.emptyList(), getErrorScope(), ERROR_FUNCTION_GROUP, ERROR_CONSTRUCTOR); + true, Collections.emptyList(), Collections.emptyList(), getErrorScope(), ERROR_CONSTRUCTOR_GROUP, ERROR_CONSTRUCTOR); } private static JetScope getErrorScope() { @@ -135,6 +136,18 @@ public class ErrorUtils { ); } + public static ConstructorDescriptor createErrorConstructor(int typeParameterCount, List positionedValueParameterTypes) { + return new ConstructorDescriptorImpl(ERROR_CLASS, Collections.emptyList(), false).initialize( + null, + ReceiverDescriptor.NO_RECEIVER, + Collections.emptyList(), // TODO + Collections.emptyList(), // TODO + createErrorType(""), + Modality.OPEN, + Visibility.INTERNAL + ); + } + private static final JetType ERROR_PARAMETER_TYPE = createErrorType(""); private static List getValueParameters(FunctionDescriptor functionDescriptor, List argumentTypes) { List result = new ArrayList(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardClasses.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardClasses.java index c84b501bc34..fb299e1c86e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardClasses.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardClasses.java @@ -48,7 +48,7 @@ public class JetStandardClasses { } }, JetScope.EMPTY, - Collections.emptySet(), + Collections.emptySet(), null, null ); @@ -71,7 +71,7 @@ public class JetStandardClasses { Collections.emptyList(), Collections.emptySet(), JetScope.EMPTY, - Collections.emptySet(), + Collections.emptySet(), null, null ); @@ -123,7 +123,7 @@ public class JetStandardClasses { parameters, Collections.singleton(getAnyType()), STUB, - Collections.emptySet(), // TODO + Collections.emptySet(), // TODO null); // TODO : constructor TUPLE_CONSTRUCTORS.add(TUPLE[i].getTypeConstructor()); } @@ -148,7 +148,7 @@ public class JetStandardClasses { FUNCTION[i] = function.initialize( false, createTypeParameters(i, function), - Collections.singleton(getAnyType()), STUB, Collections.emptySet(), null); + Collections.singleton(getAnyType()), STUB, Collections.emptySet(), null); FUNCTION_TYPE_CONSTRUCTORS.add(FUNCTION[i].getTypeConstructor()); ClassDescriptorImpl receiverFunction = new ClassDescriptorImpl( @@ -163,7 +163,7 @@ public class JetStandardClasses { RECEIVER_FUNCTION[i] = receiverFunction.initialize( false, parameters, - Collections.singleton(getAnyType()), STUB, Collections.emptySet(), null); + Collections.singleton(getAnyType()), STUB, Collections.emptySet(), null); RECEIVER_FUNCTION_TYPE_CONSTRUCTORS.add(RECEIVER_FUNCTION[i].getTypeConstructor()); } } diff --git a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java index 39a7dbd9de7..202905b1477 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java @@ -675,7 +675,7 @@ public class JetTypeCheckerTest extends JetLiteFixture { }); } - Set constructors = Sets.newLinkedHashSet(); + Set constructors = Sets.newLinkedHashSet(); classDescriptor.initialize( !open, typeParameters,