JavaCompilerCore/resources/bytecode/javFiles/OverloadPattern.jav
Daniel Holle 170955b333
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 43s
More complex overloading for switch
2024-11-19 15:19:40 +01:00

66 lines
1.5 KiB
Java

import java.lang.Integer;
import java.lang.Number;
import java.lang.Float;
public record Point(Number x, Number y) {}
public class OverloadPattern {
public Number m(Point(Integer x, Integer y), Point(Float a, Float b)) {
return 1;
}
public Number m(Point(Integer x, Integer y), Point(Integer a, Integer b)) {
return 2;
}
public Number m(Point(Float x, Float y), Point(Integer a, Integer b)) {
return 3;
}
public Number m(Point(Float x, Float y), Point(Float a, Float b)) {
return 4;
}
public Number m(Point(Integer x, Integer y)) {
return 5;
}
public Number m(Point(Float x, Float y)) {
return 6;
}
public m(Integer x) {
return x;
}
}
/*
public class OverloadPattern {
Integer m$Point$_$java$lang$Integer$_$java$lang$Integer$_$(Point point) {
var x = point.x();
var y = point.y();
return x + y;
}
Float m$Point$_$java$lang$Float$_$java$lang$Float$_$(Point point) {
var x = point.x();
var y = point.y();
return x * y;
}
Number m(Point point) {
return switch(point) {
case Point(Integer x, Integer y) ->
m$Point$_$java$lang$Integer$_$java$lang$Integer$_$(point);
case Point(Float x, Float y) ->
m$Point$_$java$lang$Float$_$java$lang$Float$_$(point);
default -> throw new IllegalArgumentException();
}
}
Integer m(Integer x) {
return x;
}
}
*/