Skip to content

Commit 585d8a0

Browse files
authored
Merge pull request #61 from exoego/factory-inherited
Add test in case the annotated trait extends other trait
2 parents f64ab07 + 6b4bc81 commit 585d8a0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

macros/src/test/scala/net/exoego/scalajs/types/util/FactoryTest.scala

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ class FactoryTest extends AnyFlatSpec with Matchers {
3232
"""@Factory trait X extends scala.scalajs.js.Object {}""" should compile
3333
}
3434

35-
it should "not a compile when applied to a Scala-native trait not ext" in {
35+
it should "not compile when applied to a Scala-native trait not extending js.Object" in {
3636
"""@Factory trait X""" shouldNot compile
3737
"""@Factory trait X {}""" shouldNot compile
38+
"""@Factory trait X extends Seq[Int]""" shouldNot compile
3839
}
3940

4041
"factory method " should "have defined parameter" in {
@@ -73,6 +74,16 @@ class FactoryTest extends AnyFlatSpec with Matchers {
7374
""" val a: Nested = Nested(name = "yay")
7475
| """.stripMargin should compile
7576
}
77+
78+
it should "have inherited members as parameter" in {
79+
""" val a: Inherited = Inherited(own = 42)
80+
| """.stripMargin shouldNot compile
81+
82+
""" val a: Inherited = Inherited(name= "yay", own = 42)
83+
| val x: String = a.name
84+
| val y: Int = a.own
85+
| """.stripMargin should compile
86+
}
7687
}
7788

7889
@Factory
@@ -111,3 +122,8 @@ trait Nested extends js.Object {
111122
object Nested {
112123
type Z = String
113124
}
125+
126+
@Factory
127+
trait Inherited extends TargetScalaNative {
128+
var own: Int
129+
}

0 commit comments

Comments
 (0)