Check if the parent of class has an empty constr before expanding SAM#15909
Closed
KacperFKorban wants to merge 1 commit into
Closed
Check if the parent of class has an empty constr before expanding SAM#15909KacperFKorban wants to merge 1 commit into
KacperFKorban wants to merge 1 commit into
Conversation
Expanding a SAM into an anonymous class assumes that the parent class has a constructor with an empty parameter list. Before this change, a situation in which there was no such constructor caused a crash. fixes scala#15855
Member
Author
|
Looks like there's a case that I missed, converting to draft for now. |
Member
|
These are things that Scala 2 can handle correctly, filling in the appropriate $ cs launch scala:2.13.8
Welcome to Scala 2.13.8 (OpenJDK 64-Bit Server VM, Java 1.8.0_342).
Type in expressions for evaluation. Or try :help.
scala> class MyFunction(val args: String*)
class MyFunction
scala> trait MyFun[+R] extends MyFunction { def apply(i: Int): R }
trait MyFun
scala> val f: MyFun[Int] = _ + 1
val f: MyFun[Int] = $anonfun$1@2728add3
scala> f(5)
val res1: Int = 6
scala> f.args
val res2: Seq[String] = List()
scala> class MyFunction(val arg: String = "foo")
class MyFunction
scala> trait MyFun[+R] extends MyFunction { def apply(i: Int): R }
trait MyFun
scala> val f: MyFun[Int] = _ + 1
val f: MyFun[Int] = $anonfun$1@2f1b8770
scala> f(5)
val res3: Int = 6
scala> f.arg
val res4: String = foo |
Member
Author
|
@sjrd Right, I see. Then the fix is going to be entirely different then. Will open a new PR for it then. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Expanding a SAM into an anonymous class assumes that the parent class
has a constructor with an empty parameter list. Before this change, a
situation in which there was no such constructor caused a crash.
fixes #15855