diff options
author | ghik <romeqjanoosh@gmail.com> | 2014-09-17 20:45:01 +0200 |
---|---|---|
committer | ghik <romeqjanoosh@gmail.com> | 2014-09-17 20:45:01 +0200 |
commit | 7c81959d724a6565c00b86591d54c195d8bed1de (patch) | |
tree | 42ad6d8ddfcb0a06111bbb6feb2438a5e5791e3b /test/files/presentation | |
parent | 190c6726158f3f7e1ac5d26782437c184cee5872 (diff) | |
download | scala-7c81959d724a6565c00b86591d54c195d8bed1de.tar.gz scala-7c81959d724a6565c00b86591d54c195d8bed1de.tar.bz2 scala-7c81959d724a6565c00b86591d54c195d8bed1de.zip |
SI-8459 fix incorrect positions for incomplete selection trees
The mentioned issue is a presentation compiler issue, but its root cause is a bug in the parser which incorrectly assigned positions to incomplete selection trees (i.e. selections that lack an indentifier after dot and have some whitespace instead).
In detail: for such incomplete selection trees, the "point" of the position should be immediately after the dot but instead was at the start of next token after the dot. For range positions, this caused a pathological situation where the "point" was greater than the "end" of the position. This position is later used by the typechecker during resolution of dynamic calls and causes it to crash. Of course, because a syntactically incorrect code is required for the bug to manifest, it only happens in the presentation compiler.
Diffstat (limited to 'test/files/presentation')
-rw-r--r-- | test/files/presentation/t8459.check | 14 | ||||
-rw-r--r-- | test/files/presentation/t8459/Test.scala | 3 | ||||
-rw-r--r-- | test/files/presentation/t8459/src/IncompleteDynamicSelect.scala | 14 |
3 files changed, 31 insertions, 0 deletions
diff --git a/test/files/presentation/t8459.check b/test/files/presentation/t8459.check new file mode 100644 index 0000000000..336c147141 --- /dev/null +++ b/test/files/presentation/t8459.check @@ -0,0 +1,14 @@ +reload: IncompleteDynamicSelect.scala + +askType at IncompleteDynamicSelect.scala(12,2) +================================================================================ +[response] askTypeAt (12,2) +scala.AnyRef { + def <init>(): Foo = { + Foo.super.<init>(); + () + }; + private[this] val bar: F = new F(); + Foo.this.bar.<selectDynamic: error>("<error>") +} +================================================================================ diff --git a/test/files/presentation/t8459/Test.scala b/test/files/presentation/t8459/Test.scala new file mode 100644 index 0000000000..bec1131c4c --- /dev/null +++ b/test/files/presentation/t8459/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/t8459/src/IncompleteDynamicSelect.scala b/test/files/presentation/t8459/src/IncompleteDynamicSelect.scala new file mode 100644 index 0000000000..61976fe2f9 --- /dev/null +++ b/test/files/presentation/t8459/src/IncompleteDynamicSelect.scala @@ -0,0 +1,14 @@ +import scala.language.dynamics + +class F extends Dynamic { + def applyDynamic(name: String)(args: Any*) = + s"method '$name' called with arguments ${args.mkString("'", "', '", "'")}" +} + +class Foo { + val bar = new F + + bar. //note whitespace after dot + /*?*/ //force typechecking +} + |