Skip to content

Commit 1306639

Browse files
committed
Rename This types in tests
1 parent 355f1e5 commit 1306639

23 files changed

+179
-179
lines changed

tests/disabled/partest/run/existentials-in-compiler.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ abstract trait Bippy[A <: AnyRef, B] extends AnyRef
44
abstract trait BippyBud[A <: AnyRef, B, C <: List[A]] extends AnyRef
55
extest.BippyBud[A,B,C] forSome { A <: AnyRef; B; C <: List[A] }
66

7-
abstract trait BippyLike[A <: AnyRef, B <: List[A], This <: extest.BippyLike[A,B,This] with extest.Bippy[A,B]] extends AnyRef
8-
extest.BippyLike[A,B,This] forSome { A <: AnyRef; B <: List[A]; This <: extest.BippyLike[A,B,This] with extest.Bippy[A,B] }
7+
abstract trait BippyLike[A <: AnyRef, B <: List[A], Self <: extest.BippyLike[A,B,Self] with extest.Bippy[A,B]] extends AnyRef
8+
extest.BippyLike[A,B,Self] forSome { A <: AnyRef; B <: List[A]; Self <: extest.BippyLike[A,B,Self] with extest.Bippy[A,B] }
99

1010
abstract trait Contra[-A >: AnyRef, -B] extends AnyRef
1111
extest.Contra[AnyRef, _]
@@ -151,6 +151,6 @@ abstract trait Cov49[-A >: Null, -B] extends AnyRef
151151
abstract trait Covariant[+A <: AnyRef, +B] extends AnyRef
152152
extest.Covariant[AnyRef,Any]
153153

154-
abstract trait CovariantLike[+A <: AnyRef, +B <: List[A], +This <: extest.CovariantLike[A,B,This] with extest.Covariant[A,B]] extends AnyRef
155-
extest.CovariantLike[A,B,This] forSome { +A <: AnyRef; +B <: List[A]; +This <: extest.CovariantLike[A,B,This] with extest.Covariant[A,B] }
154+
abstract trait CovariantLike[+A <: AnyRef, +B <: List[A], +Self <: extest.CovariantLike[A,B,Self] with extest.Covariant[A,B]] extends AnyRef
155+
extest.CovariantLike[A,B,Self] forSome { +A <: AnyRef; +B <: List[A]; +Self <: extest.CovariantLike[A,B,Self] with extest.Covariant[A,B] }
156156

