Skip to content

Commit b8c4908

Browse files
authored
Merge branch 'scala:main' into main
2 parents d99c1d0 + f2829c3 commit b8c4908

File tree

7 files changed

+133
-2
lines changed

7 files changed

+133
-2
lines changed

.github/workflows/publish-winget.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
###################################################################################################
2+
### THIS IS A REUSABLE WORKFLOW TO PUBLISH SCALA TO WINGET ###
3+
### HOW TO USE: ###
4+
### - THE RELEASE WORKFLOW SHOULD CALL THIS WORKFLOW ###
5+
### - IT WILL PUBLISH THE MSI TO WINGET ###
6+
### ###
7+
### NOTE: ###
8+
### - WE SHOULD KEEP IN SYNC THE https://github.com/dottybot/winget-pkgs REPOSITORY ###
9+
###################################################################################################
10+
11+
12+
name: Publish Scala to winget
13+
run-name: Publish Scala ${{ inputs.version }} to winget
14+
15+
on:
16+
workflow_call:
17+
inputs:
18+
version:
19+
required: true
20+
type: string
21+
secrets:
22+
DOTTYBOT-TOKEN:
23+
required: true
24+
25+
jobs:
26+
publish:
27+
runs-on: windows-latest
28+
steps:
29+
- uses: vedantmgoyal9/winget-releaser@b87a066d9e624db1394edcd947f8c4e5a7e30cd7
30+
with:
31+
identifier : Scala.Scala.3
32+
version : ${{ inputs.version }}
33+
installers-regex: '\.msi$'
34+
release-tag : ${{ inputs.version }}
35+
fork-user : dottybot
36+
token : ${{ secrets.DOTTYBOT-WINGET-TOKEN }}

.github/workflows/releases.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,12 @@ jobs:
2929
secrets:
3030
CONSUMER-KEY: ${{ secrets.SDKMAN_KEY }}
3131
CONSUMER-TOKEN: ${{ secrets.SDKMAN_TOKEN }}
32-
32+
33+
publish-winget:
34+
uses: ./.github/workflows/publish-winget.yml
35+
with:
36+
version: ${{ inputs.version }}
37+
secrets:
38+
DOTTYBOT-TOKEN: ${{ secrets.DOTTYBOT_WINGET_TOKEN }}
39+
3340
# TODO: ADD RELEASE WORKFLOW TO CHOCOLATEY AND OTHER PACKAGE MANAGERS HERE

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3544,6 +3544,8 @@ object Types extends TypeUtils {
35443544
else this match
35453545
case tp: OrType => OrType.make(tp1, tp2, tp.isSoft)
35463546
case tp: AndType => AndType.make(tp1, tp2, checkValid = true)
3547+
3548+
override def hashIsStable: Boolean = tp1.hashIsStable && tp2.hashIsStable
35473549
}
35483550

35493551
abstract case class AndType(tp1: Type, tp2: Type) extends AndOrType {
@@ -3589,6 +3591,10 @@ object Types extends TypeUtils {
35893591
case that: AndType => tp1.eq(that.tp1) && tp2.eq(that.tp2)
35903592
case _ => false
35913593
}
3594+
3595+
override protected def iso(that: Any, bs: BinderPairs) = that match
3596+
case that: AndType => tp1.equals(that.tp1, bs) && tp2.equals(that.tp2, bs)
3597+
case _ => false
35923598
}
35933599

35943600
final class CachedAndType(tp1: Type, tp2: Type) extends AndType(tp1, tp2)
@@ -3741,6 +3747,10 @@ object Types extends TypeUtils {
37413747
case that: OrType => tp1.eq(that.tp1) && tp2.eq(that.tp2) && isSoft == that.isSoft
37423748
case _ => false
37433749
}
3750+
3751+
override protected def iso(that: Any, bs: BinderPairs) = that match
3752+
case that: OrType => tp1.equals(that.tp1, bs) && tp2.equals(that.tp2, bs) && isSoft == that.isSoft
3753+
case _ => false
37443754
}
37453755

