JavaCompilerCore/resources/bytecode/javFiles/OverloadPattern.jav

50 lines
1.1 KiB
Plaintext
Raw Normal View History

import java.lang.Integer;
2023-09-01 10:34:43 +00:00
import java.lang.Number;
import java.lang.Float;
2023-09-01 10:34:43 +00:00
record Point(Number x, Number y) {}
public class OverloadPattern {
2024-03-14 12:50:56 +00:00
public m(Point(Integer x, Integer y)) {
return x + y;
}
2024-03-14 12:50:56 +00:00
public m(Point(Float x, Float y)) {
2023-09-01 10:34:43 +00:00
return x * y;
}
2024-03-14 12:50:56 +00:00
public m(Integer x) {
return x;
}
2023-09-01 10:34:43 +00:00
}
/*
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;
}
2023-09-01 10:51:06 +00:00
Number m(Point point) {
return switch(point) {
2023-09-01 10:34:43 +00:00
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);
2023-09-01 10:51:06 +00:00
default -> throw new IllegalArgumentException();
2023-09-01 10:34:43 +00:00
}
}
Integer m(Integer x) {
return x;
}
}
*/