diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyClassMemberScope.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyClassMemberScope.java index cefa60192f8..9c6262c0ef6 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyClassMemberScope.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyClassMemberScope.java @@ -254,6 +254,12 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope fromSupertypes = Lists.newArrayList(); for (JetType supertype : thisDescriptor.getTypeConstructor().getSupertypes()) { diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/ScriptDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/ScriptDescriptorImpl.java index 222e54128a9..d50cf48e717 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/ScriptDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/ScriptDescriptorImpl.java @@ -77,20 +77,7 @@ public class ScriptDescriptorImpl extends DeclarationDescriptorNonRootImpl imple assert valueParameters != null : "setValueParameters() must be called before this method"; scriptCodeDescriptor.initialize(implicitReceiver, valueParameters, returnType); - PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(classDescriptor, - Annotations.EMPTY, - Modality.FINAL, - Visibilities.PUBLIC, - false, - Name.identifier(LAST_EXPRESSION_VALUE_FIELD_NAME), - CallableMemberDescriptor.Kind.DECLARATION); - propertyDescriptor.setType( - returnType, - Collections.emptyList(), - classDescriptor.getThisAsReceiverParameter(), - ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER); - propertyDescriptor.initialize(null, null); - classScope.addPropertyDescriptor(propertyDescriptor); + classScope.addPropertyDescriptor(createScriptResultProperty(this)); for (PropertyDescriptorImpl property : properties) { classScope.addPropertyDescriptor(property); @@ -101,6 +88,26 @@ public class ScriptDescriptorImpl extends DeclarationDescriptorNonRootImpl imple } } + @NotNull + public static PropertyDescriptor createScriptResultProperty(@NotNull ScriptDescriptor scriptDescriptor) { + PropertyDescriptorImpl propertyDescriptor = PropertyDescriptorImpl.create(scriptDescriptor.getClassDescriptor(), + Annotations.EMPTY, + Modality.FINAL, + Visibilities.PUBLIC, + false, + Name.identifier(LAST_EXPRESSION_VALUE_FIELD_NAME), + CallableMemberDescriptor.Kind.DECLARATION); + JetType returnType = scriptDescriptor.getScriptCodeDescriptor().getReturnType(); + assert returnType != null : "Return type not initialized for " + scriptDescriptor; + propertyDescriptor.setType( + returnType, + Collections.emptyList(), + scriptDescriptor.getThisAsReceiverParameter(), + ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER); + propertyDescriptor.initialize(null, null); + return propertyDescriptor; + } + @Override public int getPriority() { return priority;