Skip to content

Backport "Cancel stale CI executions when CI is re-triggered in the same branch/PR" to 3.3 LTS #120

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 1 commit into from
Mar 11, 2025
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
8 changes: 8 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ on:
- cron: '0 3 * * *' # Every day at 3 AM
workflow_dispatch:

# Cancels any in-progress runs within the same group identified by workflow name and GH reference (branch or tag)
# For example it would:
# - terminate previous PR CI execution after pushing more changes to the same PR branch
# - terminate previous on-push CI run after merging new PR to main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

env:
DOTTY_CI_RUN: true

Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/annot-crash.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- Error: tests/neg-macros/annot-crash/Test_2.scala:1:0 ----------------------------------------------------------------
1 |@crash // error
|^^^^^^
|Failed to evaluate macro annotation '@crash'.
|Failed to evaluate macro.
| Caused by class scala.NotImplementedError: an implementation is missing
| scala.Predef$.$qmark$qmark$qmark(Predef.scala:344)
| crash.transform(Macro_1.scala:7)
2 changes: 1 addition & 1 deletion tests/pos-macros/i20353/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end ImplicitValue

@experimental
class Test extends MacroAnnotation:
def transform(using Quotes)(definition: quotes.reflect.Definition, companion: Option[quotes.reflect.Definition]) =
def transform(using Quotes)(definition: quotes.reflect.Definition): List[quotes.reflect.Definition] =
import quotes.reflect.*
Implicits.search(TypeRepr.of[ImplicitValue])
List(definition)
6 changes: 6 additions & 0 deletions tests/pos-with-compiler/A.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import dotty.tools.dotc.core.Decorators.*
import dotty.tools.dotc.core.NameOps.*

object Test {
"JFunction".toTermName.specializedFor(Nil, ???, Nil, Nil)(using ???)
}
6 changes: 6 additions & 0 deletions tests/pos-with-compiler/B.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import dotty.tools.dotc.core.Contexts.Context

object Formatting {
def rainbows(implicit ctx: Context): String =
ctx.settings.color.value.toString
}
53 changes: 53 additions & 0 deletions tests/pos-with-compiler/Fileish.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Inspired by the original Fileish,
// testing combinations of lazy and non-lazy vals for their treatment in constructors
package dotty.tools
package io

import java.io.InputStream
import java.util.jar.JarEntry
import language.postfixOps

/** A common interface for File-based things and Stream-based things.
* (In particular, io.File and JarEntry.)
*/
class Fileish(val path: Path, val input: () => InputStream) extends Streamable.Chars {
def inputStream() = input()

def parent = path.parent
def name = path.name
def isSourceFile = path.hasExtension("java", "scala")

private lazy val pkgLines = lines() collect { case x if x startsWith "package " => x stripPrefix "package" trim }
lazy val pkgFromPath = parent.path.replaceAll("""[/\\]""", ".")
lazy val pkgFromSource = pkgLines map (_ stripSuffix ";") mkString "."

override def toString = path.path
}
class Fileish2(val path: Path, val input: () => InputStream) extends Streamable.Chars {
def inputStream() = input()

def parent = path.parent
def name = path.name
def isSourceFile = path.hasExtension("java", "scala")

private val pkgLines = lines() collect { case x if x startsWith "package " => x stripPrefix "package" trim }
lazy val pkgFromPath = parent.path.replaceAll("""[/\\]""", ".")
lazy val pkgFromSource = pkgLines map (_ stripSuffix ";") mkString "."

override def toString = path.path
}

class Fileish3(val path: Path, val input: () => InputStream) extends Streamable.Chars {
def inputStream() = input()

def parent = path.parent
def name = path.name
def isSourceFile = path.hasExtension("java", "scala")

private val pkgLines = lines() collect { case x if x startsWith "package " => x stripPrefix "package" trim }
private val pkgFromPath = parent.path.replaceAll("""[/\\]""", ".")
private val pkgFromSource = pkgLines map (_ stripSuffix ";") mkString "."

override def toString = path.path
}

