Skip to content

Commit 40d5a36

Browse files
committed
Add ambiguity test
1 parent ddfdc54 commit 40d5a36

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/neg/creator-ambiguous.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
// This used to succeed with old creator methods scheme
3+
// What happened was: the overloading resolution gave an ambiguous
4+
// overload, but then the falblback picked the constructor
5+
object Test:
6+
7+
case class Record(elems: (String, Any)*)
8+
9+
object Record:
10+
11+
inline def apply[R <: Record](elems: (String, Any)*) : R = new Record(elems: _*).asInstanceOf[R]
12+
13+
def fromUntypedTuple(elems: (String, Any)*): Record = Record(elems: _*) // error: ambiguous overload
14+
15+
def apply(x: String): Test = Test(x ++ x)
16+
17+
def apply(x: Integer): Test = Test(x + x)
18+
19+
Test(null) // error: ambiguous overload
20+
21+
end Test
22+
23+
class Test(x: Object)

0 commit comments

Comments
 (0)