diff --git a/.gitignore b/.gitignore index 467357b..056e553 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target/ -.bsp/ \ No newline at end of file +.bsp/ +.idea/ diff --git a/src/main/scala/Test.scala b/src/main/scala/Test.scala index 48becd6..09f65ea 100644 --- a/src/main/scala/Test.scala +++ b/src/main/scala/Test.scala @@ -2,6 +2,7 @@ class Test { inline def test(fun: => Any): Any = fun + /* This works as of 3.1.3 */ test { case class Pair[X, Y]( x: X, @@ -9,4 +10,27 @@ class Test { ) } -} \ No newline at end of file + /** + * This does not work as of 3.1.3 + * Self-types are not resolved, this does work though if + * Moveable and Vehicle are removed from the test context + */ + test { + transparent trait Moveable { + def increaseSpeed(ms: Int): Moveable + def decreaseSpeed(ms: Int): Moveable + } + + trait Vehicle { self: Moveable => + def make: String + def model: String + } + + class Car(val make: String, val model: String, val currentSpeed: Int) extends Vehicle with Moveable { + override def increaseSpeed(ms: Int):Car = new Car(make, model, currentSpeed + ms) + override def decreaseSpeed(ms: Int):Car = new Car(make, model, currentSpeed - ms) + } + + val ford:Car = new Car("Ford", "Fiesta", 110).decreaseSpeed(20) + } +}