Skip to content

Commit

Permalink
Apply the check even for null Type[]
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Jan 26, 2024
1 parent efbe6a0 commit 0542f48
Showing 1 changed file with 28 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,33 +328,34 @@ private Pair<Function, Type> findConversion(Type from) {
}

ApplicationNode findConversionNode(Type[] allTypes) {
if (allTypes != null) {
for (var from : allTypes) {
var convAndType = findConversion(from);

if (convAndType != null) {
if (NodeUtil.findParent(this, ReadArgumentNode.class) instanceof ReadArgumentNode ran) {
CompilerAsserts.neverPartOfCompilation();
var convNode = LiteralNode.build(convAndType.getLeft());
var intoNode = LiteralNode.build(convAndType.getRight());
var valueNode = ran.plainRead();
var args =
new CallArgument[] {
new CallArgument(null, intoNode), new CallArgument(null, valueNode)
};
return ApplicationNode.build(convNode, args, DefaultsExecutionMode.EXECUTE);
} else if (NodeUtil.findParent(this, TypeCheckExpressionNode.class)
instanceof TypeCheckExpressionNode tcen) {
CompilerAsserts.neverPartOfCompilation();
var convNode = LiteralNode.build(convAndType.getLeft());
var intoNode = LiteralNode.build(convAndType.getRight());
var valueNode = tcen.original;
var args =
new CallArgument[] {
new CallArgument(null, intoNode), new CallArgument(null, valueNode)
};
return ApplicationNode.build(convNode, args, DefaultsExecutionMode.EXECUTE);
}
if (allTypes == null) {
allTypes = new Type[] {null};
}
for (var from : allTypes) {
var convAndType = findConversion(from);

if (convAndType != null) {
if (NodeUtil.findParent(this, ReadArgumentNode.class) instanceof ReadArgumentNode ran) {
CompilerAsserts.neverPartOfCompilation();
var convNode = LiteralNode.build(convAndType.getLeft());
var intoNode = LiteralNode.build(convAndType.getRight());
var valueNode = ran.plainRead();
var args =
new CallArgument[] {
new CallArgument(null, intoNode), new CallArgument(null, valueNode)
};
return ApplicationNode.build(convNode, args, DefaultsExecutionMode.EXECUTE);
} else if (NodeUtil.findParent(this, TypeCheckExpressionNode.class)
instanceof TypeCheckExpressionNode tcen) {
CompilerAsserts.neverPartOfCompilation();
var convNode = LiteralNode.build(convAndType.getLeft());
var intoNode = LiteralNode.build(convAndType.getRight());
var valueNode = tcen.original;
var args =
new CallArgument[] {
new CallArgument(null, intoNode), new CallArgument(null, valueNode)
};
return ApplicationNode.build(convNode, args, DefaultsExecutionMode.EXECUTE);
}
}
}
Expand Down

0 comments on commit 0542f48

Please sign in to comment.