File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ package twitter ;
2
+
3
+ public class CompileTest {
4
+
5
+ public static void main (String [] args ) {
6
+ Duration durMilliseconds = Duration .fromMilliseconds (1000 );
7
+ Duration durSeconds = Duration .fromSeconds (1 );
8
+ }
9
+ }
Original file line number Diff line number Diff line change
1
+ package twitter
2
+
3
+ trait TimeLike [This <: TimeLike [This ]]
4
+
5
+ trait TimeLikeOps [This <: TimeLike [This ]] {
6
+ def fromMilliseconds (milliseconds : Long ): This
7
+
8
+ def fromSeconds (seconds : Long ): This = fromMilliseconds(seconds * 1000L )
9
+ }
10
+
11
+ sealed class Duration (val milliseconds : Long ) extends TimeLike [Duration ]
12
+ object Duration extends TimeLikeOps [Duration ] {
13
+ def fromMilliseconds (milliseconds : Long ): Duration = new Duration (milliseconds)
14
+
15
+ override def fromSeconds (seconds : Long ): Duration = super .fromSeconds(seconds)
16
+ }
You can’t perform that action at this time.
0 commit comments