From fb7b51a971ef4e6def739433e1cd37f37b89d43f Mon Sep 17 00:00:00 2001 From: Vic Nightfall Date: Fri, 1 Sep 2023 12:34:43 +0200 Subject: [PATCH] Point out what the goal translation is --- .../bytecode/javFiles/OverloadPattern.jav | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/resources/bytecode/javFiles/OverloadPattern.jav b/resources/bytecode/javFiles/OverloadPattern.jav index e6025de7..fced10aa 100644 --- a/resources/bytecode/javFiles/OverloadPattern.jav +++ b/resources/bytecode/javFiles/OverloadPattern.jav @@ -1,13 +1,49 @@ import java.lang.Integer; +import java.lang.Number; +import java.lang.Float; -record Point(Integer x, Integer y) {} +record Point(Number x, Number y) {} public class OverloadPattern { m(Point(Integer x, Integer y)) { return x + y; } + m(Point(Float x, Float y)) { + return x * y; + } + m(Integer x) { return x; } -} \ No newline at end of file +} + +/* +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; + } + + Object m(Point point) { + 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); + } + } + + Integer m(Integer x) { + return x; + } +} + +*/ \ No newline at end of file