Skip to content

Commit c4a7bb8

Browse files
authored
Merge pull request #120 from scala/backport-lts-3.3-21974
Backport "Cancel stale CI executions when CI is re-triggered in the same branch/PR" to 3.3 LTS
2 parents 6d4a6c5 + f3ec3de commit c4a7bb8

File tree

12 files changed

+930
-2
lines changed

12 files changed

+930
-2
lines changed

Diff for: .github/workflows/ci.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ on:
2727
- cron: '0 3 * * *' # Every day at 3 AM
2828
workflow_dispatch:
2929

30+
# Cancels any in-progress runs within the same group identified by workflow name and GH reference (branch or tag)
31+
# For example it would:
32+
# - terminate previous PR CI execution after pushing more changes to the same PR branch
33+
# - terminate previous on-push CI run after merging new PR to main
34+
concurrency:
35+
group: ${{ github.workflow }}-${{ github.ref }}
36+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
37+
3038
env:
3139
DOTTY_CI_RUN: true
3240

Diff for: tests/neg-macros/annot-crash.check

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- Error: tests/neg-macros/annot-crash/Test_2.scala:1:0 ----------------------------------------------------------------
33
1 |@crash // error
44
|^^^^^^
5-
|Failed to evaluate macro annotation '@crash'.
5+
|Failed to evaluate macro.
66
| Caused by class scala.NotImplementedError: an implementation is missing
77
| scala.Predef$.$qmark$qmark$qmark(Predef.scala:344)
88
| crash.transform(Macro_1.scala:7)

Diff for: tests/pos-macros/i20353/Macro_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ end ImplicitValue
1616

1717
@experimental
1818
class Test extends MacroAnnotation:
19-
def transform(using Quotes)(definition: quotes.reflect.Definition, companion: Option[quotes.reflect.Definition]) =
19+
def transform(using Quotes)(definition: quotes.reflect.Definition): List[quotes.reflect.Definition] =
2020
import quotes.reflect.*
2121
Implicits.search(TypeRepr.of[ImplicitValue])
2222
List(definition)

Diff for: tests/pos-with-compiler/A.scala

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import dotty.tools.dotc.core.Decorators.*
2+
import dotty.tools.dotc.core.NameOps.*
3+
4+
object Test {
5+
"JFunction".toTermName.specializedFor(Nil, ???, Nil, Nil)(using ???)
6+
}

Diff for: tests/pos-with-compiler/B.scala

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import dotty.tools.dotc.core.Contexts.Context
2+
3+
object Formatting {
4+
def rainbows(implicit ctx: Context): String =
5+
ctx.settings.color.value.toString
6+
}

Diff for: tests/pos-with-compiler/Fileish.scala

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Inspired by the original Fileish,
2+
// testing combinations of lazy and non-lazy vals for their treatment in constructors
3+
package dotty.tools
4+
package io
5+
6+
import java.io.InputStream
7+
import java.util.jar.JarEntry
8+
import language.postfixOps
9+
10+
/** A common interface for File-based things and Stream-based things.
11+
* (In particular, io.File and JarEntry.)
12+
*/
13+
class Fileish(val path: Path, val input: () => InputStream) extends Streamable.Chars {
14+
def inputStream() = input()
15+
16+
def parent = path.parent
17+
def name = path.name
18+
def isSourceFile = path.hasExtension("java", "scala")
19+
20+
private lazy val pkgLines = lines() collect { case x if x startsWith "package " => x stripPrefix "package" trim }
21+
lazy val pkgFromPath = parent.path.replaceAll("""[/\\]""", ".")
22+
lazy val pkgFromSource = pkgLines map (_ stripSuffix ";") mkString "."
23+
24+
override def toString = path.path
25+
}
26+
class Fileish2(val path: Path, val input: () => InputStream) extends Streamable.Chars {
27+
def inputStream() = input()
28+
29+
def parent = path.parent
30+
def name = path.name
31+
def isSourceFile = path.hasExtension("java", "scala")
32+
33+
private val pkgLines = lines() collect { case x if x startsWith "package " => x stripPrefix "package" trim }
34+
lazy val pkgFromPath = parent.path.replaceAll("""[/\\]""", ".")
35+
lazy val pkgFromSource = pkgLines map (_ stripSuffix ";") mkString "."
36+
37+
override def toString = path.path
38+
}
39+
40+
class Fileish3(val path: Path, val input: () => InputStream) extends Streamable.Chars {
41+
def inputStream() = input()
42+
43+
def parent = path.parent
44+
def name = path.name
45+
def isSourceFile = path.hasExtension("java", "scala")
46+
47+
private val pkgLines = lines() collect { case x if x startsWith "package " => x stripPrefix "package" trim }
48+
private val pkgFromPath = parent.path.replaceAll("""[/\\]""", ".")
49+
private val pkgFromSource = pkgLines map (_ stripSuffix ";") mkString "."
50+
51+
override def toString = path.path
52+
}
53+

