Skip to content

Fix #8920: Keep track of rawParamss when mapping symbols #8923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ object Flags {
/** A Scala 2x super accessor / an unpickled Scala 2.x class */
val (SuperParamAliasOrScala2x @ _, SuperParamAlias @ _, Scala2x @ _) = newFlags(26, "<super-param-alias>", "<scala-2.x>")

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

/** An extension method, or a collective extension instance */
Expand Down
10 changes: 9 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,15 @@ trait Applications extends Compatibility {
val reverseMapping = alts.flatMap { alt =>
val t = f(alt)
if t.exists then
Some((TermRef(NoPrefix, alt.symbol.asTerm.copy(info = t)), alt))
val mappedSym = alt.symbol.asTerm.copy(info = t)
mappedSym.rawParamss = alt.symbol.rawParamss
// we need rawParamss to find parameters with default arguments,
// but we do not need to be precise right now, since this is just a pre-test before
// we look up defult getters. If at some point we extract default arguments from the
// parameter symbols themselves, we have to find the right parameter by name, not position.
// That means it's OK to copy parameters wholesale rather than tailoring them to always
// correspond to the type transformation.
Some((TermRef(NoPrefix, mappedSym), alt))
else
None
}
Expand Down
9 changes: 9 additions & 0 deletions tests/pos/i8920/Qu_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package scala.collection.mutable

class Qu[A] protected (array: Array[AnyRef], start: Int, end: Int):
def this(initialSize: Int = ArrayDeque.DefaultInitialSize) =
this(ArrayDeque.alloc(initialSize), start = 0, end = 0)

object Qu:
def f[A](array: Array[AnyRef], start: Int, end: Int) = 1
def f[A](initialSize: Int = 1) = 2
6 changes: 6 additions & 0 deletions tests/pos/i8920/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

class Q[A] extends scala.collection.mutable.Queue[A]
class Q1[A] extends scala.collection.mutable.Qu[A]

def test = scala.collection.mutable.Qu.f()