JavaCompilerCore/resources/bytecode/javFiles/OverloadPattern.jav

66 lines
1.5 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;
public record Point(Number x, Number y) {}
public class OverloadPattern {
2024-11-19 12:32:55 +00:00
public Number m(Point(Integer x, Integer y), Point(Float a, Float b)) {
2024-11-19 14:19:40 +00:00
return 1;
}
2024-11-19 12:32:55 +00:00
public Number m(Point(Integer x, Integer y), Point(Integer a, Integer b)) {
2024-11-19 14:19:40 +00:00
return 2;
2024-11-19 12:32:55 +00:00
}
public Number m(Point(Float x, Float y), Point(Integer a, Integer b)) {
2024-11-19 14:19:40 +00:00
return 3;
2024-11-19 12:32:55 +00:00
}
public Number m(Point(Float x, Float y), Point(Float a, Float b)) {
2024-11-19 14:19:40 +00:00
return 4;
}
public Number m(Point(Integer x, Integer y)) {
return 5;
}
public Number m(Point(Float x, Float y)) {
return 6;
}
2023-09-01 10:34:43 +00:00
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;
}
}
*/