Skip to content

Commit

Permalink
Quick Fix in Dynamic Dispatch
Browse files Browse the repository at this point in the history
Previously if there was a contract def that only had impls defined such that dynamic dispatch was supported over a subset of args, you'd run into an internal compiler error (NPE). That's fixed.
  • Loading branch information
JasonSteving99 committed Jun 27, 2023
1 parent c786265 commit 75df30e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public void assertExpectedExprTypes(ScopedHeap scopedHeap) throws ClaroTypeExcep
// TODO(steving) Find some way to make this assertion in the CUP parsing phase itself. Once we start
// implementing better error messages with line numbers etc, I get a feeling that
// throwing this manner of error here will make it hard to get line numbers right.
throw new ClaroParserException(
"Unreachable statements following a return/break stmt are not allowed." + curr.getChildren().get(0));
throw new ClaroParserException("Unreachable statements following a return/break stmt are not allowed.");
}

Stmt currStmt = ((Stmt) curr.getChildren().get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,11 @@ private StringBuilder generateDynamicDispatchHelperForContractProcedure(String p
.requiredContextualOutputTypeAssertionTypeParamNames
.contains(this.typeParamNames.get(n))
||
this.contractProceduresSupportingDynamicDispatchOverArgsWhenGenericReturnTypeInferenceRequired
.get(procedureName).values().stream().anyMatch(i -> n == i)) {
Optional.ofNullable(
this.contractProceduresSupportingDynamicDispatchOverArgsWhenGenericReturnTypeInferenceRequired
.get(procedureName))
.map(m -> m.values().stream().anyMatch(i -> n == i))
.orElse(false)) {
return String.format("$%s_vtableKey", this.typeParamNames.get(n));
}
Type onlyConcreteTypeForCurrTypeParam =
Expand Down

0 comments on commit 75df30e

Please sign in to comment.