Skip to content
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

Use normal mixed-in Product.productIterator #10002

Merged
merged 2 commits into from
Apr 19, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import symtab.Flags._
* def productArity: Int
* def productElement(n: Int): Any
* def productPrefix: String
* def productIterator: Iterator[Any]
*
* Selectively added to case classes/objects, unless a non-default
* implementation already exists:
Expand Down Expand Up @@ -114,11 +113,6 @@ trait SyntheticMethods extends ast.TreeDSL {
(m0 ne meth) && !m0.isDeferred && !m0.isSynthetic && (m0.owner != AnyValClass) && (typeInClazz(m0) matches typeInClazz(meth))
}
}
def productIteratorMethod = {
createMethod(nme.productIterator, iteratorOfType(AnyTpe))(_ =>
gen.mkMethodCall(ScalaRunTimeModule, nme.typedProductIterator, List(AnyTpe), List(mkThis))
)
}

def perElementMethod(name: Name, returnType: Type)(caseFn: Symbol => Tree): Tree =
createSwitchMethod(name, accessors.indices, returnType)(idx => caseFn(accessors(idx)))
Expand Down Expand Up @@ -265,7 +259,6 @@ trait SyntheticMethods extends ast.TreeDSL {
Product_productPrefix -> (() => constantNullary(nme.productPrefix, clazz.name.decode)),
Product_productArity -> (() => constantNullary(nme.productArity, arity)),
Product_productElement -> (() => perElementMethod(nme.productElement, AnyTpe)(mkThisSelect)),
Product_iterator -> (() => productIteratorMethod),
Product_canEqual -> (() => canEqualMethod)
)
}
Expand Down
1 change: 0 additions & 1 deletion test/files/run/idempotency-case-classes.check
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ C(2,3)
case 1 => C.this.y
case _ => scala.runtime.Statics.ioobe[Any](x$1)
};
override <synthetic> def productIterator: Iterator[Any] = scala.runtime.ScalaRunTime.typedProductIterator[Any](C.this);
<synthetic> def canEqual(x$1: Any): Boolean = x$1.$isInstanceOf[C]();
override <synthetic> def productElementName(x$1: Int): String = x$1 match {
case 0 => "x"
Expand Down
1 change: 0 additions & 1 deletion test/files/scalap/caseClass.check
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ case class CaseClass[A <: scala.Seq[scala.Int]](i: A, s: scala.Predef.String) ex
override def productPrefix: java.lang.String = { /* compiled code */ }
def productArity: scala.Int = { /* compiled code */ }
def productElement(x$1: scala.Int): scala.Any = { /* compiled code */ }
override def productIterator: scala.collection.Iterator[scala.Any] = { /* compiled code */ }
def canEqual(x$1: scala.Any): scala.Boolean = { /* compiled code */ }
override def productElementName(x$1: scala.Int): java.lang.String = { /* compiled code */ }
override def hashCode(): scala.Int = { /* compiled code */ }
Expand Down
1 change: 0 additions & 1 deletion test/files/scalap/caseObject.check
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ case object CaseObject extends scala.AnyRef with scala.Product with scala.Serial
override def productPrefix: java.lang.String = { /* compiled code */ }
def productArity: scala.Int = { /* compiled code */ }
def productElement(x$1: scala.Int): scala.Any = { /* compiled code */ }
override def productIterator: scala.collection.Iterator[scala.Any] = { /* compiled code */ }
def canEqual(x$1: scala.Any): scala.Boolean = { /* compiled code */ }
override def hashCode(): scala.Int = { /* compiled code */ }
override def toString(): java.lang.String = { /* compiled code */ }
Expand Down
22 changes: 11 additions & 11 deletions test/scaladoc/run/implicits-chaining.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import scala.tools.nsc.doc.model._
import scala.tools.partest.ScaladocModelTest
import language._
import org.junit.Assert.{assertEquals, assertTrue}

object Test extends ScaladocModelTest {

Expand All @@ -23,43 +23,43 @@ object Test extends ScaladocModelTest {
val A = base._class("A")

conv = A._conversion(base.qualifiedName + ".convertToZ")
assert(conv.members.length == 2)
assert(conv.constraints.length == 1)
assertEquals(3, conv.members.length)
assertEquals(1, conv.constraints.length)

//// class B ///////////////////////////////////////////////////////////////////////////////////////////////////////////

val B = base._class("B")

conv = B._conversion(base.qualifiedName + ".convertToZ")
assert(conv.members.length == 2)
assert(conv.constraints.length == 0)
assertEquals(3, conv.members.length)
assertEquals(0, conv.constraints.length)

//// class C ///////////////////////////////////////////////////////////////////////////////////////////////////////////

val C = base._class("C")

assert(C._conversions(base.qualifiedName + ".convertToZ").isEmpty)
assertTrue(C._conversions(base.qualifiedName + ".convertToZ").isEmpty)

//// class D ///////////////////////////////////////////////////////////////////////////////////////////////////////////

val D = base._class("D")

conv = D._conversion(base.qualifiedName + ".convertToZ")
assert(conv.members.length == 2)
assert(conv.constraints.length == 0)
assertEquals(3, conv.members.length)
assertEquals(0, conv.constraints.length)

//// class E ///////////////////////////////////////////////////////////////////////////////////////////////////////////

val E = base._class("E")

conv = E._conversion(base.qualifiedName + ".convertToZ")
assert(conv.members.length == 2)
assert(conv.constraints.length == 0)
assertEquals(3, conv.members.length)
assertEquals(0, conv.constraints.length)

//// class F ///////////////////////////////////////////////////////////////////////////////////////////////////////////

val F = base._class("F")

assert(F._conversions(base.qualifiedName + ".convertToZ").isEmpty)
assertTrue(F._conversions(base.qualifiedName + ".convertToZ").isEmpty)
}
}