tests/disabled/partest/run/existentials-in-compiler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ object Test extends CompilerTest {
1313
override def code = """
1414
package extest {
1515
trait Bippy[A <: AnyRef, B] { } // wildcards
16-
trait BippyLike[A <: AnyRef, B <: List[A], This <: BippyLike[A, B, This] with Bippy[A, B]] // no wildcards
16+
trait BippyLike[A <: AnyRef, B <: List[A], Self <: BippyLike[A, B, Self] with Bippy[A, B]] // no wildcards
1717
trait BippyBud[A <: AnyRef, B, C <: List[A]]
1818
1919
trait Cov01[+A <: AnyRef, +B] { }
@@ -67,7 +67,7 @@ package extest {
6767
trait Cov49[-A >: Null, -B] { }
6868
6969
trait Covariant[+A <: AnyRef, +B] { }
70-
trait CovariantLike[+A <: AnyRef, +B <: List[A], +This <: CovariantLike[A, B, This] with Covariant[A, B]]
70+
trait CovariantLike[+A <: AnyRef, +B <: List[A], +Self <: CovariantLike[A, B, Self] with Covariant[A, B]]
7171
7272
trait Contra[-A >: AnyRef, -B] { }
7373
trait ContraLike[-A >: AnyRef, -B >: List[A]]

tests/invalid/pos/IterableSelfRec.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ package immutable
55
import annotation.unchecked.uncheckedVariance
66

77
trait Collection[T] { self =>
8-
type This <: Collection { type This <: self.This }
9-
def companion: CollectionCompanion[This]
8+
type ThisCollection <: Collection { type ThisCollection <: self.ThisCollection }
9+
def companion: CollectionCompanion[ThisCollection]
1010
}
1111

1212
trait Iterable[T] extends Collection[T] { self =>
13-
type This <: Iterable { type This <: self.This }
14-
override def companion: IterableCompanion[This] = Iterable.asInstanceOf
13+
type ThisCollection <: Iterable { type ThisCollection <: self.ThisCollection }
14+
override def companion: IterableCompanion[ThisCollection] = Iterable.asInstanceOf
1515

1616
def iterator: Iterator[T]
1717
}
1818

1919
trait Seq[T] extends Iterable[T] { self =>
20-
type This <: Seq { type This <: self.This }
21-
override def companion: IterableCompanion[This] = Seq.asInstanceOf
20+
type ThisCollection <: Seq { type ThisCollection <: self.ThisCollection }
21+
override def companion: IterableCompanion[ThisCollection] = Seq.asInstanceOf
2222

2323
def apply(x: Int): T
2424
}
2525

26-
abstract class CollectionCompanion[+CC[X] <: Collection[X] { type This <: CC }]
26+
abstract class CollectionCompanion[+CC[X] <: Collection[X] { type ThisCollection <: CC }]
2727

28-
abstract class IterableCompanion[+CC[X] <: Iterable[X] { type This <: CC }] extends CollectionCompanion[CC] {
28+
abstract class IterableCompanion[+CC[X] <: Iterable[X] { type ThisCollection <: CC }] extends CollectionCompanion[CC] {
2929
def fromIterator[T](it: Iterator[T]): CC[T]
3030
def map[T, U](xs: Iterable[T], f: T => U): CC[U] =
3131
fromIterator(xs.iterator.map(f))
@@ -37,7 +37,7 @@ abstract class IterableCompanion[+CC[X] <: Iterable[X] { type This <: CC }] exte
3737
implicit def transformOps[T](xs: CC[T] @uncheckedVariance): TransformOps[CC, T] = ??? // new TransformOps[CC, T](xs)
3838
}
3939

40-
class TransformOps[+CC[X] <: Iterable[X] { type This <: CC }, T] (val xs: CC[T]) extends AnyVal {
40+
class TransformOps[+CC[X] <: Iterable[X] { type ThisCollection <: CC }, T] (val xs: CC[T]) extends AnyVal {
4141
def companion[T](xs: CC[T] @uncheckedVariance): IterableCompanion[CC] = xs.companion
4242
def map[U](f: T => U): CC[U] = companion(xs).map(xs, f)
4343
def filter(p: T => Boolean): CC[T] = companion(xs).filter(xs, p)

tests/neg/typeclass-encoding2.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ object runtime1 {
66

77
trait TypeClass1[A] {
88
val common: TypeClassCommon1
9-
type This[X] = common.This[X]
9+
type ThisClass[X] = common.ThisClass[X]
1010
}
1111

1212
trait TypeClassCommon1 { self =>
13-
type This[X]
13+
type ThisClass[X]
1414
type Instance[X] <: TypeClass1[X]
15-
def inject[A](x: This[A]): Instance[A]// { val common: self.type }
15+
def inject[A](x: ThisClass[A]): Instance[A]// { val common: self.type }
1616
}
1717

1818
trait Extension1[From[_], To[X] <: TypeClass1[X]] extends TypeClassCommon1 {
19-
type This[X] = From[X]
19+
type ThisClass[X] = From[X]
2020
type Instance[X] = To[X]
2121
}
2222

2323
implicit def inject[A, From[_]](x: From[A])
24-
(implicit ev: Extension1[From, _]): ev.Instance[A] { type This[X] = From[X] } =
25-
ev.inject(x) // error: found: ev.To[A], required: ev.To[A]{This = From}
24+
(implicit ev: Extension1[From, _]): ev.Instance[A] { type ThisClass[X] = From[X] } =
25+
ev.inject(x) // error: found: ev.To[A], required: ev.To[A]{ThisClass = From}
2626
}

tests/pending/pos/depmet_implicit_oopsla_session.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
object Sessions {
2-
trait Session[This] {
2+
trait Session[Self] {
33
type Dual
4-
type HasDual[D] = Session[This]{type Dual=D}
5-
def run(p: This, dp: Dual): Unit
4+
type HasDual[D] = Session[Self]{type Dual=D}
5+
def run(p: Self, dp: Dual): Unit
66
}
77

88
implicit object StopSession extends Session[Stop] {

tests/pos-with-compiler/tasty/definitions.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ object definitions {
6868
case Ident(name: String, override val tpe: Type)
6969
case Select(prefix: Term, name: String, signature: Option[Signature])
7070
case Literal(value: Constant)
71-
case This(id: Option[Id])
71+
case Self(id: Option[Id])
7272
case New(tpt: TypeTree)
7373
case Throw(expr: Term)
7474
case NamedArg(name: String, arg: Term)
@@ -163,8 +163,8 @@ object definitions {
163163
}
164164
}
165165

166-
abstract class LambdaType[ParamInfo, This <: LambdaType[ParamInfo, This]](
167-
val companion: LambdaTypeCompanion[ParamInfo, This]
166+
abstract class LambdaType[ParamInfo, Self <: LambdaType[ParamInfo, Self]](
167+
val companion: LambdaTypeCompanion[ParamInfo, Self]
168168
) extends Type {
169169
private[Type] var _pinfos: List[ParamInfo]
170170
private[Type] var _restpe: Type
@@ -174,10 +174,10 @@ object definitions {
174174
def resultType: Type = _restpe
175175
}
176176

177-
abstract class LambdaTypeCompanion[ParamInfo, This <: LambdaType[ParamInfo, This]] {
178-
def apply(pnames: List[String], ptypes: List[ParamInfo], restpe: Type): This
177+
abstract class LambdaTypeCompanion[ParamInfo, Self <: LambdaType[ParamInfo, Self]] {
178+
def apply(pnames: List[String], ptypes: List[ParamInfo], restpe: Type): Self
179179

180-
def apply(pnames: List[String], ptypesExp: This => List[ParamInfo], restpeExp: This => Type): This = {
180+
def apply(pnames: List[String], ptypesExp: Self => List[ParamInfo], restpeExp: Self => Type): Self = {
181181
val lambda = apply(pnames, Nil, PlaceHolder)
182182
lambda._pinfos = ptypesExp(lambda)
183183
lambda._restpe = restpeExp(lambda)

tests/pos/extmethods-2.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package extMethods
22

33
trait That1[A]
4-
class T[A, This <: That1[A]](val x: Int) extends AnyVal {
5-
self: This =>
6-
final def loop(x: This, cnt: Int): Int = loop(x, cnt + 1)
4+
class T[A, Self <: That1[A]](val x: Int) extends AnyVal {
5+
self: Self =>
6+
final def loop(x: Self, cnt: Int): Int = loop(x, cnt + 1)
77
}

tests/pos/extmethods.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
trait That1[A]
2-
class T[A, This <: That1[A]](val x: Int) extends AnyVal {
3-
self: This =>
4-
final def loop(x: This, cnt: Int): Int = loop(x, cnt + 1)
2+
class T[A, Self <: That1[A]](val x: Int) extends AnyVal {
3+
self: Self =>
4+
final def loop(x: Self, cnt: Int): Int = loop(x, cnt + 1)
55
def const[B](): Boolean = return true
66
}
77

tests/pos/i1401.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ trait Subtractable[AS, +Repr <: Subtractable[AS, Repr]] {
44
def -(elem: AS): Repr
55
}
66

7-
trait BufferLike[BA, +This <: BufferLike[BA, This] with Buffer[BA]]
8-
extends Subtractable[BA, This]
9-
{ self : This =>
7+
trait BufferLike[BA, +Self <: BufferLike[BA, Self] with Buffer[BA]]
8+
extends Subtractable[BA, Self]
9+
{ self : Self =>
1010

1111
/* Without fix-#1401:
1212
*
13-
error: overriding method - in trait Subtractable of type (elem: A)This & i1401.Buffer[A];
14-
method - of type (elem: BA)This has incompatible type
15-
def -(elem: BA): This
13+
error: overriding method - in trait Subtractable of type (elem: A)Self & i1401.Buffer[A];
14+
method - of type (elem: BA)Self has incompatible type
15+
def -(elem: BA): Self
1616
^
1717
one error found
1818
*/
19-
def -(elem: BA): This
19+
def -(elem: BA): Self
2020
}
2121

2222
trait Buffer[A] extends BufferLike[A, Buffer[A]]

tests/pos/i4884.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ object Test {
1414
}
1515
trait TestConstructor4[D] {
1616
trait TestConstructor5[E] {
17-
trait MSetLike[X <: D & E, This <: MSet[X] with MSetLike[X, This]]
17+
trait MSetLike[X <: D & E, Self <: MSet[X] with MSetLike[X, Self]]
1818
trait MSet[X <: D & E] extends MSetLike[X, MSet[X]]
1919
}
2020
}

tests/pos/pets.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
// Representing the current type
22
trait Pet {
3-
type This <: Pet
3+
type ThisPet <: Pet
44
def name: String
5-
def renamed(newName: String): This
5+
def renamed(newName: String): ThisPet
66
}
77

88
case class Fish(name: String, age: Int) extends Pet {
9-
type This = Fish
9+
type ThisPet = Fish
1010
def renamed(newName: String): Fish = copy(name = newName)
1111
}
1212

1313
case class Kitty(name: String, age: Int) extends Pet {
14-
type This = Kitty
14+
type ThisPet = Kitty
1515
def renamed(newName: String): Kitty = copy(name = newName)
1616
}
1717

1818
object Test {
19-
def esquire[A <: Pet](a: A): a.This = a.renamed(a.name + ", Esq.")
19+
def esquire[A <: Pet](a: A): a.ThisPet = a.renamed(a.name + ", Esq.")
2020
val f: Fish = esquire(new Fish("bob", 22))
2121
}

tests/pos/spec-partialmap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ trait PartialMap[@specialized A,@specialized B] extends PartialFunction[A,B] wit
88
for ((k,v) <- iterator; if f(k)) yield v
99

1010
// if this is commented, it compiles fine:
11-
def apply[This <: Iterable[A]](keys : IterableOps[A, Iterable, This]): Iterable[B] = keys.map(apply)
11+
def apply[Self <: Iterable[A]](keys : IterableOps[A, Iterable, Self]): Iterable[B] = keys.map(apply)
1212
}

tests/pos/t0039.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
abstract class Extensible[A, This <: Extensible[A, This]](x: A, xs: This) { self: This =>
2-
def mkObj(x: A, xs: This): This;
1+
abstract class Extensible[A, Self <: Extensible[A, Self]](x: A, xs: Self) { self: Self =>
2+
def mkObj(x: A, xs: Self): Self;
33
}
44
class Fixed[A](x: A, xs: Fixed[A]) extends Extensible[A, Fixed[A]](x, xs) {
55
def mkObj(x: A, xs: Fixed[A]) = new Fixed(x, xs);

tests/pos/t2399.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
trait That1[A]
22
trait That2[A, R <: That2[A, R]]
33

4-
trait T[A, This >: Null <: That1[A] with T[A, This]] extends That2[A, This] {
5-
self: This =>
4+
trait T[A, Self >: Null <: That1[A] with T[A, Self]] extends That2[A, Self] {
5+
self: Self =>
66

7-
private var next: This = _
7+
private var next: Self = _
88
def isEmpty = next eq null
99

1010
def length: Int = {
11-
def loop(x: This, cnt: Int): Int = if (x.isEmpty) cnt else loop(x.next, cnt + 1)
11+
def loop(x: Self, cnt: Int): Int = if (x.isEmpty) cnt else loop(x.next, cnt + 1)
1212
loop(self, 0)
1313
}
1414
}

tests/pos/t4243.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
object wrap {
66

7-
trait DomainLike[@specialized(Int) A, +This <: Domain[A]]
7+
trait DomainLike[@specialized(Int) A, +Self <: Domain[A]]
88

99
trait Domain[@specialized(Int) B]
1010
extends DomainLike[B, Domain[B]]
1111

12-
trait IterableDomainLike[@specialized(Int) C, +This <: IterableDomain[C]]
13-
extends DomainLike[C, This]
12+
trait IterableDomainLike[@specialized(Int) C, +Self <: IterableDomain[C]]
13+
extends DomainLike[C, Self]
1414

1515
trait IterableDomain[@specialized(Int) D]
1616
extends Domain[D] with IterableDomainLike[D, IterableDomain[D]]

tests/pos/typeclass-encoding.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
object runtime {
2626

2727
trait TypeClass {
28-
type This
29-
type StaticPart[This]
28+
type ThisClass
29+
type StaticPart[ThisClass]
3030
}
3131

3232
trait Implementation[From] {
33-
type This = From
33+
type ThisClass = From
3434
type Implemented <: TypeClass
35-
def inject(x: From): Implemented { type This = From }
35+
def inject(x: From): Implemented { type ThisClass = From }
3636
}
3737

3838
class CompanionOf[T] { type StaticPart[_] }
@@ -43,21 +43,21 @@ object runtime {
4343
ev1.asInstanceOf // can we avoid the cast?
4444

4545
implicit def inject[From](x: From)(
46-
implicit ev1: Implementation[From]): ev1.Implemented { type This = From } =
46+
implicit ev1: Implementation[From]): ev1.Implemented { type ThisClass = From } =
4747
ev1.inject(x)
4848
}
4949

5050
object semiGroups {
5151
import runtime._
5252

5353
trait SemiGroup extends TypeClass {
54-
def add(that: This): This
54+
def add(that: ThisClass): ThisClass
5555
}
5656

5757
trait Monoid extends SemiGroup {
58-
type StaticPart[This] <: MonoidStatic[This]
58+
type StaticPart[ThisClass] <: MonoidStatic[ThisClass]
5959
}
60-
abstract class MonoidStatic[This] { def unit: This }
60+
abstract class MonoidStatic[ThisClass] { def unit: ThisClass }
6161

6262
implicit def companionOfMonoid: CompanionOf[Monoid] {
6363
type StaticPart[X] = MonoidStatic[X]
@@ -69,18 +69,18 @@ object semiGroups {
6969
type Implemented = Monoid
7070
def unit: Int = 0
7171
def inject($this: Int) = new Monoid {
72-
type This = Int
73-
def add(that: This): This = $this + that
72+
type ThisClass = Int
73+
def add(that: ThisClass): ThisClass = $this + that
7474
}
7575
}
7676

7777
implicit object extend_String_Monoid extends MonoidStatic[String], Implementation[String] {
7878
type Implemented = Monoid
7979
def unit = ""
80-
def inject($this: String): Monoid { type This = String } =
80+
def inject($this: String): Monoid { type ThisClass = String } =
8181
new Monoid {
82-
type This = String
83-
def add(that: This): This = $this ++ that
82+
type ThisClass = String
83+
def add(that: ThisClass): ThisClass = $this ++ that
8484
}
8585
}
8686

0 commit comments

Comments
 (0)