Skip to content

Commit

Permalink
Start fixing field instances
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredlll08 committed Jan 31, 2025
1 parent c9d3f59 commit c5e3a2f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ public TypeID getType() {
return type;
}

@Override
public void setType(TypeID type) {
super.setType(type);

if (autoGetter != null)
this.autoGetter.setType(type);
if (autoSetter != null)
this.autoSetter.setType(type);
}

@Override
public Modifiers getModifiers() {
return modifiers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ public void setBody(Statement body) {
this.body = body;

if (type == BasicTypeID.UNDETERMINED) {
body.getReturnType().ifPresent(returnType -> {
this.type = returnType;
this.header = new FunctionHeader(type);
});
body.getReturnType().ifPresent(this::setType);
}
}

public void setType(TypeID type) {
if (type == null) {
throw new NullPointerException();
}
this.type = type;
this.header = new FunctionHeader(type);
}

@Override
public String getCanonicalName() {
return definition.getFullName() + ":get:" + name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public PropertyMember(CodePosition position, HighLevelDefinition definition, Mod
if (type == null)
throw new NullPointerException();

this.type = type;
this.setType(type);
}

public TypeID getType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ public void setBody(Statement body) {
this.body = body;
}

public void setType(TypeID type) {
if (type == null) {
throw new NullPointerException();
}
this.type = type;
this.parameter = new FunctionParameter(type, "$");
this.header = new FunctionHeader(BasicTypeID.VOID, this.parameter);
}

@Override
public String getCanonicalName() {
return definition.getFullName() + ":get:" + name;
Expand Down Expand Up @@ -67,9 +76,7 @@ public <C, R> R accept(C context, MemberVisitorWithContext<C, R> visitor) {
@Override
public void inferFromOverride(MethodInstance overrides) {
if (type == BasicTypeID.UNDETERMINED) {
this.type = overrides.getHeader().getReturnType();
parameter = new FunctionParameter(overrides.getHeader().getReturnType(), "$");
header = new FunctionHeader(BasicTypeID.VOID, parameter);
setType(overrides.getHeader().getReturnType());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#output: Hello World

public class MyClass {
public static var myVariable = "Hello World";
}

println(MyClass.myVariable);

0 comments on commit c5e3a2f

Please sign in to comment.