37463756
final class CachedOrType(tp1: Type, tp2: Type, override val isSoft: Boolean) extends OrType(tp1, tp2)

docs/_docs/reference/contextual/givens.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,45 @@ given (using config: Config): Factory = MemoizingFactory(config)
8888
An alias given can have type parameters and context parameters just like any other given,
8989
but it can only implement a single type.
9090

91+
## Abstract Givens
92+
93+
A given may be an abstract member, with the restriction that it must have an explicit name.
94+
95+
```scala
96+
trait HasOrd[T]:
97+
given ord: Ord[T]
98+
```
99+
100+
## More Structural Givens
101+
102+
If an alias given instance is analogous to a lazy val,
103+
and a structural given instance is analogous to an object,
104+
albeit an object with an explicit type,
105+
then a structural given may also be specified without an explicit type:
106+
107+
```scala
108+
class IntOrd extends Ord[Int]:
109+
def compare(x: Int, y: Int) =
110+
if x < y then -1 else if x > y then +1 else 0
111+
112+
given IntOrd()
113+
```
114+
115+
Compare this syntax to:
116+
117+
```scala
118+
object intOrd extends IntOrd()
119+
```
120+
121+
The empty parentheses are optional in the extends clause when defining a class,
122+
but are required when defining a given.
123+
124+
Further mixins are allowed as usual:
125+
126+
```scala
127+
given IntOrd() with OrdOps[Int]
128+
```
129+
91130
## Given Macros
92131

93132
Given aliases can have the `inline` and `transparent` modifiers.
@@ -191,4 +230,4 @@ of given instances:
191230
- A _structural instance_ contains one or more types or constructor applications,
192231
followed by `with` and a template body that contains member definitions of the instance.
193232
- An _alias instance_ contains a type, followed by `=` and a right-hand side expression.
194-
- An _abstract instance_ contains just the type, which is not followed by anything.
233+
- An _abstract instance_ contains just the name and type, which is not followed by anything.

tests/pos/i20858-min.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
type M[F[_,_]] = Int match
3+
case 0 => String & M[F]
4+
5+
type M1 = M[[x,y] =>> x | y]
6+
type M2 = M[[x,y] =>> x | y]
7+
8+
def Test: Unit =
9+
val x: M1 = ???
10+
val _: M2 = x // was error

tests/pos/i20858/defns_1.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import scala.compiletime.*
2+
import scala.deriving.*
3+
4+
sealed trait ZIO[-R, +E, +A]
5+
sealed abstract class ZLayer[-RIn, +E, +ROut]
6+
object ZLayer:
7+
def apply[RIn, E, ROut](zio: => ZIO[RIn, E, ROut]): ZLayer[RIn, E, ROut] = ???
8+
type URIO[-R, +A] = ZIO[R, Nothing, A]
9+
type IAnyType[T <: Tuple] = Tuple.Fold[T, Any, [x, y] =>> x & y]
10+
type UAnyType[T <: Tuple] = Tuple.Fold[T, Any, [x, y] =>> x | y]
11+
12+
13+
trait AutoLayer[A]:
14+
def zlayer(using
15+
p: Mirror.ProductOf[A]
16+
): ZLayer[IAnyType[p.MirroredElemTypes], Nothing, A]
17+
18+
object AutoLayer:
19+
inline given derived[A](using p: Mirror.ProductOf[A]): AutoLayer[A] = {
20+
val a: ZIO[IAnyType[p.MirroredElemTypes], Nothing, A] = ???
21+
new AutoLayer[A]:
22+
override def zlayer(using
23+
pp: Mirror.ProductOf[A]
24+
): ZLayer[IAnyType[pp.MirroredElemTypes], Nothing, A] = ZLayer {
25+
a.asInstanceOf[ZIO[IAnyType[pp.MirroredElemTypes], Nothing, A]]
26+
}
27+
}

tests/pos/i20858/usages_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
case class TestService(port: Int) derives AutoLayer // was error

0 commit comments

Comments
 (0)