Skip to content

Resolve SeqType based on the alias defined in scala package object #4741

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

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 9 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,15 @@ class Definitions {
List(AnyClass.typeRef), EmptyScope)
lazy val SingletonType: TypeRef = SingletonClass.typeRef

lazy val SeqType: TypeRef = ctx.requiredClassRef("scala.collection.Seq")
lazy val SeqType: TypeRef = {
// We load SeqType from the alias in scala package object
// - in 2.12: scala.collection.Seq
// - in 2.13: scala.collection.immutable.Seq
val alias = ctx.base.staticRef("scala.Seq".toTypeName).requiredSymbol(_.isAliasType)
alias.info.classSymbol.typeRef
}

// lazy val SeqType: TypeRef = ctx.requiredClassRef("scala.collection.Seq")
def SeqClass(implicit ctx: Context) = SeqType.symbol.asClass
lazy val Seq_applyR = SeqClass.requiredMethodRef(nme.apply)
def Seq_apply(implicit ctx: Context) = Seq_applyR.symbol
Expand Down
14 changes: 13 additions & 1 deletion tests/pos/repeatedArgs.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
object testRepeated {
def foo = java.lang.System.out.format("%4$2s %3$2s %2$2s %1$2s", "a", "b", "c", "d")
def foo = java.lang.System.out.format("%4$2s %3$2s %2$2s %1$2s", "a", "b", "c", "d")

def bar(xs: Int*): Int = xs.length
def bat(xs: scala.Seq[Int]): Int = xs.length

def test(xs: List[Int]): Unit = {
bar(1, 2, 3)
bar(xs: _*)

val List(_, ys: _*) = xs
bar(ys: _*)
bat(ys)
}
}