Skip to content

Add init and last methods to NonEmptyTuple #13735

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
merged 8 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Mark NonEmptyTuple.{init|last} as experimental
  • Loading branch information
danicheg committed Oct 13, 2021
commit 809d7b769a4700d79093b454ced0bf9cb15cb276
5 changes: 4 additions & 1 deletion library/src/scala/Tuple.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package scala
import annotation.showAsInfix

import annotation.{experimental, showAsInfix}
import compiletime._
import compiletime.ops.int._

Expand Down Expand Up @@ -299,10 +300,12 @@ sealed trait NonEmptyTuple extends Tuple {
runtime.Tuples.apply(this, 0).asInstanceOf[Head[This]]

/** Get the initial part of the tuple without its last element */
@experimental
inline def init[This >: this.type <: NonEmptyTuple]: Init[This] =
runtime.Tuples.init(this).asInstanceOf[Init[This]]

/** Get the last of this tuple */
@experimental
inline def last[This >: this.type <: NonEmptyTuple]: Last[This] =
runtime.Tuples.last(this).asInstanceOf[Last[This]]

Expand Down
13 changes: 6 additions & 7 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import java.nio.file._

import Modes._
import com.jsuereth.sbtpgp.PgpKeys
import com.typesafe.tools.mima.core.{DirectMissingMethodProblem, ProblemFilters}
import sbt.Keys._
import sbt._
import complete.DefaultParsers._
Expand All @@ -14,20 +15,15 @@ import sbt.ScriptedPlugin.autoImport._
import xerial.sbt.pack.PackPlugin
import xerial.sbt.pack.PackPlugin.autoImport._
import xerial.sbt.Sonatype.autoImport._

import com.typesafe.tools.mima.plugin.MimaPlugin.autoImport._

import dotty.tools.sbtplugin.DottyIDEPlugin.{ installCodeExtension, prepareCommand, runProcess }
import dotty.tools.sbtplugin.DottyIDEPlugin.{installCodeExtension, prepareCommand, runProcess}
import dotty.tools.sbtplugin.DottyIDEPlugin.autoImport._

import org.scalajs.sbtplugin.ScalaJSPlugin
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._

import sbtbuildinfo.BuildInfoPlugin
import sbtbuildinfo.BuildInfoPlugin.autoImport._

import scala.util.Properties.isJavaAtLeast

import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._

object DottyJSPlugin extends AutoPlugin {
Expand Down Expand Up @@ -1781,7 +1777,10 @@ object Build {
(Compile/doc/target).value
},
commonMiMaSettings,
mimaBinaryIssueFilters ++= MiMaFilters.Library,
mimaBinaryIssueFilters ++= MiMaFilters.Library ++ Seq(
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.runtime.Tuples.init"),
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.runtime.Tuples.last")
)
)
} else base
}
Expand Down