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/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 0000000..d3ac8d4 --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,32 @@ +version = "3.5.8" +runner.dialect = scala3 +align.openParenCallSite = true +align.openParenDefnSite = true +assumeStandardLibraryStripMargin = true +continuationIndent.defnSite = 2 +continuationIndent.callSite = 2 +continuationIndent.ctorSite = 2 +danglingParentheses.preset = true +docstrings.style = Asterisk +docstrings.oneline = unfold +indent.main = 2 +maxColumn = 120 +newlines.afterCurlyLambda = preserve +rewrite.rules = [AvoidInfix, SortImports, RedundantParens, SortModifiers] +rewrite.scala3.convertToNewSyntax = true +rewrite.scala3.removeOptionalBraces = yes +rewrite.sortModifiers.order = [ + implicit + final + sealed + abstract + override + private + protected + lazy + open + transparent + inline + infix + opaque +] 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) + } +}