forked from scala/scala
-
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.
Merge pull request scala#10831 from som-snytt/issue/13022-CCE-delambd…
…a-result Improve result of bridge in delambdafy
- Loading branch information
Showing
2 changed files
with
36 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
case class StringValue(value: String) extends AnyVal | ||
|
||
trait Foo[A] { | ||
def singleMethod(arg: A): StringValue | ||
} | ||
|
||
class R { | ||
val foo1: Foo[Int] = new Foo[Int] { | ||
override def singleMethod(arg: Int): StringValue = new StringValue(arg.toString) | ||
} | ||
val foo2: Foo[Int] = (arg: Int) => new StringValue(arg.toString) | ||
val foo3 = (arg: Int) => new StringValue(arg.toString) | ||
|
||
def run() = { | ||
assert(foo1.singleMethod(1).toString == "StringValue(1)") | ||
assert(foo2.singleMethod(1).toString == "StringValue(1)") // throws ClassCastException | ||
assert(foo3(1).toString == "StringValue(1)") | ||
} | ||
} | ||
object Test extends App { | ||
new R().run() | ||
} |