-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport "Three fixes to SAM type handling" to LTS (#22132)
Backports #21596 to the 3.3.5. PR submitted by the release tooling. [skip ci]
- Loading branch information
Showing
7 changed files
with
124 additions
and
38 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
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
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
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
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
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,15 @@ | ||
class MyFunction(args: String) | ||
|
||
trait MyFunction0[+R] extends MyFunction { | ||
def apply(): R | ||
} | ||
|
||
def fromFunction0[R](f: Function0[R]): MyFunction0[R] = () => f() // error | ||
|
||
class MyFunctionWithImplicit(implicit args: String) | ||
|
||
trait MyFunction0WithImplicit[+R] extends MyFunctionWithImplicit { | ||
def apply(): R | ||
} | ||
|
||
def fromFunction1[R](f: Function0[R]): MyFunction0WithImplicit[R] = () => f() // error |
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,17 @@ | ||
class MyFunction(args: String*) | ||
|
||
trait MyFunction0[+R] extends MyFunction { | ||
def apply(): R | ||
} | ||
|
||
abstract class MyFunction1[R](args: R*): | ||
def apply(): R | ||
|
||
def fromFunction0[R](f: Function0[R]): MyFunction0[R] = () => f() | ||
def fromFunction1[R](f: Function0[R]): MyFunction1[R] = () => f() | ||
|
||
@main def Test = | ||
val m0: MyFunction0[Int] = fromFunction0(() => 1) | ||
val m1: MyFunction1[Int] = fromFunction1(() => 2) | ||
assert(m0() == 1) | ||
assert(m1() == 2) |