From e2fdeeabe2f34b5f2230e16a426ba97311f64f02 Mon Sep 17 00:00:00 2001 From: Ingo Wechsung Date: Sun, 22 Dec 2013 14:02:18 +0100 Subject: [PATCH] fix Issue#61 --- frege/compiler/tc/Methods.fr | 14 +++++++------- tests/comp/I61Java.java | 12 ++++++++++++ tests/comp/Issue61.fr | 21 +++++++++++++++++++++ 3 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 tests/comp/I61Java.java create mode 100644 tests/comp/Issue61.fr diff --git a/frege/compiler/tc/Methods.fr b/frege/compiler/tc/Methods.fr index 382b6fdc..2d05e5ff 100644 --- a/frege/compiler/tc/Methods.fr +++ b/frege/compiler/tc/Methods.fr @@ -52,13 +52,13 @@ derive Show NIKind {-- determine kind of java expression to generate, based on the item information -} -niKind "new" = NINew -niKind #^\W+$# = NIOp -niKind #^\w+$# = NIMethod -niKind #^\.\w+$# = NIMember -niKind #^\(.+\)$# = NICast -niKind #.+\[\]$# = NINewArray -niKind _ = NIStatic +niKind "new" = NINew +niKind ´^\W+$´ = NIOp +niKind ´^[\w\$]+$´ = NIMethod +niKind ´^\.[\w\$]+$´ = NIMember +niKind ´^\(.+\)$´ = NICast +niKind ´.+\[\]$´ = NINewArray +niKind _ = NIStatic {-- Check the sanity of the type of a native method, whose symbol is passed. diff --git a/tests/comp/I61Java.java b/tests/comp/I61Java.java new file mode 100644 index 00000000..70bb014a --- /dev/null +++ b/tests/comp/I61Java.java @@ -0,0 +1,12 @@ +package tests.comp; + +/** + *

Test calss to demonstrate that $ in method names and member names work.

+ * @author ingo + * + */ +final public class I61Java { + final public int mem$1; + final public int $getMem1$() { return mem$1;} + public I61Java(int arg) { mem$1 = arg; } +} diff --git a/tests/comp/Issue61.fr b/tests/comp/Issue61.fr new file mode 100644 index 00000000..5d3fe914 --- /dev/null +++ b/tests/comp/Issue61.fr @@ -0,0 +1,21 @@ +--- 'https://github.com/Frege/frege/issues/61 Issue#61' +{-- + Compiler does not recognize instance methods and members + that have a @$@ sign in their name. +-} +module tests.comp.Issue61 where + + +data Native = pure native tests.comp.I61Java where + pure native new :: Int -> Native + pure native member ".mem$1" :: Native -> Int + pure native method "$getMem1$" :: Native -> Int + +main _ = do + let nat = Native.new 42 + print "Member mem$1 is " + println nat.member + print "Method $getMem1$ returns " + println nat.method + +