diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 7 | ||||
-rw-r--r-- | test/disabled/neg/t5452.check (renamed from test/files/neg/t5452.check) | 0 | ||||
-rw-r--r-- | test/disabled/neg/t5452.scala (renamed from test/files/neg/t5452.scala) | 0 | ||||
-rw-r--r-- | test/disabled/pos/spurious-overload.scala | 32 |
4 files changed, 33 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index acf905d974..b97fbebec2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -1466,9 +1466,7 @@ trait Infer { argtpes: List[Type], pt0: Type, varArgsOnly: Boolean = false): Unit = tree.tpe match { case OverloadedType(pre, alts) => val pt = if (pt0.typeSymbol == UnitClass) WildcardType else pt0 - var secondTry = true tryTwice { - secondTry = !secondTry debuglog("infer method alt "+ tree.symbol +" with alternatives "+ (alts map pre.memberType) +", argtpes = "+ argtpes +", pt = "+ pt) @@ -1490,11 +1488,8 @@ trait Infer { if (improves(alt, best)) alt else best) val competing = applicable.dropWhile(alt => best == alt || improves(best, alt)) if (best == NoSymbol) { - if (pt == WildcardType) { + if (pt == WildcardType) NoBestMethodAlternativeError(tree, argtpes, pt) - if (secondTry) - setError(tree) - } else inferMethodAlternative(tree, undetparams, argtpes, WildcardType) } else if (!competing.isEmpty) { diff --git a/test/files/neg/t5452.check b/test/disabled/neg/t5452.check index 2f35a45509..2f35a45509 100644 --- a/test/files/neg/t5452.check +++ b/test/disabled/neg/t5452.check diff --git a/test/files/neg/t5452.scala b/test/disabled/neg/t5452.scala index 1032db7a4b..1032db7a4b 100644 --- a/test/files/neg/t5452.scala +++ b/test/disabled/neg/t5452.scala diff --git a/test/disabled/pos/spurious-overload.scala b/test/disabled/pos/spurious-overload.scala new file mode 100644 index 0000000000..9767a44eee --- /dev/null +++ b/test/disabled/pos/spurious-overload.scala @@ -0,0 +1,32 @@ +object Test extends App { + def foo(bar: Any) = bar + + val code = foo{ + object lazyLib { + + def delay[A](value: => A): Susp[A] = new SuspImpl[A](value) + + implicit def force[A](s: Susp[A]): A = s() + + abstract class Susp[+A] extends Function0[A] + + class SuspImpl[A](lazyValue: => A) extends Susp[A] { + private var maybeValue: Option[A] = None + + override def apply() = maybeValue match { + case None => + val value = lazyValue + maybeValue = Some(value) + value + case Some(value) => + value + } + } + } + + import lazyLib._ + + val s: Susp[Int] = delay { println("evaluating..."); 3 } + println("2 + s = " + (2 + s)) // implicit call to force() + } +}
\ No newline at end of file |