From 652b3b4b9dcbf990e7ace409e050cc4ba4e83b16 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 1 Dec 2013 09:56:36 +0100 Subject: SI-7548 Test to demonstrate residual exploratory typing bug We shouldn't observe tree types under silent mode. The enclosed test is a standalone version of `1 + BigInt(2)`, a standard example of exploratory typing in Scala. Once we determine that none of the `+` methods in `Int` accepts (possibly implicitly coerced `BigInt`), we have to backtrack and look for a view from `Int => { +(_: BigInt): ? }`. The next commit will correct the problem. --- test/files/presentation/t7548b.check | 1 + test/files/presentation/t7548b/Test.scala | 17 +++++++++++++++++ test/files/presentation/t7548b/src/Foo.scala | 12 ++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 test/files/presentation/t7548b.check create mode 100644 test/files/presentation/t7548b/Test.scala create mode 100644 test/files/presentation/t7548b/src/Foo.scala (limited to 'test/files/presentation') diff --git a/test/files/presentation/t7548b.check b/test/files/presentation/t7548b.check new file mode 100644 index 0000000000..5ba69809f1 --- /dev/null +++ b/test/files/presentation/t7548b.check @@ -0,0 +1 @@ +Foo.this.I.+: (other: Foo.I.type)Unit diff --git a/test/files/presentation/t7548b/Test.scala b/test/files/presentation/t7548b/Test.scala new file mode 100644 index 0000000000..0c022df839 --- /dev/null +++ b/test/files/presentation/t7548b/Test.scala @@ -0,0 +1,17 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest { + override protected def loadSources() { /* don't parse or typecheck sources */ } + + import compiler._ + + override def runDefaultTests() { + val res = new Response[Tree] + val pos = compiler.rangePos(sourceFiles.head, 191, 191, 191) // + + compiler.askTypeAt(pos, res) + res.get match { + case Left(tree) => compiler.ask(() => reporter.println(s"$tree: ${tree.tpe}")) + case Right(ex) => reporter.println(ex) + } + } +} diff --git a/test/files/presentation/t7548b/src/Foo.scala b/test/files/presentation/t7548b/src/Foo.scala new file mode 100644 index 0000000000..5cf0a4ef4e --- /dev/null +++ b/test/files/presentation/t7548b/src/Foo.scala @@ -0,0 +1,12 @@ +import language._ + +object Foo { + object I { + def +(other: I.type) : Unit = () + } + object BI { + def +(other: BI.type): Unit = () + } + implicit def I2BI(i: I.type): BI.type = BI + I.+(BI) +} -- cgit v1.2.3