Skip to content

Commit

Permalink
Merge pull request #1859 from retronym/ticket/6912
Browse files Browse the repository at this point in the history
SI-6912 Avoid a typer cycle in overload resolution.
  • Loading branch information
paulp committed Jan 13, 2013
2 parents 9ea0a20 + 7a23562 commit 5d65772
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/compiler/scala/tools/nsc/typechecker/Infer.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1512,6 +1512,13 @@ trait Infer extends Checkable {
} else if (!competing.isEmpty) { } else if (!competing.isEmpty) {
if (noAlternatives) NoBestExprAlternativeError(tree, pt, isSecondTry) if (noAlternatives) NoBestExprAlternativeError(tree, pt, isSecondTry)
else if (!pt.isErroneous) AmbiguousExprAlternativeError(tree, pre, best, competing.head, pt, isSecondTry) else if (!pt.isErroneous) AmbiguousExprAlternativeError(tree, pre, best, competing.head, pt, isSecondTry)
else {
// SI-6912 Don't give up and leave an OverloadedType on the tree.
// Originally I wrote this as `if (secondTry) ... `, but `tryTwice` won't attempt the second try
// unless an error is issued. We're not issuing an error, in the assumption that it would be
// spurious in light of the erroneous expected type
setError(tree)
}
} else { } else {
// val applicable = alts1 filter (alt => // val applicable = alts1 filter (alt =>
// global.typer.infer.isWeaklyCompatible(pre.memberType(alt), pt)) // global.typer.infer.isWeaklyCompatible(pre.memberType(alt), pt))
Expand Down
4 changes: 4 additions & 0 deletions test/files/neg/t6912.check
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,4 @@
t6912.scala:8: error: not found: type Xxxx
def test[T]: Xxxx = Foo1[T]
^
one error found
9 changes: 9 additions & 0 deletions test/files/neg/t6912.scala
Original file line number Original file line Diff line number Diff line change
@@ -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]
}

0 comments on commit 5d65772

Please sign in to comment.