JetConstructor renamed to avoid confusion
This commit is contained in:
@@ -562,8 +562,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
@Override
|
||||
protected void generateDeclaration(PropertyCodegen propertyCodegen, JetDeclaration declaration, FunctionCodegen functionCodegen) {
|
||||
if (declaration instanceof JetConstructor) {
|
||||
generateSecondaryConstructor((JetConstructor) declaration);
|
||||
if (declaration instanceof JetSecondaryConstructor) {
|
||||
generateSecondaryConstructor((JetSecondaryConstructor) declaration);
|
||||
}
|
||||
else if (declaration instanceof JetClassObject) {
|
||||
generateClassObject((JetClassObject) declaration);
|
||||
@@ -622,7 +622,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
private void generateSecondaryConstructor(JetConstructor constructor) {
|
||||
private void generateSecondaryConstructor(JetSecondaryConstructor constructor) {
|
||||
ConstructorDescriptor constructorDescriptor = state.getBindingContext().get(BindingContext.CONSTRUCTOR, constructor);
|
||||
if (constructorDescriptor == null) {
|
||||
throw new UnsupportedOperationException("failed to get descriptor for secondary constructor");
|
||||
|
||||
@@ -19,7 +19,7 @@ public interface JetNodeTypes {
|
||||
JetNodeType OBJECT_DECLARATION_NAME = new JetNodeType("OBJECT_DECLARATION_NAME", JetObjectDeclarationName.class);
|
||||
|
||||
JetNodeType CLASS_OBJECT = new JetNodeType("CLASS_OBJECT", JetClassObject.class);
|
||||
JetNodeType CONSTRUCTOR = new JetNodeType("CONSTRUCTOR", JetConstructor.class);
|
||||
JetNodeType CONSTRUCTOR = new JetNodeType("CONSTRUCTOR", JetSecondaryConstructor.class);
|
||||
JetNodeType ENUM_ENTRY = new JetNodeType("ENUM_ENTRY", JetEnumEntry.class);
|
||||
JetNodeType ANONYMOUS_INITIALIZER = new JetNodeType("ANONYMOUS_INITIALIZER", JetClassInitializer.class);
|
||||
|
||||
|
||||
@@ -553,7 +553,7 @@ public class JetControlFlowProcessor {
|
||||
trace.report(RETURN_NOT_ALLOWED.on(expression));
|
||||
error = true;
|
||||
}
|
||||
if (subroutine instanceof JetFunction || subroutine instanceof JetPropertyAccessor || subroutine instanceof JetConstructor) {
|
||||
if (subroutine instanceof JetFunction || subroutine instanceof JetPropertyAccessor || subroutine instanceof JetSecondaryConstructor) {
|
||||
if (returnedExpression == null) {
|
||||
builder.returnNoValue(expression, subroutine);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class JetClass extends JetTypeParameterListOwner implements JetClassOrObj
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<JetConstructor> getSecondaryConstructors() {
|
||||
public List<JetSecondaryConstructor> getSecondaryConstructors() {
|
||||
JetClassBody body = (JetClassBody) findChildByType(JetNodeTypes.CLASS_BODY);
|
||||
if (body == null) return Collections.emptyList();
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ public class JetClassBody extends JetElement {
|
||||
return PsiTreeUtil.getChildrenOfTypeAsList(this, JetDeclaration.class);
|
||||
}
|
||||
|
||||
public List<JetConstructor> getSecondaryConstructors() {
|
||||
return PsiTreeUtil.getChildrenOfTypeAsList(this, JetConstructor.class);
|
||||
public List<JetSecondaryConstructor> getSecondaryConstructors() {
|
||||
return PsiTreeUtil.getChildrenOfTypeAsList(this, JetSecondaryConstructor.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ import java.util.List;
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class JetConstructor extends JetDeclaration implements JetDeclarationWithBody {
|
||||
public JetConstructor(@NotNull ASTNode node) {
|
||||
public class JetSecondaryConstructor extends JetDeclaration implements JetDeclarationWithBody {
|
||||
public JetSecondaryConstructor(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class JetVisitor<R, D> extends PsiElementVisitor {
|
||||
return visitDeclaration(classObject, data);
|
||||
}
|
||||
|
||||
public R visitConstructor(JetConstructor constructor, D data) {
|
||||
public R visitConstructor(JetSecondaryConstructor constructor, D data) {
|
||||
return visitDeclaration(constructor, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class JetVisitorVoid extends PsiElementVisitor {
|
||||
visitDeclaration(classObject);
|
||||
}
|
||||
|
||||
public void visitConstructor(JetConstructor constructor) {
|
||||
public void visitConstructor(JetSecondaryConstructor constructor) {
|
||||
visitDeclaration(constructor);
|
||||
}
|
||||
|
||||
|
||||
@@ -282,8 +282,8 @@ public class BodyResolver {
|
||||
}
|
||||
|
||||
private void resolveSecondaryConstructorBodies() {
|
||||
for (Map.Entry<JetConstructor, ConstructorDescriptor> entry : this.context.getConstructors().entrySet()) {
|
||||
JetConstructor constructor = entry.getKey();
|
||||
for (Map.Entry<JetSecondaryConstructor, ConstructorDescriptor> entry : this.context.getConstructors().entrySet()) {
|
||||
JetSecondaryConstructor constructor = entry.getKey();
|
||||
ConstructorDescriptor descriptor = entry.getValue();
|
||||
|
||||
resolveSecondaryConstructorBody(constructor, descriptor, ((MutableClassDescriptor) descriptor.getContainingDeclaration()).getScopeForMemberResolution());
|
||||
@@ -292,7 +292,7 @@ public class BodyResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private void resolveSecondaryConstructorBody(JetConstructor declaration, final ConstructorDescriptor descriptor, final JetScope declaringScope) {
|
||||
private void resolveSecondaryConstructorBody(JetSecondaryConstructor declaration, final ConstructorDescriptor descriptor, final JetScope declaringScope) {
|
||||
if (!context.completeAnalysisNeeded(declaration)) return;
|
||||
final JetScope functionInnerScope = getInnerScopeForConstructor(descriptor, declaringScope, false);
|
||||
|
||||
|
||||
@@ -731,7 +731,7 @@ public class ClassDescriptorResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ConstructorDescriptorImpl resolveSecondaryConstructorDescriptor(@NotNull JetScope scope, @NotNull ClassDescriptor classDescriptor, @NotNull JetConstructor constructor) {
|
||||
public ConstructorDescriptorImpl resolveSecondaryConstructorDescriptor(@NotNull JetScope scope, @NotNull ClassDescriptor classDescriptor, @NotNull JetSecondaryConstructor constructor) {
|
||||
return createConstructorDescriptor(scope, classDescriptor, false, constructor.getModifierList(), constructor, classDescriptor.getTypeConstructor().getParameters(), constructor.getValueParameters());
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ControlFlowAnalyzer {
|
||||
: functionDescriptor.getReturnType();
|
||||
checkFunction(function, expectedReturnType);
|
||||
}
|
||||
for (JetConstructor constructor : this.context.getConstructors().keySet()) {
|
||||
for (JetSecondaryConstructor constructor : this.context.getConstructors().keySet()) {
|
||||
if (!context.completeAnalysisNeeded(constructor)) continue;
|
||||
checkFunction(constructor, JetStandardClasses.getUnitType());
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DeclarationResolver {
|
||||
MutableClassDescriptor classDescriptor = entry.getValue();
|
||||
|
||||
processPrimaryConstructor(classDescriptor, jetClass);
|
||||
for (JetConstructor jetConstructor : jetClass.getSecondaryConstructors()) {
|
||||
for (JetSecondaryConstructor jetConstructor : jetClass.getSecondaryConstructors()) {
|
||||
processSecondaryConstructor(classDescriptor, jetConstructor);
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class DeclarationResolver {
|
||||
|
||||
resolveFunctionAndPropertyHeaders(jetClass.getDeclarations(), classDescriptor.getScopeForMemberResolution(), classDescriptor);
|
||||
// processPrimaryConstructor(classDescriptor, jetClass);
|
||||
// for (JetConstructor jetConstructor : jetClass.getSecondaryConstructors()) {
|
||||
// for (JetSecondaryConstructor jetConstructor : jetClass.getSecondaryConstructors()) {
|
||||
// processSecondaryConstructor(classDescriptor, jetConstructor);
|
||||
// }
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public class DeclarationResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private void processSecondaryConstructor(MutableClassDescriptor classDescriptor, JetConstructor constructor) {
|
||||
private void processSecondaryConstructor(MutableClassDescriptor classDescriptor, JetSecondaryConstructor constructor) {
|
||||
if (classDescriptor.getKind() == ClassKind.TRAIT) {
|
||||
// context.getTrace().getErrorHandler().genericError(constructor.getNameNode(), "A trait may not have a constructor");
|
||||
context.getTrace().report(CONSTRUCTOR_IN_TRAIT.on(constructor.getNameNode()));
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.Set;
|
||||
private final Map<JetDeclaration, JetScope> declaringScopes = Maps.newHashMap();
|
||||
|
||||
private final Map<JetNamedFunction, FunctionDescriptorImpl> functions = Maps.newLinkedHashMap();
|
||||
private final Map<JetConstructor, ConstructorDescriptor> constructors = Maps.newLinkedHashMap();
|
||||
private final Map<JetSecondaryConstructor, ConstructorDescriptor> constructors = Maps.newLinkedHashMap();
|
||||
private final Map<JetProperty, PropertyDescriptor> properties = Maps.newLinkedHashMap();
|
||||
private final Set<PropertyDescriptor> primaryConstructorParameterProperties = Sets.newHashSet();
|
||||
|
||||
@@ -117,7 +117,7 @@ import java.util.Set;
|
||||
return primaryConstructorParameterProperties;
|
||||
}
|
||||
|
||||
public Map<JetConstructor, ConstructorDescriptor> getConstructors() {
|
||||
public Map<JetSecondaryConstructor, ConstructorDescriptor> getConstructors() {
|
||||
return constructors;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public class JetControlFlowTest extends JetLiteFixture {
|
||||
for (Pseudocode pseudocode : pseudocodes) {
|
||||
JetElement correspondingElement = pseudocode.getCorrespondingElement();
|
||||
String label = "";
|
||||
assert (correspondingElement instanceof JetNamedDeclaration || correspondingElement instanceof JetConstructor || correspondingElement instanceof JetPropertyAccessor) :
|
||||
assert (correspondingElement instanceof JetNamedDeclaration || correspondingElement instanceof JetSecondaryConstructor || correspondingElement instanceof JetPropertyAccessor) :
|
||||
"Unexpected element class is pseudocode: " + correspondingElement.getClass();
|
||||
if (correspondingElement instanceof JetFunctionLiteral) {
|
||||
label = "anonymous_" + i++;
|
||||
@@ -114,7 +114,7 @@ public class JetControlFlowTest extends JetLiteFixture {
|
||||
String propertyName = ((JetProperty) correspondingElement.getParent()).getName();
|
||||
label = (((JetPropertyAccessor) correspondingElement).isGetter() ? "get" : "set") + "_" + propertyName;
|
||||
}
|
||||
else if (correspondingElement instanceof JetConstructor) {
|
||||
else if (correspondingElement instanceof JetSecondaryConstructor) {
|
||||
label = "this";
|
||||
}
|
||||
|
||||
|
||||
@@ -684,7 +684,7 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
constructors,
|
||||
null
|
||||
);
|
||||
for (JetConstructor constructor : classElement.getSecondaryConstructors()) {
|
||||
for (JetSecondaryConstructor constructor : classElement.getSecondaryConstructors()) {
|
||||
ConstructorDescriptorImpl functionDescriptor = classDescriptorResolver.resolveSecondaryConstructorDescriptor(memberDeclarations, classDescriptor, constructor);
|
||||
functionDescriptor.setReturnType(classDescriptor.getDefaultType());
|
||||
constructors.add(functionDescriptor);
|
||||
|
||||
Reference in New Issue
Block a user