Revert "feat: changes in Grammar and Parser so typeless Recs get recognised"
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 6m35s

This reverts commit 7650813bb7.
This commit is contained in:
Ruben 2024-06-06 12:07:32 +02:00
parent 7650813bb7
commit ea217d16d5
4 changed files with 3 additions and 31 deletions

View File

@ -1,17 +0,0 @@
import java.lang.Integer;
import java.lang.Object;
import java.lang.Float;
public record Rec(Integer a, Object b) {}
public class SwitchInfered {
public main(o) {
return switch (o) {
case Rec(a, b) -> a + b;
case Rec(Integer a, Float b) -> a + 10;
case Rec(Integer a, Rec(Integer b, Integer c)) -> a + b + c;
case Integer i -> i;
default -> 0;
};
}
}

View File

@ -658,12 +658,10 @@ primaryPattern
recordPattern
: typeType recordStructurePattern identifier?
//| recordStructurePattern identifier?
;
typePattern
: variableModifier* typeType identifier
| variableModifier* identifier
;
recordStructurePattern
@ -719,10 +717,10 @@ switchLabeledRule
;
switchLabelCase
: CASE NULL_LITERAL (ARROW | COLON) #labeledRuleNull
: CASE expressionList (ARROW | COLON) #labeledRuleExprList
| CASE NULL_LITERAL (ARROW | COLON) #labeledRuleNull
| CASE pattern (ARROW | COLON) #labeledRulePattern
| DEFAULT (ARROW | COLON) #labeledRuleDefault
| CASE expressionList (ARROW | COLON) #labeledRuleExprList
;
// Java20

View File

@ -457,7 +457,7 @@ public class StatementGenerator {
case TPatternContext tPattern:
TypePatternContext typePattern = tPattern.typePattern();
var text = typePattern.identifier().getText();
var type = typePattern.typeType() == null ? TypePlaceholder.fresh(typePattern.getStart()) : TypeGenerator.convert(typePattern.typeType(), reg, generics);
var type = TypeGenerator.convert(typePattern.typeType(), reg, generics);
localVars.put(text, type);
return new FormalParameter(text, type, typePattern.getStart());
case RPatternContext rPattern:

View File

@ -673,15 +673,6 @@ public class TestComplete {
assertEquals(swtch.invoke(instance, "Some string"), 0);
}
@Ignore("Not implemented")
@Test
public void testSwitchInfered() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "SwitchInfered.jav");
var clazz = classFiles.get("SwitchInfered");
var instance = clazz.getDeclaredConstructor().newInstance();
var swtch = clazz.getDeclaredMethod("main", Object.class);
}
@Ignore("Not implemented")
@Test
public void testSwitch2() throws Exception {