Skip to content

Commit e2fdeea

Browse files
committed
fix Issue#61
1 parent 34ac1c4 commit e2fdeea

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

frege/compiler/tc/Methods.fr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ derive Show NIKind
5252
{--
5353
determine kind of java expression to generate, based on the item information
5454
-}
55-
niKind "new" = NINew
56-
niKind #^\W+$# = NIOp
57-
niKind #^\w+$# = NIMethod
58-
niKind #^\.\w+$# = NIMember
59-
niKind #^\(.+\)$# = NICast
60-
niKind #.+\[\]$# = NINewArray
61-
niKind _ = NIStatic
55+
niKind "new" = NINew
56+
niKind ´^\W+$´ = NIOp
57+
niKind ´^[\w\$]+$´ = NIMethod
58+
niKind ´^\.[\w\$]+$´ = NIMember
59+
niKind ´^\(.+\)$´ = NICast
60+
niKind ´.+\[\]$´ = NINewArray
61+
niKind _ = NIStatic
6262

6363
{--
6464
Check the sanity of the type of a native method, whose symbol is passed.

tests/comp/I61Java.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package tests.comp;
2+
3+
/**
4+
* <p>Test calss to demonstrate that $ in method names and member names work.</p>
5+
* @author ingo
6+
*
7+
*/
8+
final public class I61Java {
9+
final public int mem$1;
10+
final public int $getMem1$() { return mem$1;}
11+
public I61Java(int arg) { mem$1 = arg; }
12+
}

tests/comp/Issue61.fr

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--- 'https://github.com/Frege/frege/issues/61 Issue#61'
2+
{--
3+
Compiler does not recognize instance methods and members
4+
that have a @$@ sign in their name.
5+
-}
6+
module tests.comp.Issue61 where
7+
8+
9+
data Native = pure native tests.comp.I61Java where
10+
pure native new :: Int -> Native
11+
pure native member ".mem$1" :: Native -> Int
12+
pure native method "$getMem1$" :: Native -> Int
13+
14+
main _ = do
15+
let nat = Native.new 42
16+
print "Member mem$1 is "
17+
println nat.member
18+
print "Method $getMem1$ returns "
19+
println nat.method
20+
21+

0 commit comments

Comments
 (0)