aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-09-06 13:20:39 +0200
committerMartin Odersky <odersky@gmail.com>2016-10-02 16:11:21 +0200
commit19ab7ab10fabe7113f45063ffd2b6cc6abcc3329 (patch)
tree3672315832460f5d636074fc2c387d243597cff5 /tests
parentbd0660ef100ee1a41bd56267d9e95c9e6dd74d5e (diff)
downloaddotty-19ab7ab10fabe7113f45063ffd2b6cc6abcc3329.tar.gz
dotty-19ab7ab10fabe7113f45063ffd2b6cc6abcc3329.tar.bz2
dotty-19ab7ab10fabe7113f45063ffd2b6cc6abcc3329.zip
Make inline annotation @scala.inline.
Drop @dotty.annotation.inline. This will inline all @inline marked methods in Scala for which a body is known (i.e. that are either compiled in the same run or have Tasty trees available). Option -Yno-inline suppresses inlining. This is needed for the moment because some @inline methods access private members or members that are otherwise inaccessible at the call-site. Also fixes some problems in Inliner - make sure type arguments to inline calls re fully defined - don't forget recursive calls in typeMap - don't forget positions in treeMap - drop dead code dealing with outer.
Diffstat (limited to 'tests')
-rw-r--r--tests/neg/inlineAccess.scala15
-rw-r--r--tests/neg/inlineAccess/C_1.scala2
-rw-r--r--tests/neg/power.scala2
-rw-r--r--tests/run/inline/inlines_1.scala10
-rw-r--r--tests/run/inlinePower/power_1.scala2
-rw-r--r--tests/run/inlinedAssign.scala6
6 files changed, 11 insertions, 26 deletions
diff --git a/tests/neg/inlineAccess.scala b/tests/neg/inlineAccess.scala
deleted file mode 100644
index cfb1cc06f..000000000
--- a/tests/neg/inlineAccess.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-package p {
-class C {
- protected def f(): Unit = ()
-
- @dotty.annotation.inline
- def inl() = f() // error (when inlined): not accessible
-}
-}
-
-object Test {
- def main(args: Array[String]) = {
- val c = new p.C()
- c.inl()
- }
-}
diff --git a/tests/neg/inlineAccess/C_1.scala b/tests/neg/inlineAccess/C_1.scala
index fc24f7666..6db1ea787 100644
--- a/tests/neg/inlineAccess/C_1.scala
+++ b/tests/neg/inlineAccess/C_1.scala
@@ -2,7 +2,7 @@ package p {
class C {
protected def f(): Unit = ()
- @dotty.annotation.inline
+ @inline
def inl() = f() // error (when inlined): not accessible
}
}
diff --git a/tests/neg/power.scala b/tests/neg/power.scala
index 7439d8699..6230b4e51 100644
--- a/tests/neg/power.scala
+++ b/tests/neg/power.scala
@@ -1,6 +1,6 @@
object Test {
- @dotty.annotation.inline
+ @inline
def power(x: Double, n: Int): Double =
if (n == 0) 1.0
else if (n == 1) x
diff --git a/tests/run/inline/inlines_1.scala b/tests/run/inline/inlines_1.scala
index 36f5ac402..8189e6805 100644
--- a/tests/run/inline/inlines_1.scala
+++ b/tests/run/inline/inlines_1.scala
@@ -5,7 +5,7 @@ object inlines {
final val monitored = false
- @dotty.annotation.inline
+ @inline
def f(x: Int): Int = x * x
val hits = new mutable.HashMap[String, Int] {
@@ -21,7 +21,7 @@ object inlines {
@volatile private var stack: List[String] = Nil
- @dotty.annotation.inline
+ @inline
def track[T](fn: String)(op: => T) =
if (monitored) {
stack = fn :: stack
@@ -34,9 +34,9 @@ object inlines {
def f = "Outer.f"
class Inner {
val msg = " Inner"
- @dotty.annotation.inline def m = msg
- @dotty.annotation.inline def g = f
- @dotty.annotation.inline def h = f ++ m
+ @inline def m = msg
+ @inline def g = f
+ @inline def h = f ++ m
}
val inner = new Inner
}
diff --git a/tests/run/inlinePower/power_1.scala b/tests/run/inlinePower/power_1.scala
index 1faa10516..23da6009a 100644
--- a/tests/run/inlinePower/power_1.scala
+++ b/tests/run/inlinePower/power_1.scala
@@ -2,7 +2,7 @@ package p
object pow {
- @dotty.annotation.inline
+ @inline
def power(x: Double, n: Int): Double =
if (n == 0) 1.0
else if (n == 1) x
diff --git a/tests/run/inlinedAssign.scala b/tests/run/inlinedAssign.scala
index 735158209..b9a5d287d 100644
--- a/tests/run/inlinedAssign.scala
+++ b/tests/run/inlinedAssign.scala
@@ -1,6 +1,6 @@
object Test {
- @dotty.annotation.inline
+ @inline
def swap[T](x: T, x_= : T => Unit, y: T, y_= : T => Unit) = {
val t = x
x_=(y)
@@ -10,8 +10,8 @@ object Test {
def main(args: Array[String]) = {
var x = 1
var y = 2
- @dotty.annotation.inline def setX(z: Int) = x = z
- @dotty.annotation.inline def setY(z: Int) = y = z
+ @inline def setX(z: Int) = x = z
+ @inline def setY(z: Int) = y = z
swap[Int](x, setX, y, setY)
assert(x == 2 && y == 1)
}