summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/reflect/scala/reflect/internal/util/Position.scala5
-rw-r--r--test/files/neg/parser-errors.check16
-rw-r--r--test/files/neg/parser-errors.scala5
-rw-r--r--test/files/neg/t7473.check12
-rw-r--r--test/files/neg/t7473.scala4
-rw-r--r--test/files/run/existential-rangepos.check6
-rw-r--r--test/files/run/t5064.check8
-rw-r--r--test/files/run/t5385.check16
-rw-r--r--test/files/run/t5603.check22
-rw-r--r--test/files/run/t6288.check6
-rw-r--r--test/files/run/t6768.check12
-rw-r--r--test/files/run/t6768.scala12
-rw-r--r--test/files/run/t7271.check2
13 files changed, 90 insertions, 36 deletions
diff --git a/src/reflect/scala/reflect/internal/util/Position.scala b/src/reflect/scala/reflect/internal/util/Position.scala
index 8e7df28167..d62ab40a9d 100644
--- a/src/reflect/scala/reflect/internal/util/Position.scala
+++ b/src/reflect/scala/reflect/internal/util/Position.scala
@@ -197,10 +197,11 @@ private[util] trait InternalPositionImpl {
}
def showDebug: String = toString
def show = (
- if (isOpaqueRange) s"[$start:$end]"
+ if (isOpaqueRange && start != point) s"[$point/$start:$end]"
+ else if (isOpaqueRange) s"[$start:$end]"
else if (isTransparent) s"<$start:$end>"
else if (isDefined) s"[$point]"
- else "[NoPosition]"
+ else "[X]"
)
private def asOffset(point: Int): Position = Position.offset(source, point)
diff --git a/test/files/neg/parser-errors.check b/test/files/neg/parser-errors.check
new file mode 100644
index 0000000000..ab13ee0921
--- /dev/null
+++ b/test/files/neg/parser-errors.check
@@ -0,0 +1,16 @@
+parser-errors.scala:1: error: lazy values may not be abstract
+abstract class A1 { lazy val foo: Int }
+ ^
+parser-errors.scala:2: error: '=' expected but '}' found.
+abstract class A2 { val Some(x) }
+ ^
+parser-errors.scala:3: error: unbound placeholder parameter
+abstract class A3 { var x = _ }
+ ^
+parser-errors.scala:4: error: unbound placeholder parameter
+abstract class A4 { val x: Int = _ }
+ ^
+parser-errors.scala:5: error: unbound placeholder parameter
+abstract class A5 { var Some(x) = _ }
+ ^
+5 errors found
diff --git a/test/files/neg/parser-errors.scala b/test/files/neg/parser-errors.scala
new file mode 100644
index 0000000000..1bf121f68f
--- /dev/null
+++ b/test/files/neg/parser-errors.scala
@@ -0,0 +1,5 @@
+abstract class A1 { lazy val foo: Int }
+abstract class A2 { val Some(x) }
+abstract class A3 { var x = _ }
+abstract class A4 { val x: Int = _ }
+abstract class A5 { var Some(x) = _ } \ No newline at end of file
diff --git a/test/files/neg/t7473.check b/test/files/neg/t7473.check
index bc8c29d463..488baef94e 100644
--- a/test/files/neg/t7473.check
+++ b/test/files/neg/t7473.check
@@ -1,7 +1,13 @@
-t7473.scala:6: error: '<-' expected but '=' found.
+t7473.scala:5: error: '<-' expected but '=' found.
+ for (x = Option(i); if x == j) yield 42 //t7473.scala:4: error: '<-' expected but '=' found.
+ ^
+t7473.scala:5: error: illegal start of simple expression
+ for (x = Option(i); if x == j) yield 42 //t7473.scala:4: error: '<-' expected but '=' found.
+ ^
+t7473.scala:8: error: '<-' expected but '=' found.
(for (x = Option(i); if x == j) yield 42) toList
^
-t7473.scala:6: error: illegal start of simple expression
+t7473.scala:8: error: illegal start of simple expression
(for (x = Option(i); if x == j) yield 42) toList
^
-two errors found
+four errors found
diff --git a/test/files/neg/t7473.scala b/test/files/neg/t7473.scala
index 593231d5f2..1eb9e6cb7a 100644
--- a/test/files/neg/t7473.scala
+++ b/test/files/neg/t7473.scala
@@ -1,7 +1,9 @@
object Foo {
val i,j = 3
- //for (x = Option(i); if x == j) yield 42 //t7473.scala:4: error: '<-' expected but '=' found.
+
+ for (x = Option(i); if x == j) yield 42 //t7473.scala:4: error: '<-' expected but '=' found.
+
// evil postfix!
(for (x = Option(i); if x == j) yield 42) toList
}
diff --git a/test/files/run/existential-rangepos.check b/test/files/run/existential-rangepos.check
index 1212b60bae..6c4e86dedc 100644
--- a/test/files/run/existential-rangepos.check
+++ b/test/files/run/existential-rangepos.check
@@ -1,13 +1,13 @@
[[syntax trees at end of patmat]] // newSource1.scala
[0:76]package [0:0]<empty> {
- [0:76]abstract class A[[17:18]T[17:18]] extends [20:76][76]scala.AnyRef {
+ [15/0:76]abstract class A[[17:18]T[17:18]] extends [20:76][76]scala.AnyRef {
[76]def <init>(): [20]A[T] = [76]{
[76][76][76]A.super.<init>();
[20]()
};
- [24:51]private[this] val foo: [28]Set[_ <: T] = [47:51]null;
+ [28/24:51]private[this] val foo: [28]Set[_ <: T] = [47:51]null;
[28]<stable> <accessor> def foo: [28]Set[_ <: T] = [28][28]A.this.foo;
- [54:74]<stable> <accessor> def bar: [58]Set[_ <: T]
+ [58/54:74]<stable> <accessor> def bar: [58]Set[_ <: T]
}
}
diff --git a/test/files/run/t5064.check b/test/files/run/t5064.check
index 61ccfd16e7..7b92e40c35 100644
--- a/test/files/run/t5064.check
+++ b/test/files/run/t5064.check
@@ -1,19 +1,19 @@
[53] T5064.super.<init>()
[53] T5064.super.<init>
[53] this
-[16:23] immutable.this.List.apply(scala.this.Predef.wrapIntArray(Array[Int]{1}))
+[20/16:23] immutable.this.List.apply(scala.this.Predef.wrapIntArray(Array[Int]{1}))
[16:20] immutable.this.List.apply
<16:20> immutable.this.List
<16:20> immutable.this
-[16:23] scala.this.Predef.wrapIntArray(Array[Int]{1})
+[20/16:23] scala.this.Predef.wrapIntArray(Array[Int]{1})
[20] scala.this.Predef.wrapIntArray
[20] scala.this.Predef
[20] scala.this
-[26:32] collection.this.Seq.apply(scala.this.Predef.wrapIntArray(Array[Int]{1}))
+[29/26:32] collection.this.Seq.apply(scala.this.Predef.wrapIntArray(Array[Int]{1}))
[26:29] collection.this.Seq.apply
<26:29> collection.this.Seq
<26:29> collection.this
-[26:32] scala.this.Predef.wrapIntArray(Array[Int]{1})
+[29/26:32] scala.this.Predef.wrapIntArray(Array[Int]{1})
[29] scala.this.Predef.wrapIntArray
[29] scala.this.Predef
[29] scala.this
diff --git a/test/files/run/t5385.check b/test/files/run/t5385.check
index 1df74fcfb5..f56464facd 100644
--- a/test/files/run/t5385.check
+++ b/test/files/run/t5385.check
@@ -1,8 +1,8 @@
-[0:9] class Azz
-[0:9] class Bzz
-[0:9] class Czz
-[0:9] class Dzz
-[0:11] class Ezz
-[0:11] class Fzz
-[0:13] class Gzz
-[0:13] class Hzz
+[6/0:9] class Azz
+[6/0:9] class Bzz
+[6/0:9] class Czz
+[6/0:9] class Dzz
+[6/0:11] class Ezz
+[6/0:11] class Fzz
+[6/0:13] class Gzz
+[6/0:13] class Hzz
diff --git a/test/files/run/t5603.check b/test/files/run/t5603.check
index 188f39ff82..255e9356b9 100644
--- a/test/files/run/t5603.check
+++ b/test/files/run/t5603.check
@@ -1,29 +1,29 @@
[[syntax trees at end of parser]] // newSource1.scala
[0:241]package [0:0]<empty> {
- [0:82]abstract trait Greeting extends [15:82][83]scala.AnyRef {
+ [6/0:82]abstract trait Greeting extends [15:82][83]scala.AnyRef {
[15]def $init$() = [15]{
[15]()
};
- [23:39]val name: [33:39]String;
- [46:76]val msg = [56:76][56:72][56:71]"How are you, ".$plus([72:76]name)
+ [27/23:39]val name: [33:39]String;
+ [50/46:76]val msg = [71/56:76][71/56:72][56:71]"How are you, ".$plus([72:76]name)
};
- [87:209]class C extends [94:209][151:159]Greeting {
- [119:139]val nameElse = _;
+ [93/87:209]class C extends [94:209][151:159]Greeting {
+ [123/119:139]val nameElse = _;
[95:101]<paramaccessor> private[this] val i: [98:101]Int = _;
<119:139>def <init>([95]i: [98]Int) = <119:139>{
<119:139>val nameElse = <134:139>"Bob";
- [NoPosition][NoPosition][NoPosition]super.<init>();
+ [X][X][X]super.<init>();
[94]()
};
- [168:184]val name = [179:184]"avc";
- [191:203][191:198]println([199:202]msg)
+ [172/168:184]val name = [179:184]"avc";
+ [198/191:203][191:198]println([199:202]msg)
};
- [215:241]object Test extends [227:241][235:238]App {
+ [222/215:241]object Test extends [227:241][235:238]App {
[227]def <init>() = [227]{
- [NoPosition][NoPosition][NoPosition]super.<init>();
+ [X][X][X]super.<init>();
[227]()
};
- [NoPosition]<empty>
+ [X]<empty>
}
}
diff --git a/test/files/run/t6288.check b/test/files/run/t6288.check
index a032a10de6..0da03c0439 100644
--- a/test/files/run/t6288.check
+++ b/test/files/run/t6288.check
@@ -18,7 +18,7 @@
[64]case6(){
[64][64]matchEnd4([64]throw [64][64][64]new [64]MatchError([64]x1))
};
- [64]matchEnd4(x: [NoPosition]Unit){
+ [64]matchEnd4(x: [X]Unit){
[64]x
}
}
@@ -44,7 +44,7 @@
[175]case6(){
[175][175]matchEnd4([175]throw [175][175][175]new [175]MatchError([175]x1))
};
- [175]matchEnd4(x: [NoPosition]Unit){
+ [175]matchEnd4(x: [X]Unit){
[175]x
}
}
@@ -70,7 +70,7 @@
[273]case6(){
[273][273]matchEnd4([273]throw [273][273][273]new [273]MatchError([273]x1))
};
- [273]matchEnd4(x: [NoPosition]Unit){
+ [273]matchEnd4(x: [X]Unit){
[273]x
}
}
diff --git a/test/files/run/t6768.check b/test/files/run/t6768.check
new file mode 100644
index 0000000000..bf4f6ea2a1
--- /dev/null
+++ b/test/files/run/t6768.check
@@ -0,0 +1,12 @@
+[[syntax trees at end of typer]] // newSource1.scala
+[1:58]package [1:1]<empty> {
+ [7/1:58]class A extends [9:58][58]scala.AnyRef {
+ [58]def <init>(): [9]A = [58]{
+ [58][58][58]A.super.<init>();
+ [9]()
+ };
+ [17/13:31]def f1: [17]Some[String] = [26/22:31][22:26][22:26]scala.Some.apply[[22]String]([27:30]"a");
+ [38/34:56]def f2: [38]Some[String] = [43:56][43/47:51][43/47:51]new [47:51]<type: [47:51]scala.Some>([52:55]"b")
+ }
+}
+
diff --git a/test/files/run/t6768.scala b/test/files/run/t6768.scala
new file mode 100644
index 0000000000..11470a0ef8
--- /dev/null
+++ b/test/files/run/t6768.scala
@@ -0,0 +1,12 @@
+import scala.tools.partest._
+
+object Test extends DirectTest {
+ override def extraSettings: String = "-usejavacp -Xprint:typer -Yrangepos -Xprint-pos -d " + testOutput.path
+ override def show() = Console.withErr(System.out)(compile())
+
+ override def code = """
+class A {
+ def f1 = Some("a")
+ def f2 = new Some("b")
+}"""
+}
diff --git a/test/files/run/t7271.check b/test/files/run/t7271.check
index f7a23018ca..86b5230fd7 100644
--- a/test/files/run/t7271.check
+++ b/test/files/run/t7271.check
@@ -2,7 +2,7 @@
[6]package [6]<empty> {
[6]class C extends [8][91]scala.AnyRef {
[8]def <init>() = [8]{
- [NoPosition][NoPosition][NoPosition]super.<init>();
+ [X][X][X]super.<init>();
[8]()
};
[20]def quote = [28][28][28][28]StringContext([30]"foo", [40]"baz").s([35]this);