-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve support for Unicode supplementary characters in identifiers a…
- Loading branch information
Showing
8 changed files
with
146 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
class Identifiers { | ||
|
||
def f(x: Any): Boolean = x match { | ||
case 𐐨XYZ: String => true | ||
case 𐐨 => true | ||
} | ||
def g(x: Any) = x match { | ||
case 𐐨 @ _ => 𐐨 | ||
} | ||
} | ||
class Ops { | ||
def 𝆗 = 42 // was error: illegal character | ||
def op_𝆗 = 42 // was error: illegal character | ||
def 🌀 = 42 | ||
def op_🌀 = 42 | ||
def 🚀 = 42 | ||
def op_🚀 = 42 | ||
def 🜀 = 42 | ||
def op_🜀 = 42 | ||
def 𝓅 = 42 | ||
def op_𝓅 = 42 | ||
} | ||
class Strings { | ||
implicit class Interps(sc: StringContext) { | ||
def 𝓅(parts: Any*) = "done" | ||
} | ||
def 𝓅 = 42 | ||
def interpolated = s"$𝓅" | ||
def e = "a 𝓅 b" | ||
def f = 𝓅"one" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
case class C(n: Int) { | ||
def 𐀀(c: C): C = C(n * c.n) // actually a letter but supplementary 0x10000 | ||
def ☀(c: C): C = C(n * c.n) // just a symbol | ||
def ☀=(c: C): C = C(n * c.n) // just a symbol | ||
def 🌀(c: C): C = C(n * c.n) // cyclone operator is symbol, supplementary | ||
def 🌀=(c: C): C = C(n * c.n) // cyclone operator is symbol, supplementary | ||
def *(c: C): C = C(n * c.n) | ||
def +(c: C): C = C(n + c.n) | ||
} | ||
object Test extends App { | ||
val Sum = 84 | ||
val Product = 1764 | ||
val ProductSum = 1806 | ||
val SumProduct = 3528 | ||
val c, d = C(42) | ||
def assertEquals(expected: Int, actual: C) = assert(expected == actual.n) | ||
assertEquals(Sum, c + d) | ||
assertEquals(Product, c * d) | ||
assertEquals(Product, c ☀ d) | ||
assertEquals(ProductSum, c * d + d) | ||
assertEquals(ProductSum, c ☀ d + d) | ||
assertEquals(SumProduct, c ☀= d + d) // assignment op is low precedence | ||
assertEquals(SumProduct, c 𐀀 d + d) // the first one, letter should be low precedence | ||
assertEquals(ProductSum, c 🌀d + d) // the second one, cyclone should be high precedence | ||
assertEquals(SumProduct, c 🌀= d + d) // assignment op is low precedence | ||
} | ||
|