summaryrefslogtreecommitdiff
path: root/test/files/presentation
diff options
context:
space:
mode:
authorMirco Dotta <mirco.dotta@typesafe.com>2013-12-02 14:57:53 +0100
committerMirco Dotta <mirco.dotta@typesafe.com>2013-12-12 17:20:36 +0100
commitbdb0ac0fe55260d5ee5e14a963b73bf7d9166430 (patch)
tree5e2cdab713ffeb29b7c5703694d89717170ca7b9 /test/files/presentation
parent7f4720c5dbd0711983e1abb8be3781e7d53b049b (diff)
downloadscala-bdb0ac0fe55260d5ee5e14a963b73bf7d9166430.tar.gz
scala-bdb0ac0fe55260d5ee5e14a963b73bf7d9166430.tar.bz2
scala-bdb0ac0fe55260d5ee5e14a963b73bf7d9166430.zip
SI-4827 Test to demonstrate wrong position of constructor default arg
As demonstrated by the attached test, hyperlinking on constructor's default arg doesn't work (the returned tree is the parameter tree, i.e., `f`, which is of course wrong). Printing the tree reveals the issue: `` [[syntax trees at end of typer]] // Foo.scala [0:63]package [0:0]<empty> { [0:37]class Baz extends [9:37][39]scala.AnyRef { [10:31]<paramaccessor> private[this] val f: [14]Int = _; [14]<stable> <accessor> <paramaccessor> def f: [14]Int = [14][14]Baz.this.f; [39]def <init>([14]f: [17]<type: [17]scala.Int> = [30]B.a): [9]Baz = [39]{ [39][39][39]Baz.super.<init>(); [9]() } }; [6]<synthetic> object Baz extends [6][6]AnyRef { [6]def <init>(): [9]Baz.type = [6]{ [6][6][6]Baz.super.<init>(); [9]() }; [14]<synthetic> def <init>$default$1: [14]Int = [30]B.a }; [39:63]object B extends [48:63][63]scala.AnyRef { [63]def <init>(): [48]B.type = [63]{ [63][63][63]B.super.<init>(); [48]() }; [52:61]private[this] val a: [56]Int = [60:61]2; [56]<stable> <accessor> def a: [56]Int = [56][56]B.this.a } } `` In short, the default argument in `<init>` (the constructor) has an offset position, while we would expect it to have a range position. Therefore, when locating a tree for any position between (start=) 10 and (end=) 31, the paramaccessor tree `f` is returned. The next commit will correct the problem.
Diffstat (limited to 'test/files/presentation')
-rw-r--r--test/files/presentation/t4287.check11
-rw-r--r--test/files/presentation/t4287/Test.scala3
-rw-r--r--test/files/presentation/t4287/src/Foo.scala5
3 files changed, 19 insertions, 0 deletions
diff --git a/test/files/presentation/t4287.check b/test/files/presentation/t4287.check
new file mode 100644
index 0000000000..80c3e2fb23
--- /dev/null
+++ b/test/files/presentation/t4287.check
@@ -0,0 +1,11 @@
+reload: Foo.scala
+
+askHyperlinkPos for `f ` at (1,24) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `f ` at (1,15) Foo.scala
+================================================================================
+
+askHyperlinkPos for `f ` at (1,31) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `f ` at (1,15) Foo.scala
+================================================================================
diff --git a/test/files/presentation/t4287/Test.scala b/test/files/presentation/t4287/Test.scala
new file mode 100644
index 0000000000..bec1131c4c
--- /dev/null
+++ b/test/files/presentation/t4287/Test.scala
@@ -0,0 +1,3 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+
+object Test extends InteractiveTest \ No newline at end of file
diff --git a/test/files/presentation/t4287/src/Foo.scala b/test/files/presentation/t4287/src/Foo.scala
new file mode 100644
index 0000000000..a744eaabe2
--- /dev/null
+++ b/test/files/presentation/t4287/src/Foo.scala
@@ -0,0 +1,5 @@
+class Baz(val f: Int = B/*#*/.a/*#*/)
+
+object B {
+ val a = 2
+}