summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala9
-rw-r--r--test/files/presentation/t7915.check11
-rw-r--r--test/files/presentation/t7915/Test.scala8
-rw-r--r--test/files/presentation/t7915/src/Foo.scala9
4 files changed, 34 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index aafff8a48e..70f2f41ec7 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -164,7 +164,7 @@ trait NamesDefaults { self: Analyzer =>
// never used for constructor calls, they always have a stable qualifier
def blockWithQualifier(qual: Tree, selected: Name) = {
- val sym = blockTyper.context.owner.newValue(unit.freshTermName("qual$"), qual.pos) setInfo uncheckedBounds(qual.tpe)
+ val sym = blockTyper.context.owner.newValue(unit.freshTermName("qual$"), qual.pos) setInfo uncheckedBounds(qual.tpe) setPos (qual.pos.makeTransparent)
blockTyper.context.scope enter sym
val vd = atPos(sym.pos)(ValDef(sym, qual) setType NoType)
// it stays in Vegas: SI-5720, SI-5727
@@ -175,13 +175,16 @@ trait NamesDefaults { self: Analyzer =>
// setSymbol below is important because the 'selected' function might be overloaded. by
// assigning the correct method symbol, typedSelect will just assign the type. the reason
// to still call 'typed' is to correctly infer singleton types, SI-5259.
- val f = blockTyper.typedOperator(Select(newQual, selected).setSymbol(baseFun1.symbol))
+ val selectPos =
+ if(qual.pos.isRange && baseFun.pos.isRange) qual.pos.union(baseFun.pos).withStart(Math.min(qual.pos.end, baseFun.pos.end))
+ else baseFun.pos
+ val f = blockTyper.typedOperator(Select(newQual, selected).setSymbol(baseFun1.symbol).setPos(selectPos))
if (funTargs.isEmpty) f
else TypeApply(f, funTargs).setType(baseFun.tpe)
}
val b = Block(List(vd), baseFunTransformed)
- .setType(baseFunTransformed.tpe).setPos(baseFun.pos)
+ .setType(baseFunTransformed.tpe).setPos(baseFun.pos.makeTransparent)
context.namedApplyBlockInfo =
Some((b, NamedApplyInfo(Some(newQual), defaultTargs, Nil, blockTyper)))
b
diff --git a/test/files/presentation/t7915.check b/test/files/presentation/t7915.check
new file mode 100644
index 0000000000..b18b4ddb55
--- /dev/null
+++ b/test/files/presentation/t7915.check
@@ -0,0 +1,11 @@
+reload: Foo.scala
+
+askHyperlinkPos for `Bar` at (7,11) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `Bar` at (1,7) Foo.scala
+================================================================================
+
+askHyperlinkPos for `bar` at (7,22) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `bar` at (2,7) Foo.scala
+================================================================================
diff --git a/test/files/presentation/t7915/Test.scala b/test/files/presentation/t7915/Test.scala
new file mode 100644
index 0000000000..c2f89bdb17
--- /dev/null
+++ b/test/files/presentation/t7915/Test.scala
@@ -0,0 +1,8 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+
+object Test extends InteractiveTest {
+ override def runDefaultTests() {
+ sourceFiles foreach (src => askLoadedTyped(src).get)
+ super.runDefaultTests()
+ }
+}
diff --git a/test/files/presentation/t7915/src/Foo.scala b/test/files/presentation/t7915/src/Foo.scala
new file mode 100644
index 0000000000..a4166ae5b4
--- /dev/null
+++ b/test/files/presentation/t7915/src/Foo.scala
@@ -0,0 +1,9 @@
+class Bar {
+ def bar(b: Int = 2) {}
+}
+
+class Foo {
+ def foo() {
+ new Bar/*#*/().bar/*#*/()
+ }
+}