38 changes: 38 additions & 0 deletions tests/pos-with-compiler/Labels.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import dotty.tools.dotc.ast.Trees.Thicket
import dotty.tools.dotc.ast.tpd.*


object Labels {
def main(args: Array[String]): Unit = {
var i = 10
while(i>0) {
var j = 0
while(j<i) {
println(j +" " + i)
j = j + 1
}
i = i - 1}
pattern(1)
pattern(2)
pattern(3)
}

def pattern(a: Int) = a match {
case 1 if (a>0) => println("one")
case t@2 => println("two" + t)
case _ => println("default")
}

def flatten(trees: Tree): Int = {
trees match {
case Thicket(elems) =>
while (trees ne trees) {
}
case tree =>
33
}
55
}


}
137 changes: 137 additions & 0 deletions tests/pos-with-compiler/Patterns.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import dotty.tools.dotc.ast.Trees.*
import dotty.tools.dotc.core.Types.*

object Patterns {
val d: Object = null
private def rebase(tp: NamedType): Type = {
def rebaseFrom(prefix: Type): Type = ???
tp.prefix match {
case SkolemType(rt) => rebaseFrom(rt)
case pre: ThisType => rebaseFrom(pre)
case _ => tp
}
}
d match {
case WildcardType(bounds: TypeBounds) => bounds.lo
case a @ Assign(Ident(id), rhs) => id
case a: Object => a
}

('1', "1") match {
case (digit, str) => true
case _ => false
}


def foo2(x: AnyRef) = x match { case x: Function0[Any] => x() }
object Breakdown {
def unapplySeq(x: Int): Some[List[String]] = Some(List("", "there"))
}

object Test2 {
42 match {
case a@Breakdown(f@"") => // needed to trigger bug
case b@Breakdown(d@"foo") => // needed to trigger bug
case c@Breakdown(e@"", who) => println ("hello " + who)
}
}

val names = List("a", "b", "c")
object SeqExtractors {
val y = names match {
case List(x, z) => x
case List(x) => x
case List() => ""
case x @ _ => "wildcard"
}
val yy: String = y
}



val xs = List('2' -> "ABC", '3' -> "DEF")

xs filter {
case (digit, str) => true
case _ => false
}

(xs: Any) match {
case x: Int @unchecked => true
case xs: List[Int @ unchecked] => true
case _ => false
}

def sum(xs: List[Int]): Int = xs match {
case Nil => 0
case x :: xs1 => x + sum(xs1)
}

def len[T](xs: List[T]): Int = xs match {
case _ :: xs1 => 1 + len(xs1)
case Nil => 0
}

final def sameLength[T](xs: List[T], ys: List[T]): Boolean = xs match {
case _ :: xs1 => xs1.isEmpty
ys match {
case _ :: ys1 => sameLength(xs1, ys1)
case _ => false
}
case _ => ys.isEmpty
}

class A{
class B
}
val a1 = new A
val a2 = new A
d match {
case t: a1.B =>
t
case t: a2.B =>
t
}

class caseWithPatternVariableHelper1[A]
class caseWithPatternVariableHelper2[A]

def caseWithPatternVariable(x: Any) = x match {
case a: caseWithPatternVariableHelper1[_] => ()
case b: caseWithPatternVariableHelper2[_] => ()
}

}

object NestedPattern {
val xss: List[List[String]] = ???
val List(List(x)) = xss
}

// Tricky case (exercised by Scala parser combinators) where we use
// both get/isEmpty and product-based pattern matching in different
// matches on the same types.
object ProductAndGet {

trait Result[+T]
case class Success[+T](in: String, x: T) extends Result[T] {
def isEmpty = false
def get: T = x
}
case class Failure[+T](in: String, msg: String) extends Result[T] {
def isEmpty = false
def get: String = msg
}

val r: Result[Int] = ???

r match {
case Success(in, x) => x
case Failure(in, msg) => -1
}

r match {
case Success(x) => x
case Failure(msg) => -1
}
}
Loading
Loading