-
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.
Resolve overloading: keep track of prefix and indices of all default …
…getters When resolving overloading using parameter lists after the first one, we used mapped symbols that forgot about the prefix of the original call and how many parameters were skipped. Consequently, overloading resolution got confused when there were default parameters in following parameter lists. We now keep track of these values in an annotation that gets added to the mapped symbols. We also use `findDefaultGetter` directly to compute the number of default parameters in `sizeFits`. The previous scheme of checking the `HasParam` flag of parameters fails for default values inherited from overriden methods.
- Loading branch information
Showing
5 changed files
with
124 additions
and
60 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
13 changes: 13 additions & 0 deletions
13
library/src/scala/annotation/internal/MappedAlternative.scala
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 @@ | ||
package scala.annotation | ||
package internal | ||
|
||
/** An annotation added by overloading resoluton to mapped symbols that | ||
* explore deeper into the types of the opverloaded alternatives. | ||
* Its tree is a TypeTree with two parameters which are both needed to | ||
* fine default getters in later parameter sections. | ||
* @param Prefix the prefix field of the original alternative TermRef | ||
* @param SkipCount a ConstantType referring to the number of skipped term parameters | ||
* The annotation is short-lived since mapped symbols are discarded immediately | ||
* once an overloading resolution step terminates. | ||
*/ | ||
final class MappedAlternative[Prefix, SkipCount] extends Annotation |
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 @@ | ||
overriden (3, 10) |
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,11 @@ | ||
class X: | ||
def toString(maxLines: Int = 10, maxWidth: Int = 10): String = (maxLines -> maxWidth).toString | ||
|
||
class Foo extends X: | ||
override def toString(maxLines: Int, maxWidth: Int): String = s"overriden ($maxLines, $maxWidth)" | ||
override def toString(): String = toString(maxLines = 3) | ||
|
||
|
||
@main def Test = { | ||
println(Foo().toString()) | ||
} |