Skip to content

Commit

Permalink
Merge pull request #177 from ZenCodeLang/feature/refactor-use-invalid…
Browse files Browse the repository at this point in the history
…-check

Fix: Use isInvalid method instead of comparing to INVALID to check for invalidtypes
  • Loading branch information
stanhebben authored Oct 11, 2024
2 parents 81799c9 + 2140993 commit 7e3a6da
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private static <T extends AnyMethod> MatchedCallArguments<T> applyWidening(
.orElse(value);
}).toArray(Expression[]::new);

if (Stream.of(expressions).anyMatch(e -> e.type == BasicTypeID.INVALID)) {
if (Stream.of(expressions).anyMatch(e -> e.type.isInvalid())) {
return new MatchedCallArguments<>(
method,
new CallArguments(CastedExpression.Level.INVALID, expansionTypeArguments, typeArguments, expressions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Compiling(ExpressionCompiler compiler, CodePosition position, CompilingEx
@Override
public Expression eval() {
Expression leftValue = this.left.eval();
if (leftValue.type == BasicTypeID.INVALID)
if (leftValue.type.isInvalid())
return leftValue;

ResolvedType resolved = compiler.resolve(leftValue.type);
Expand All @@ -57,7 +57,7 @@ public Expression eval() {
@Override
public CastedExpression cast(CastedEval cast) {
Expression leftValue = this.left.eval();
if (leftValue.type == BasicTypeID.INVALID)
if (leftValue.type.isInvalid())
return CastedExpression.invalid(leftValue);

ResolvedType resolved = compiler.resolve(leftValue.type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Compiling(ExpressionCompiler compiler, CodePosition position, CompilingEx
@Override
public Expression eval() {
Expression value = this.value.eval();
if (value.type == BasicTypeID.INVALID)
if (value.type.isInvalid())
return value;

ResolvedType resolved = compiler.resolve(value.type);
Expand All @@ -61,7 +61,7 @@ public Expression eval() {
@Override
public CastedExpression cast(CastedEval cast) {
Expression value = this.value.eval();
if (value.type == BasicTypeID.INVALID)
if (value.type.isInvalid())
return CastedExpression.invalid(value);

ResolvedType resolved = compiler.resolve(value.type);
Expand Down Expand Up @@ -115,7 +115,7 @@ public Expression eval() {
@Override
public CastedExpression cast(CastedEval cast) {
Expression instance = this.instance.eval();
if (instance.type == BasicTypeID.INVALID)
if (instance.type.isInvalid())
return CastedExpression.invalid(instance);

return compiler.resolve(instance.type).findOperator(OperatorType.INDEXSET)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public Compiling(ExpressionCompiler compiler, CodePosition position, CompilingEx
@Override
public Expression eval() {
Expression value = this.value.eval();
if (value.type == BasicTypeID.INVALID)
if (value.type.isInvalid())
return value;

ResolvedType resolvedType = compiler.resolve(value.type);
Expand All @@ -52,7 +52,7 @@ public Expression eval() {
@Override
public CastedExpression cast(CastedEval cast) {
Expression value = this.value.eval();
if (value.type == BasicTypeID.INVALID)
if (value.type.isInvalid())
return CastedExpression.invalid(value);

ResolvedType resolvedType = compiler.resolve(value.type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ public Void visitMemoized(MemoizedExpression expression) {
}

private void checkCorrectType(CodePosition position, TypeID expected, TypeID actual) {
if (actual == BasicTypeID.INVALID)
if (actual.isInvalid())
return; // in this case the underlying error will already by reported elsewhere

if (!expected.equals(actual)) {
Expand Down

0 comments on commit 7e3a6da

Please sign in to comment.