Skip to content

Commit af63f66

Browse files
smarterbishabosha
authored andcommitted
Allow implementing unapplySeq using scala.collection.Seq
Needed to compile scala-xml with the 2.13 stdlib.
1 parent 3f53d57 commit af63f66

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ class Definitions {
396396
List(AnyClass.typeRef), EmptyScope)
397397
@tu lazy val SingletonType: TypeRef = SingletonClass.typeRef
398398

399+
@tu lazy val CollectionSeqType: TypeRef = ctx.requiredClassRef("scala.collection.Seq")
399400
@tu lazy val SeqType: TypeRef = ctx.requiredClassRef("scala.collection.immutable.Seq")
400401
def SeqClass given Context: ClassSymbol = SeqType.symbol.asClass
401402
@tu lazy val Seq_apply : Symbol = SeqClass.requiredMethod(nme.apply)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ object Applications {
7878
* {
7979
* def lengthCompare(len: Int): Int // or, def length: Int
8080
* def apply(i: Int): T = a(i)
81-
* def drop(n: Int): scala.Seq[T]
82-
* def toSeq: scala.Seq[T]
81+
* def drop(n: Int): scala.collection.Seq[T]
82+
* def toSeq: scala.collection.Seq[T]
8383
* }
8484
* ```
8585
* returns `T`, otherwise NoType.
@@ -88,8 +88,8 @@ object Applications {
8888
def lengthTp = ExprType(defn.IntType)
8989
def lengthCompareTp = MethodType(List(defn.IntType), defn.IntType)
9090
def applyTp(elemTp: Type) = MethodType(List(defn.IntType), elemTp)
91-
def dropTp(elemTp: Type) = MethodType(List(defn.IntType), defn.SeqType.appliedTo(elemTp))
92-
def toSeqTp(elemTp: Type) = ExprType(defn.SeqType.appliedTo(elemTp))
91+
def dropTp(elemTp: Type) = MethodType(List(defn.IntType), defn.CollectionSeqType.appliedTo(elemTp))
92+
def toSeqTp(elemTp: Type) = ExprType(defn.CollectionSeqType.appliedTo(elemTp))
9393

9494
// the result type of `def apply(i: Int): T`
9595
val elemTp = getTp.member(nme.apply).suchThat(_.info <:< applyTp(WildcardType)).info.resultType

0 commit comments

Comments
 (0)