Skip to content

Workaround LazyRef CyclicReference in genDocs #8077

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
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
6 changes: 4 additions & 2 deletions library/src/scala/internal/quoted/Matcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,11 @@ private[quoted] object Matcher {
if (hasBindAnnotation(pattern.symbol)) bindingMatch(scrutinee.symbol)
else matched
def rhsEnv =
summon[Env] + (scrutinee.symbol -> pattern.symbol) ++
typeParams1.zip(typeParams2).map((tparam1, tparam2) => tparam1.symbol -> tparam2.symbol) ++
val oldEnv: Env = summon[Env]
val newEnv: List[(Symbol, Symbol)] =
(scrutinee.symbol -> pattern.symbol) :: typeParams1.zip(typeParams2).map((tparam1, tparam2) => tparam1.symbol -> tparam2.symbol) :::
paramss1.flatten.zip(paramss2.flatten).map((param1, param2) => param1.symbol -> param2.symbol)
oldEnv ++ newEnv

bindMatch &&
typeParams1 =?= typeParams2 &&
Expand Down
8 changes: 4 additions & 4 deletions library/src/scala/quoted/unsafe/UnsafeExpr.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,23 @@ object UnsafeExpr {
*/
def open[T1, R, X](f: Expr[T1 => R])(content: (Expr[R], [t] => Expr[t] => Expr[T1] => Expr[t]) => X)(given qctx: QuoteContext): X = {
import qctx.tasty.{given, _}
val (params, bodyExpr) = paramsAndBody(f)
val (params, bodyExpr) = paramsAndBody[R](f)
content(bodyExpr, [t] => (e: Expr[t]) => (v: Expr[T1]) => bodyFn[t](e.unseal, params, List(v.unseal)).seal.asInstanceOf[Expr[t]])
}

def open[T1, T2, R, X](f: Expr[(T1, T2) => R])(content: (Expr[R], [t] => Expr[t] => (Expr[T1], Expr[T2]) => Expr[t]) => X)(given qctx: QuoteContext)(given DummyImplicit): X = {
import qctx.tasty.{given, _}
val (params, bodyExpr) = paramsAndBody(f)
val (params, bodyExpr) = paramsAndBody[R](f)
content(bodyExpr, [t] => (e: Expr[t]) => (v1: Expr[T1], v2: Expr[T2]) => bodyFn[t](e.unseal, params, List(v1.unseal, v2.unseal)).seal.asInstanceOf[Expr[t]])
}

def open[T1, T2, T3, R, X](f: Expr[(T1, T2, T3) => R])(content: (Expr[R], [t] => Expr[t] => (Expr[T1], Expr[T2], Expr[T3]) => Expr[t]) => X)(given qctx: QuoteContext)(given DummyImplicit, DummyImplicit): X = {
import qctx.tasty.{given, _}
val (params, bodyExpr) = paramsAndBody(f)
val (params, bodyExpr) = paramsAndBody[R](f)
content(bodyExpr, [t] => (e: Expr[t]) => (v1: Expr[T1], v2: Expr[T2], v3: Expr[T3]) => bodyFn[t](e.unseal, params, List(v1.unseal, v2.unseal, v3.unseal)).seal.asInstanceOf[Expr[t]])
}

private def paramsAndBody[R](given qctx: QuoteContext)(f: Expr[Any]) = {
private def paramsAndBody[R](given qctx: QuoteContext)(f: Expr[Any]): (List[qctx.tasty.ValDef], Expr[R]) = {
import qctx.tasty.{given, _}
val Block(List(DefDef("$anonfun", Nil, List(params), _, Some(body))), Closure(Ident("$anonfun"), None)) = f.unseal.etaExpand
(params, body.seal.asInstanceOf[Expr[R]])
Expand Down
37 changes: 19 additions & 18 deletions library/src/scala/runtime/DynamicTuple.scala
Original file line number Diff line number Diff line change
Expand Up @@ -274,31 +274,29 @@ object DynamicTuple {
def dynamicConcat[This <: Tuple, That <: Tuple](self: This, that: That): Concat[This, That] = {
type Result = Concat[This, That]

val selfSize: Int = self.size
// If one of the tuples is empty, we can leave early
(self: Any) match {
case self: Unit => return that.asInstanceOf[Result]
case _ =>
}
if selfSize == 0 then
return that.asInstanceOf[Result]

(that: Any) match {
case that: Unit => return self.asInstanceOf[Result]
case _ =>
}
val thatSize: Int = that.size
if thatSize == 0 then
return self.asInstanceOf[Result]

val arr = new Array[Object](self.size + that.size)
val arr = new Array[Object](selfSize + thatSize)

// Copies the tuple to an array, at the given offset
inline def copyToArray[T <: Tuple](tuple: T, array: Array[Object], offset: Int): Unit = (tuple: Any) match {
inline def copyToArray[T <: Tuple](tuple: T, size: Int, array: Array[Object], offset: Int): Unit = (tuple: Any) match {
case xxl: TupleXXL =>
System.arraycopy(xxl.elems, 0, array, offset, tuple.size)
System.arraycopy(xxl.elems, 0, array, offset, size)
case _ =>
tuple.asInstanceOf[Product].productIterator.asInstanceOf[Iterator[Object]]
.copyToArray(array, offset, tuple.size)
.copyToArray(array, offset, size)
}

// In the general case, we copy the two tuples to an array, and convert it back to a tuple
copyToArray(self, arr, 0)
copyToArray(that, arr, self.size)
copyToArray(self, selfSize, arr, 0)
copyToArray(that, thatSize, arr, selfSize)
dynamicFromIArray[Result](arr.asInstanceOf[IArray[Object]])
}

Expand Down Expand Up @@ -401,9 +399,11 @@ object DynamicTuple {
}

def dynamicZip[This <: Tuple, T2 <: Tuple](t1: This, t2: T2): Zip[This, T2] = {
if (t1.size == 0 || t2.size == 0) return ().asInstanceOf[Zip[This, T2]]
val size = Math.min(t1.size, t2.size)
Tuple.fromIArray(
val t1Size: Int = t1.size
val t2Size: Int = t2.size
val size = Math.min(t1Size, t2Size)
if size == 0 then ().asInstanceOf[Zip[This, T2]]
else Tuple.fromIArray(
zipIterators(
t1.asInstanceOf[Product].productIterator,
t2.asInstanceOf[Product].productIterator,
Expand Down Expand Up @@ -475,7 +475,8 @@ object DynamicTuple {

def dynamicTake[This <: Tuple, N <: Int](self: This, n: N): Take[This, N] = {
if (n < 0) throw new IndexOutOfBoundsException(n.toString)
val actualN = Math.min(n, self.size)
val selfSize: Int = self.size
val actualN = Math.min(n, selfSize)

type Result = Take[This, N]

Expand Down