Skip to content

Commit 8c5afe3

Browse files
committed
Make run tests for #1381.
1 parent 91f0671 commit 8c5afe3

File tree

3 files changed

+66
-36
lines changed

3 files changed

+66
-36
lines changed

tests/pos/overloaded.scala

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -47,40 +47,4 @@ object overloaded {
4747
val t5: Int = r5
4848
val r6 = combine((x: String, y) => x ++ y.toString)
4949
val t6: String = r6
50-
51-
// test result disambiguation
52-
trait A
53-
trait B
54-
class C extends A with B
55-
def fr(x: A): A = x
56-
def fr(x: B): B = x
57-
val a: A = fr(new C)
58-
val b: B = fr(new C)
59-
}
60-
61-
// from #1381
62-
63-
object Foo {
64-
class Bar[T]
65-
implicit def const[T](x: T): Bar[T] = ???
66-
67-
def bar[T](e: T): Any = ???
68-
def bar[T](e: Bar[T]): Any = ???
69-
70-
val b: Bar[Int] = ???
71-
bar(b)
72-
}
73-
74-
object Test2 {
75-
trait A; trait B
76-
class C1 {
77-
def f(x: A): Unit = println("A")
78-
}
79-
class C2 extends C1 {
80-
def f(x: B): Unit = println("B")
81-
}
82-
object Test extends C2 with App {
83-
implicit def a2b(x: A): B = new B {}
84-
f(new A {})
85-
}
8650
}

tests/run/t1381.check

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
4
2+
3
3+
2
4+
A
5+
B
6+
frA
7+
frB

tests/run/t1381.scala

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
object Test {
2+
def main(args: Array[String]): Unit = {
3+
Test1.test()
4+
Test2.test()
5+
Test3.test()
6+
}
7+
}
8+
9+
object Test1 {
10+
class Bar[T](n: Int) {
11+
println(n)
12+
}
13+
implicit def const[T](x: T): Bar[T] = new Bar[T](1)
14+
15+
def bar[T](e: T): Any = new Bar[T](2)
16+
def bar[T](e: Bar[T]): Any = new Bar[T](3)
17+
18+
val b: Bar[Int] = new Bar[Int](4)
19+
20+
def test(): Unit = {
21+
bar(b)
22+
bar(5)
23+
}
24+
}
25+
26+
object Test2 {
27+
trait A; trait B
28+
class C1 {
29+
def f(x: A): Unit = println("A")
30+
}
31+
class C2 extends C1 {
32+
def f(x: B): Unit = println("B")
33+
}
34+
object Test extends C2 with App {
35+
implicit def a2b(x: A): B = new B {}
36+
def test(): Unit = {
37+
f(new A {})
38+
f(new B {})
39+
}
40+
}
41+
def test(): Unit = Test.test()
42+
}
43+
44+
object Test3 {
45+
trait A; trait B
46+
class C extends A with B
47+
def fr(x: A): A = {
48+
println("frA")
49+
x
50+
}
51+
def fr(x: B): B = {
52+
println("frB")
53+
x
54+
}
55+
def test(): Unit = {
56+
val a: A = fr(new C)
57+
val b: B = fr(new C)
58+
}
59+
}

0 commit comments

Comments
 (0)