Skip to content

Commit 5a276ac

Browse files
authored
Merge pull request #8923 from dotty-staging/fix-#8920
Fix #8920: Keep track of rawParamss when mapping symbols
2 parents f5b1d79 + e435e79 commit 5a276ac

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

compiler/src/dotty/tools/dotc/core/Flags.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ object Flags {
298298
/** A Scala 2x super accessor / an unpickled Scala 2.x class */
299299
val (SuperParamAliasOrScala2x @ _, SuperParamAlias @ _, Scala2x @ _) = newFlags(26, "<super-param-alias>", "<scala-2.x>")
300300

301-
/** A method that has default params */
301+
/** A parameter with a default value */
302302
val (_, HasDefault @ _, _) = newFlags(27, "<hasdefault>")
303303

304304
/** An extension method, or a collective extension instance */

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,15 @@ trait Applications extends Compatibility {
18781878
val reverseMapping = alts.flatMap { alt =>
18791879
val t = f(alt)
18801880
if t.exists then
1881-
Some((TermRef(NoPrefix, alt.symbol.asTerm.copy(info = t)), alt))
1881+
val mappedSym = alt.symbol.asTerm.copy(info = t)
1882+
mappedSym.rawParamss = alt.symbol.rawParamss
1883+
// we need rawParamss to find parameters with default arguments,
1884+
// but we do not need to be precise right now, since this is just a pre-test before
1885+
// we look up defult getters. If at some point we extract default arguments from the
1886+
// parameter symbols themselves, we have to find the right parameter by name, not position.
1887+
// That means it's OK to copy parameters wholesale rather than tailoring them to always
1888+
// correspond to the type transformation.
1889+
Some((TermRef(NoPrefix, mappedSym), alt))
18821890
else
18831891
None
18841892
}

tests/pos/i8920/Qu_1.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package scala.collection.mutable
2+
3+
class Qu[A] protected (array: Array[AnyRef], start: Int, end: Int):
4+
def this(initialSize: Int = ArrayDeque.DefaultInitialSize) =
5+
this(ArrayDeque.alloc(initialSize), start = 0, end = 0)
6+
7+
object Qu:
8+
def f[A](array: Array[AnyRef], start: Int, end: Int) = 1
9+
def f[A](initialSize: Int = 1) = 2

tests/pos/i8920/Test_2.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
class Q[A] extends scala.collection.mutable.Queue[A]
3+
class Q1[A] extends scala.collection.mutable.Qu[A]
4+
5+
def test = scala.collection.mutable.Qu.f()
6+

0 commit comments

Comments
 (0)