-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement
Description
Compiler version
3.8.0-RC4
Minimized example
class C[T]
object X:
def apply(xs: Int*)(d: Double) = Nil
def apply[T](xs: Int*)(t: C[T])(d: Double) = Nil
def apply()(d: Double) = List(List(d))
def apply[T]()(t: C[T])(d: Double) = List(List(d))
for
List(x) <- X()(.0)
yield
xOutput Error/Warning message
-- [E051] Reference Error: -----------------------------------------------------
2 | List(x) <- X()(.0)
| ^
|Ambiguous overload. The overloaded alternatives of method apply in object X with types
| ()(d: Double): List[List[Double]]
| (xs: Int*)(d: Double): scala.collection.immutable.Nil.type
|both match arguments ()((0.0d : Double))
|
| longer explanation available when compiling with `-explain`
1 error foundHowever, if the first apply method were commented out:
class C[T]
object X:
//def apply(xs: Int*)(d: Double) = Nil
def apply[T](xs: Int*)(t: C[T])(d: Double) = Nil
def apply()(d: Double) = List(List(d))
def apply[T]()(t: C[T])(d: Double) = List(List(d))
for
List(x) <- X()(.0)
yield
xor the fourth apply method were commented out:
class C[T]
object X:
def apply(xs: Int*)(d: Double) = Nil
def apply[T](xs: Int*)(t: C[T])(d: Double) = Nil
def apply()(d: Double) = List(List(d))
//def apply[T]()(t: C[T])(d: Double) = List(List(d))
for
List(x) <- X()(.0)
yield
xthere would be no error. There is no error also if the first method were used instead:
class C[T]
object X:
def apply(xs: Int*)(d: Double) = Nil
def apply[T](xs: Int*)(t: C[T])(d: Double) = Nil
def apply()(d: Double) = List(List(d))
def apply[T]()(t: C[T])(d: Double) = List(List(d))
for
List(x) <- X(1, 2, 3)(.0)
yield
xMetadata
Metadata
Assignees
Labels
area:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement