Skip to content

Commit 783b978

Browse files
authored
Merge pull request #2035 from dotty-staging/fix-#2033
Fix #2033: Improve handling of unresolved overloaded arguments
2 parents 179a5d6 + 145ac69 commit 783b978

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,16 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
450450

451451
def typedArg(arg: Arg, formal: Type): Arg = arg
452452
def addArg(arg: TypedArg, formal: Type) =
453-
ok = ok & isCompatible(argType(arg, formal), formal)
453+
ok = ok & {
454+
argType(arg, formal) match {
455+
case ref: TermRef if ref.denot.isOverloaded =>
456+
// in this case we could not resolve overloading because no alternative
457+
// matches expected type
458+
false
459+
case argtpe =>
460+
isCompatible(argtpe, formal)
461+
}
462+
}
454463
def makeVarArg(n: Int, elemFormal: Type) = {}
455464
def fail(msg: => Message, arg: Arg) =
456465
ok = false

tests/neg/i2033.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.io._
2+
import collection._
3+
object Test {
4+
def check(obj: AnyRef): Unit = {
5+
val bos = new ByteArrayOutputStream()
6+
val out = new ObjectOutputStream(println) // error
7+
val arr = bos toByteArray ()
8+
val in = (())
9+
val deser = ()
10+
val lhs = mutable LinkedHashSet ()
11+
check(lhs)
12+
}
13+
}
14+
15+
// minimization
16+
object Test2 {
17+
class ObjectOutputStream(out: String) {
18+
def this() = this("")
19+
}
20+
val out = new ObjectOutputStream(println) // error
21+
}

0 commit comments

Comments
 (0)