From 7a23562431e3e9673112b0f5ec5624eb28194ee5 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 8 Jan 2013 12:10:10 +0100 Subject: SI-6912 Avoid a typer cycle in overload resolution. c800d1fe, and followup commits 1ddc9358 and b10b5821 modified error handling in `Infer#inferExprAlternative`. After these changes, this method could fail to resolve the overloaded alternative if: best != NoSymbol && !competing.isEmpty && !noAlternatives && pt.isErroneous This commit calls `setError` in that case, which prevents the cycle in `adapt`. While I didn't extract a reproduction from the original code base, I've included a test case that exhibits the same symptom. It was actually pretty tough to find an program that got close to this code path, but luckilly we've been pretty close to this bug in SI-5553 / 4f99c2e5, and those test cases formed the basis for this one. --- test/files/neg/t6912.check | 4 ++++ test/files/neg/t6912.scala | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100644 test/files/neg/t6912.check create mode 100644 test/files/neg/t6912.scala (limited to 'test/files/neg') diff --git a/test/files/neg/t6912.check b/test/files/neg/t6912.check new file mode 100644 index 0000000000..137b651705 --- /dev/null +++ b/test/files/neg/t6912.check @@ -0,0 +1,4 @@ +t6912.scala:8: error: not found: type Xxxx + def test[T]: Xxxx = Foo1[T] + ^ +one error found diff --git a/test/files/neg/t6912.scala b/test/files/neg/t6912.scala new file mode 100644 index 0000000000..f2540ee8c6 --- /dev/null +++ b/test/files/neg/t6912.scala @@ -0,0 +1,9 @@ +object Foo1 { + def apply[T](a: Int = 0): Nothing = sys.error("") + def apply[T](z: String = ""): Nothing = sys.error("") +} + +object Test { + // Triggered a cycle in Typers#adapt + def test[T]: Xxxx = Foo1[T] +} -- cgit v1.2.3