forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes scala#9225 Closes scala#10437
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import scala.language.implicitConversions | ||
|
||
final class MyClass(name: String) { | ||
|
||
final class Fun0(val f: Function0[Any]) | ||
|
||
object Fun0 { | ||
|
||
implicit def function0AsFun0(f: Function0[Any]): Fun0 = new Fun0(f) | ||
|
||
} | ||
|
||
def apply(f: => Unit): Unit = { | ||
apply(() => f) | ||
} | ||
|
||
def apply(fun: Fun0): Unit = { | ||
// Do something | ||
println(s"Got a Fun0 $fun") | ||
} | ||
|
||
def apply[T1](f: (T1) => Any)(implicit m1: Manifest[T1]): Unit = { | ||
// Do something | ||
println(s"Got a Function1: ${f}") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
trait A { | ||
val s = "same val in A" | ||
def f: String = s | ||
} | ||
|
||
class B extends A { | ||
class C { | ||
def call_f_in_A: String = B.super[A].f | ||
} | ||
} | ||
val b = new B | ||
val c = new b.C | ||
@main def Test = c.call_f_in_A // AbstractMethodError |