File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
tests/run/mirror-defaultArgument Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,37 @@ object Test extends App:
21
21
throw IllegalStateException (" There should be no default argument" )
22
22
catch
23
23
case ex : NoSuchElementException => assert(ex.getMessage == " 0" ) // Ok
24
+
25
+
26
+ case class WithCompanion (s : String = " hello" )
27
+ case object WithCompanion // => mirrors must be anonymous
28
+
29
+ val m2 = summon[Mirror .Of [WithCompanion ]]
30
+ assert(m2 ne WithCompanion )
31
+ assert(m2.defaultArgument(0 ) == " hello" )
32
+
33
+
34
+ class Outer (val i : Int ) {
35
+
36
+ case class Inner (x : Int , y : Int = i + 1 )
37
+ case object Inner
38
+
39
+ val m3 = summon[Mirror .Of [Inner ]]
40
+ assert(m3.defaultArgument(1 ) == i + 1 )
41
+
42
+ def localTest (d : Double ): Unit = {
43
+ case class Local (x : Int = i, y : Double = d, z : Double = i + d)
44
+ case object Local
45
+
46
+ val m4 = summon[Mirror .Of [Local ]]
47
+ assert(m4.defaultArgument(0 ) == i)
48
+ assert(m4.defaultArgument(1 ) == d)
49
+ assert(m4.defaultArgument(2 ) == i + d)
50
+ }
51
+
52
+ }
53
+
54
+ val outer = Outer (3 )
55
+ val m5 = summon[Mirror .Of [outer.Inner ]]
56
+ assert(m5.defaultArgument(1 ) == 3 + 1 )
57
+ outer.localTest(9d )
You can’t perform that action at this time.
0 commit comments