提交 c478899f 编写于 作者: 梦境迷离's avatar 梦境迷离

ready to 0.3.2

上级 849a7c35
...@@ -18,8 +18,8 @@ Learn Scala macro and abstract syntax tree. ...@@ -18,8 +18,8 @@ Learn Scala macro and abstract syntax tree.
# Environment # Environment
- It is compiled in Java 8, 11 - Compile passed in Java 8、11
- It is compiled in Scala 2.11.x ~ 2.13.x - Compile passed in Scala 2.11.12、2.12.14、2.13.6
# Features # Features
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
# 环境 # 环境
- 使用 Java 8, 11 编译通过 - Java 8、11 编译通过
- 使用 Scala 2.11.x ~ 2.13.x 编译通过 - Scala 2.11.12、2.12.14、2.13.6 编译通过
# 功能 # 功能
......
...@@ -57,6 +57,13 @@ class JavaCompatibleTest extends AnyFlatSpec with Matchers { ...@@ -57,6 +57,13 @@ class JavaCompatibleTest extends AnyFlatSpec with Matchers {
| val t = new A() | val t = new A()
| assert(t.a == 0 && t.g == '?') | assert(t.a == 0 && t.g == '?')
|""".stripMargin shouldNot compile |""".stripMargin shouldNot compile
"""
| @JavaCompatible
| class A(val a: Int, val b: Short)
| val t = new A()
| assert(t.a == 0)
|""".stripMargin shouldNot compile
} }
"JavaCompatible4" should "ok" in { "JavaCompatible4" should "ok" in {
...@@ -82,4 +89,24 @@ class JavaCompatibleTest extends AnyFlatSpec with Matchers { ...@@ -82,4 +89,24 @@ class JavaCompatibleTest extends AnyFlatSpec with Matchers {
assert(t.getA == 0) assert(t.getA == 0)
assert(t.getB == 0) assert(t.getB == 0)
} }
"JavaCompatible7" should "ok when exists super" in {
import scala.beans.BeanProperty
class B(@BeanProperty val name: String, @BeanProperty val id: Int)
@JavaCompatible
case class A(a: Int, b: Short, override val name: String, override val id: Int) extends B(name, id)
val t = new A()
assert(t.getA == 0)
assert(t.getB == 0)
}
// Why this code compile failed but test in """ """.stripMargin will pass?
"JavaCompatible8" should "fail when exists super but not use @BeanProperty" in {
"""
| class B(val name: String, val id: Int)
| @JavaCompatible
| case class A(a: Int, b: Short, override val name: String, override val id: Int) extends B(name, id)
| val t = new A()
|""".stripMargin should compile
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册