Filter out duplicate patterns
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 43s
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 43s
This commit is contained in:
parent
170955b333
commit
ff715a22cf
@ -343,6 +343,8 @@ public class ASTToTargetAST {
|
||||
}
|
||||
|
||||
var cases = new ArrayList<TargetSwitch.Case>();
|
||||
var usedPatterns = new HashSet<TargetPattern>();
|
||||
|
||||
for (var method : methods) {
|
||||
var patternsRec = new ArrayList<>(patterns);
|
||||
|
||||
@ -363,6 +365,10 @@ public class ASTToTargetAST {
|
||||
}
|
||||
}
|
||||
|
||||
var lastPattern = patternsRec.getLast();
|
||||
if (usedPatterns.contains(lastPattern)) continue;
|
||||
usedPatterns.add(lastPattern);
|
||||
|
||||
var candidates = methods.stream().filter(m -> {
|
||||
var j = 0;
|
||||
for (var param : m.signature().parameters()) {
|
||||
@ -377,7 +383,7 @@ public class ASTToTargetAST {
|
||||
|
||||
var caseBody = generatePatternOverloadsRec(offset + 1, expr, params, patternsRec, candidates, classType);
|
||||
var body = new TargetBlock(List.of(caseBody));
|
||||
var case_ = new TargetSwitch.Case(List.of(patternsRec.getLast()), body);
|
||||
var case_ = new TargetSwitch.Case(List.of(lastPattern), body);
|
||||
|
||||
cases.add(case_);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user