Diff for: tests/pos-with-compiler/Labels.scala

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import dotty.tools.dotc.ast.Trees.Thicket
2+
import dotty.tools.dotc.ast.tpd.*
3+
4+
5+
object Labels {
6+
def main(args: Array[String]): Unit = {
7+
var i = 10
8+
while(i>0) {
9+
var j = 0
10+
while(j<i) {
11+
println(j +" " + i)
12+
j = j + 1
13+
}
14+
i = i - 1}
15+
pattern(1)
16+
pattern(2)
17+
pattern(3)
18+
}
19+
20+
def pattern(a: Int) = a match {
21+
case 1 if (a>0) => println("one")
22+
case t@2 => println("two" + t)
23+
case _ => println("default")
24+
}
25+
26+
def flatten(trees: Tree): Int = {
27+
trees match {
28+
case Thicket(elems) =>
29+
while (trees ne trees) {
30+
}
31+
case tree =>
32+
33
33+
}
34+
55
35+
}
36+
37+
38+
}

Diff for: tests/pos-with-compiler/Patterns.scala

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import dotty.tools.dotc.ast.Trees.*
2+
import dotty.tools.dotc.core.Types.*
3+
4+
object Patterns {
5+
val d: Object = null
6+
private def rebase(tp: NamedType): Type = {
7+
def rebaseFrom(prefix: Type): Type = ???
8+
tp.prefix match {
9+
case SkolemType(rt) => rebaseFrom(rt)
10+
case pre: ThisType => rebaseFrom(pre)
11+
case _ => tp
12+
}
13+
}
14+
d match {
15+
case WildcardType(bounds: TypeBounds) => bounds.lo
16+
case a @ Assign(Ident(id), rhs) => id
17+
case a: Object => a
18+
}
19+
20+
('1', "1") match {
21+
case (digit, str) => true
22+
case _ => false
23+
}
24+
25+
26+
def foo2(x: AnyRef) = x match { case x: Function0[Any] => x() }
27+
object Breakdown {
28+
def unapplySeq(x: Int): Some[List[String]] = Some(List("", "there"))
29+
}
30+
31+
object Test2 {
32+
42 match {
33+
case a@Breakdown(f@"") => // needed to trigger bug
34+
case b@Breakdown(d@"foo") => // needed to trigger bug
35+
case c@Breakdown(e@"", who) => println ("hello " + who)
36+
}
37+
}
38+
39+
val names = List("a", "b", "c")
40+
object SeqExtractors {
41+
val y = names match {
42+
case List(x, z) => x
43+
case List(x) => x
44+
case List() => ""
45+
case x @ _ => "wildcard"
46+
}
47+
val yy: String = y
48+
}
49+
50+
51+
52+
val xs = List('2' -> "ABC", '3' -> "DEF")
53+
54+
xs filter {
55+
case (digit, str) => true
56+
case _ => false
57+
}
58+
59+
(xs: Any) match {
60+
case x: Int @unchecked => true
61+
case xs: List[Int @ unchecked] => true
62+
case _ => false
63+
}
64+
65+
def sum(xs: List[Int]): Int = xs match {
66+
case Nil => 0
67+
case x :: xs1 => x + sum(xs1)
68+
}
69+
70+
def len[T](xs: List[T]): Int = xs match {
71+
case _ :: xs1 => 1 + len(xs1)
72+
case Nil => 0
73+
}
74+
75+
final def sameLength[T](xs: List[T], ys: List[T]): Boolean = xs match {
76+
case _ :: xs1 => xs1.isEmpty
77+
ys match {
78+
case _ :: ys1 => sameLength(xs1, ys1)
79+
case _ => false
80+
}
81+
case _ => ys.isEmpty
82+
}
83+
84+
class A{
85+
class B
86+
}
87+
val a1 = new A
88+
val a2 = new A
89+
d match {
90+
case t: a1.B =>
91+
t
92+
case t: a2.B =>
93+
t
94+
}
95+
96+
class caseWithPatternVariableHelper1[A]
97+
class caseWithPatternVariableHelper2[A]
98+
99+
def caseWithPatternVariable(x: Any) = x match {
100+
case a: caseWithPatternVariableHelper1[_] => ()
101+
case b: caseWithPatternVariableHelper2[_] => ()
102+
}
103+
104+
}
105+
106+
object NestedPattern {
107+
val xss: List[List[String]] = ???
108+
val List(List(x)) = xss
109+
}
110+
111+
// Tricky case (exercised by Scala parser combinators) where we use
112+
// both get/isEmpty and product-based pattern matching in different
113+
// matches on the same types.
114+
object ProductAndGet {
115+
116+
trait Result[+T]
117+
case class Success[+T](in: String, x: T) extends Result[T] {
118+
def isEmpty = false
119+
def get: T = x
120+
}
121+
case class Failure[+T](in: String, msg: String) extends Result[T] {
122+
def isEmpty = false
123+
def get: String = msg
124+
}
125+
126+
val r: Result[Int] = ???
127+
128+
r match {
129+
case Success(in, x) => x
130+
case Failure(in, msg) => -1
131+
}
132+
133+
r match {
134+
case Success(x) => x
135+
case Failure(msg) => -1
136+
}
137+
}

0 commit comments

Comments
 (0)