Skip to content

Commit 80f4cf0

Browse files
committed
Fix extendsOrImplements casts not working
1 parent a543505 commit 80f4cf0

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

CodeModel/src/main/java/org/openzen/zenscript/codemodel/compilation/CastedEval.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public CastedExpression of(Expression value) {
8383
return result;
8484
}
8585

86-
//if (extendsOrImplements(type))
87-
// return CastedExpression.implicit(new SupertypeCastExpression(position, value, type));
86+
if (this.type.extendsOrImplements(value.type, compiler.getAvailableExpansions()))
87+
return CastedExpression.implicit(new SupertypeCastExpression(position, value, type));
8888

8989
if (explicit) {
9090
Optional<Expression> casted = compiler.resolve(value.type).tryCastExplicit(type, compiler, position, value, optional);

JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,7 @@ private FunctionCastWrapperClass generateFunctionCastWrapperClass(CodePosition p
12061206
@Override
12071207
public Void visitSupertypeCast(SupertypeCastExpression expression) {
12081208
expression.value.accept(this);
1209+
javaWriter.checkCast(context.getType(expression.type));
12091210
return null; // nothing to do
12101211
}
12111212

0 commit comments

Comments
 (0)