diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-11-21 07:18:59 -0800 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-11-21 07:18:59 -0800 |
commit | 38fdd3d1300761e50036c80e9e759873ea1d067b (patch) | |
tree | bcecb205b858fd8214b589d812b50f87cc01d730 | |
parent | b9f68601bee026bff2c494add399de61de7fc79d (diff) | |
parent | 04df2e48e4ae53a4f72c299ce88fa2239b7fba69 (diff) | |
download | scala-38fdd3d1300761e50036c80e9e759873ea1d067b.tar.gz scala-38fdd3d1300761e50036c80e9e759873ea1d067b.tar.bz2 scala-38fdd3d1300761e50036c80e9e759873ea1d067b.zip |
Merge pull request #3157 from dotta/backport/2.10.x/si-7915
Backport of SI-7915
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala | 9 | ||||
-rw-r--r-- | test/files/presentation/t7915.check | 11 | ||||
-rw-r--r-- | test/files/presentation/t7915/Test.scala | 8 | ||||
-rw-r--r-- | test/files/presentation/t7915/src/Foo.scala | 9 |
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/*#*/() + } +} |