forked from JavaTX/JavaCompilerCore
50 lines
1.1 KiB
Java
50 lines
1.1 KiB
Java
import java.lang.Integer;
|
|
import java.lang.Number;
|
|
import java.lang.Float;
|
|
|
|
record Point(Number x, Number y) {}
|
|
|
|
public class OverloadPattern {
|
|
public m(Point(Integer x, Integer y)) {
|
|
return x + y;
|
|
}
|
|
|
|
public m(Point(Float x, Float y)) {
|
|
return x * y;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
*/ |