From 36146eb6f7c5090a2be81df1164a07af1d5a5fd3 Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Fri, 28 Jun 2024 18:00:23 +0200 Subject: [PATCH 1/5] Stabilise SIP-47 --- .../src/dotty/tools/dotc/config/Feature.scala | 3 +- .../dotty/tools/dotc/parsing/Parsers.scala | 7 +---- .../generalized-method-syntax.md | 10 ++----- .../runtime/stdLibPatches/language.scala | 1 + .../SignatureHelpInterleavingSuite.scala | 3 -- .../src/tests/extensionParams.scala | 2 -- .../src/tests/methodsAndConstructors.scala | 2 -- tests/neg/interleaving-ab.scala | 3 +- tests/neg/interleaving-params.scala | 1 - .../neg/interleaving-signatureCollision.scala | 1 - tests/neg/interleaving-typeApply.check | 28 +++++++++---------- tests/neg/interleaving-typeApply.scala | 3 +- tests/neg/interleaving-unmatched.scala | 1 - tests/neg/interleavingExperimental.check | 4 +++ tests/neg/interleavingExperimental.scala | 3 ++ tests/neg/namedTypeParams.check | 8 +++--- tests/neg/namedTypeParams.scala | 1 - tests/neg/overrides.scala | 6 ---- tests/pos/interleaving-ba.scala | 1 - tests/pos/interleaving-chainedParams.scala | 1 - tests/pos/interleaving-classless.scala | 1 - tests/pos/interleaving-functor.scala | 1 - tests/pos/interleaving-newline.scala | 1 - tests/pos/interleaving-overload.scala | 1 - tests/pos/interleaving-params.scala | 1 - .../pos/interleaving-signatureCollision.scala | 1 - tests/pos/interleaving-typeApply.scala | 2 -- tests/pos/interleavingExperimental.scala | 5 ++++ tests/pos/namedTypeParams.scala | 1 - tests/pos/overrides.scala | 5 ---- tests/run/interleaving.scala | 1 - 31 files changed, 38 insertions(+), 71 deletions(-) rename docs/_docs/reference/{experimental => other-new-features}/generalized-method-syntax.md (92%) create mode 100644 tests/neg/interleavingExperimental.check create mode 100644 tests/neg/interleavingExperimental.scala create mode 100644 tests/pos/interleavingExperimental.scala diff --git a/compiler/src/dotty/tools/dotc/config/Feature.scala b/compiler/src/dotty/tools/dotc/config/Feature.scala index c04c58b419c9..fed67b380092 100644 --- a/compiler/src/dotty/tools/dotc/config/Feature.scala +++ b/compiler/src/dotty/tools/dotc/config/Feature.scala @@ -121,7 +121,8 @@ object Feature: def namedTypeArgsEnabled(using Context) = enabled(namedTypeArguments) - def clauseInterleavingEnabled(using Context) = enabled(clauseInterleaving) + def clauseInterleavingEnabled(using Context) = + sourceVersion.isAtLeast(`3.6`) || enabled(clauseInterleaving) def genericNumberLiteralsEnabled(using Context) = enabled(genericNumberLiterals) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 4c13934f3473..07fb97191f2d 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -3836,9 +3836,6 @@ object Parsers { /** DefDef ::= DefSig [‘:’ Type] [‘=’ Expr] * | this TypelessClauses [DefImplicitClause] `=' ConstrExpr - * DefSig ::= id [DefTypeParamClause] DefTermParamClauses - * - * if clauseInterleaving is enabled: * DefSig ::= id [DefParamClauses] [DefImplicitClause] */ def defDefOrDcl(start: Offset, mods: Modifiers, numLeadParams: Int = 0): DefDef = atSpan(start, nameStart) { @@ -3878,13 +3875,11 @@ object Parsers { val ident = termIdent() var name = ident.name.asTermName val paramss = - if in.featureEnabled(Feature.clauseInterleaving) then - // If you are making interleaving stable manually, please refer to the PR introducing it instead, section "How to make non-experimental" + if Feature.clauseInterleavingEnabled(using in.languageImportContext) then typeOrTermParamClauses(ParamOwner.Def, numLeadParams) else val tparams = typeParamClauseOpt(ParamOwner.Def) val vparamss = termParamClauses(ParamOwner.Def, numLeadParams) - joinParams(tparams, vparamss) var tpt = fromWithinReturnType { typedOpt() } diff --git a/docs/_docs/reference/experimental/generalized-method-syntax.md b/docs/_docs/reference/other-new-features/generalized-method-syntax.md similarity index 92% rename from docs/_docs/reference/experimental/generalized-method-syntax.md rename to docs/_docs/reference/other-new-features/generalized-method-syntax.md index 072052c1ae10..2dd537cacdd8 100644 --- a/docs/_docs/reference/experimental/generalized-method-syntax.md +++ b/docs/_docs/reference/other-new-features/generalized-method-syntax.md @@ -1,15 +1,9 @@ --- layout: doc-page title: "Generalized Method Syntax" -nightlyOf: https://docs.scala-lang.org/scala3/reference/experimental/generalized-method-syntax.html +nightlyOf: https://docs.scala-lang.org/scala3/reference/other-new-features/generalized-method-syntax.html --- -This feature is not yet part of the Scala 3 language definition. It can be made available by a language import: - -```scala -import scala.language.experimental.clauseInterleaving -``` - The inclusion of using clauses is not the only way in which methods have been updated, type parameter clauses are now allowed in any number and at any position. ## Syntax Changes @@ -51,7 +45,7 @@ trait DB { } ``` -Note that simply replacing `V` by `k.Value` would not be equivalent. For example, if `k.Value` is `Some[Int]`, only the above allows: +Note that simply replacing `V` by `k.Value` would not be equivalent. For example, if `k.Value` is `Some[Int]`, only the above allows: `getOrElse(k)[Option[Int]](None)`, which returns a `Number`. ## Details diff --git a/library/src/scala/runtime/stdLibPatches/language.scala b/library/src/scala/runtime/stdLibPatches/language.scala index d89bd9dcf72e..6272970ab0ed 100644 --- a/library/src/scala/runtime/stdLibPatches/language.scala +++ b/library/src/scala/runtime/stdLibPatches/language.scala @@ -67,6 +67,7 @@ object language: * @see [[https://github.com/scala/improvement-proposals/blob/main/content/clause-interleaving.md]] */ @compileTimeOnly("`clauseInterleaving` can only be used at compile time in import statements") + @deprecated("`clauseInterleaving` is now standard, no language import is needed", since = "3.6") object clauseInterleaving /** Experimental support for pure function type syntax diff --git a/presentation-compiler/test/dotty/tools/pc/tests/signaturehelp/SignatureHelpInterleavingSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/signaturehelp/SignatureHelpInterleavingSuite.scala index 15546d086033..735a2eb13fab 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/signaturehelp/SignatureHelpInterleavingSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/signaturehelp/SignatureHelpInterleavingSuite.scala @@ -8,9 +8,6 @@ import java.nio.file.Path class SignatureHelpInterleavingSuite extends BaseSignatureHelpSuite: - override protected def scalacOptions(classpath: Seq[Path]): Seq[String] = - List("-language:experimental.clauseInterleaving") - @Test def `proper-position-1` = check( """ diff --git a/scaladoc-testcases/src/tests/extensionParams.scala b/scaladoc-testcases/src/tests/extensionParams.scala index 0e2225d8aa3c..12850778c793 100644 --- a/scaladoc-testcases/src/tests/extensionParams.scala +++ b/scaladoc-testcases/src/tests/extensionParams.scala @@ -61,8 +61,6 @@ extension (using Unit)(a: Int) def f14(): Any = ??? -import scala.language.experimental.clauseInterleaving - extension (using String)(using Int)(a: Animal)(using Unit)(using Number) def f16(b: Any)[T](c: T): T = ??? diff --git a/scaladoc-testcases/src/tests/methodsAndConstructors.scala b/scaladoc-testcases/src/tests/methodsAndConstructors.scala index cddd0f56e9fe..b4c354d174c4 100644 --- a/scaladoc-testcases/src/tests/methodsAndConstructors.scala +++ b/scaladoc-testcases/src/tests/methodsAndConstructors.scala @@ -1,7 +1,5 @@ package tests.methodsAndConstructors -import scala.language.experimental.clauseInterleaving - class A class B extends A class C diff --git a/tests/neg/interleaving-ab.scala b/tests/neg/interleaving-ab.scala index e446626a2982..afdb2f0a192f 100644 --- a/tests/neg/interleaving-ab.scala +++ b/tests/neg/interleaving-ab.scala @@ -1,11 +1,10 @@ -import scala.language.experimental.clauseInterleaving object Ab: given String = "" given Double = 0 def illegal[A][B](x: A)(using B): B = summon[B] // error: Type parameter lists must be separated by a term or using parameter list - + def ab[A](x: A)[B](using B): B = summon[B] def test = ab[Int](0: Int) // error diff --git a/tests/neg/interleaving-params.scala b/tests/neg/interleaving-params.scala index dc6762cf0214..20f6bbb98d3d 100644 --- a/tests/neg/interleaving-params.scala +++ b/tests/neg/interleaving-params.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving class Params{ def bar[T](x: T)[T]: String = ??? // error diff --git a/tests/neg/interleaving-signatureCollision.scala b/tests/neg/interleaving-signatureCollision.scala index a6a729ed3b62..096073e7bda8 100644 --- a/tests/neg/interleaving-signatureCollision.scala +++ b/tests/neg/interleaving-signatureCollision.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object signatureCollision: def f[T](x: T)[U](y: U) = (x,y) diff --git a/tests/neg/interleaving-typeApply.check b/tests/neg/interleaving-typeApply.check index a50c1455bfbb..ca2ab6fa3f3e 100644 --- a/tests/neg/interleaving-typeApply.check +++ b/tests/neg/interleaving-typeApply.check @@ -1,29 +1,29 @@ --- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:10:11 -------------------------------------------- -10 | f3[String]() // error - | ^ - | Type argument String does not conform to upper bound Int - | - | longer explanation available when compiling with `-explain` --- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:11:16 -------------------------------------------- -11 | f5[Int][Unit] // error +-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:9:11 --------------------------------------------- +9 | f3[String]() // error + | ^ + | Type argument String does not conform to upper bound Int + | + | longer explanation available when compiling with `-explain` +-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:10:16 -------------------------------------------- +10 | f5[Int][Unit] // error | ^ | Type argument Unit does not conform to upper bound String | | longer explanation available when compiling with `-explain` --- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:12:19 -------------------------------------------- -12 | f5[String][Unit] // error // error +-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:11:19 -------------------------------------------- +11 | f5[String][Unit] // error // error | ^ | Type argument Unit does not conform to upper bound String | | longer explanation available when compiling with `-explain` --- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:12:11 -------------------------------------------- -12 | f5[String][Unit] // error // error +-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:11:11 -------------------------------------------- +11 | f5[String][Unit] // error // error | ^ | Type argument String does not conform to upper bound Int | | longer explanation available when compiling with `-explain` --- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:13:11 -------------------------------------------- -13 | f7[String]()[Unit] // error +-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:12:11 -------------------------------------------- +12 | f7[String]()[Unit] // error | ^ | Type argument String does not conform to upper bound Int | diff --git a/tests/neg/interleaving-typeApply.scala b/tests/neg/interleaving-typeApply.scala index ad21fe2f0329..5ad6e3dc148e 100644 --- a/tests/neg/interleaving-typeApply.scala +++ b/tests/neg/interleaving-typeApply.scala @@ -1,7 +1,6 @@ -import scala.language.experimental.clauseInterleaving object typeApply: - + def f3[T <: Int](using DummyImplicit)[U <: String](): T => T = ??? def f5[T <: Int](using DummyImplicit)[U <: String]: [X <: Unit] => X => X = ??? def f7[T <: Int](using DummyImplicit)[U <: String]()[X <: Unit]: X => X = ??? diff --git a/tests/neg/interleaving-unmatched.scala b/tests/neg/interleaving-unmatched.scala index 2ce3074d07fa..3a4371798a50 100644 --- a/tests/neg/interleaving-unmatched.scala +++ b/tests/neg/interleaving-unmatched.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object unmatched: def f1[T (x: T)] = ??? // error diff --git a/tests/neg/interleavingExperimental.check b/tests/neg/interleavingExperimental.check new file mode 100644 index 000000000000..a5e10506bdc3 --- /dev/null +++ b/tests/neg/interleavingExperimental.check @@ -0,0 +1,4 @@ +-- [E040] Syntax Error: tests/neg/interleavingExperimental.scala:3:15 -------------------------------------------------- +3 |def ba[A](x: A)[B](using B): B = summon[B] // error: clauseInterleaving was experimental until 3.6 + | ^ + | '=' expected, but '[' found diff --git a/tests/neg/interleavingExperimental.scala b/tests/neg/interleavingExperimental.scala new file mode 100644 index 000000000000..ed13707fcb68 --- /dev/null +++ b/tests/neg/interleavingExperimental.scala @@ -0,0 +1,3 @@ +//> using options --source 3.5 + +def ba[A](x: A)[B](using B): B = summon[B] // error: clauseInterleaving was experimental until 3.6 diff --git a/tests/neg/namedTypeParams.check b/tests/neg/namedTypeParams.check index 5e0672f20f25..f203f482d117 100644 --- a/tests/neg/namedTypeParams.check +++ b/tests/neg/namedTypeParams.check @@ -92,11 +92,11 @@ | illegal repeated type application | You might have meant something like: | Test.f[Y = String, Int] --- [E102] Syntax Error: tests/neg/namedTypeParams.scala:33:9 ----------------------------------------------------------- -33 | f2[Y = String][X = Int](1, "") // error: Y is undefined +-- [E102] Syntax Error: tests/neg/namedTypeParams.scala:32:9 ----------------------------------------------------------- +32 | f2[Y = String][X = Int](1, "") // error: Y is undefined | ^^^^^^ | Type parameter Y is undefined. Expected one of X. --- [E102] Syntax Error: tests/neg/namedTypeParams.scala:34:9 ----------------------------------------------------------- -34 | f2[Y = String](1, "") // error: Y is undefined +-- [E102] Syntax Error: tests/neg/namedTypeParams.scala:33:9 ----------------------------------------------------------- +33 | f2[Y = String](1, "") // error: Y is undefined | ^^^^^^ | Type parameter Y is undefined. Expected one of X. diff --git a/tests/neg/namedTypeParams.scala b/tests/neg/namedTypeParams.scala index 53ef14188e12..489ac1e8cdb6 100644 --- a/tests/neg/namedTypeParams.scala +++ b/tests/neg/namedTypeParams.scala @@ -27,7 +27,6 @@ object Test: object TestInterleaving: import language.experimental.namedTypeArguments - import language.experimental.clauseInterleaving def f2[X](using DummyImplicit)[Y](x: X, y: Y): Int = ??? f2[Y = String][X = Int](1, "") // error: Y is undefined diff --git a/tests/neg/overrides.scala b/tests/neg/overrides.scala index 8016f5646d09..c8f577103a6a 100644 --- a/tests/neg/overrides.scala +++ b/tests/neg/overrides.scala @@ -44,8 +44,6 @@ class A[T] { def next: T = ??? - import scala.language.experimental.clauseInterleaving - def b[U <: T](x: Int)[V >: T](y: String) = false } @@ -57,8 +55,6 @@ class B extends A[Int] { override def next(): Int = ??? // error: incompatible type - import scala.language.experimental.clauseInterleaving - override def b[T <: Int](x: Int)(y: String) = true // error } @@ -68,8 +64,6 @@ class C extends A[String] { override def next: Int = ??? // error: incompatible type - import scala.language.experimental.clauseInterleaving - override def b[T <: String](x: Int)[U >: Int](y: String) = true // error: incompatible type } diff --git a/tests/pos/interleaving-ba.scala b/tests/pos/interleaving-ba.scala index 69fe2d9537a0..4a7d721c804e 100644 --- a/tests/pos/interleaving-ba.scala +++ b/tests/pos/interleaving-ba.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object BA { given String = "" diff --git a/tests/pos/interleaving-chainedParams.scala b/tests/pos/interleaving-chainedParams.scala index a54885d28002..02dc7a5ccc9c 100644 --- a/tests/pos/interleaving-chainedParams.scala +++ b/tests/pos/interleaving-chainedParams.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object chainedParams{ diff --git a/tests/pos/interleaving-classless.scala b/tests/pos/interleaving-classless.scala index 5aec92db3409..bddfc821385d 100644 --- a/tests/pos/interleaving-classless.scala +++ b/tests/pos/interleaving-classless.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving def f1[T]()[U](x: T, y: U): (T, U) = (x, y) def f2[T](x: T)[U](y: U): (T, U) = (x, y) diff --git a/tests/pos/interleaving-functor.scala b/tests/pos/interleaving-functor.scala index 35bed59f77f0..b588e35f60a2 100644 --- a/tests/pos/interleaving-functor.scala +++ b/tests/pos/interleaving-functor.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object functorInterleaving: //taken from https://dotty.epfl.ch/docs/reference/contextual/type-classes.html diff --git a/tests/pos/interleaving-newline.scala b/tests/pos/interleaving-newline.scala index de8fb98a2f81..d71bdc910de2 100644 --- a/tests/pos/interleaving-newline.scala +++ b/tests/pos/interleaving-newline.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object newline { def multipleLines diff --git a/tests/pos/interleaving-overload.scala b/tests/pos/interleaving-overload.scala index 1902551f9036..e1c3db1abe37 100644 --- a/tests/pos/interleaving-overload.scala +++ b/tests/pos/interleaving-overload.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving class A{ diff --git a/tests/pos/interleaving-params.scala b/tests/pos/interleaving-params.scala index 36963ff2e123..b12608f4b291 100644 --- a/tests/pos/interleaving-params.scala +++ b/tests/pos/interleaving-params.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving class Params{ type U diff --git a/tests/pos/interleaving-signatureCollision.scala b/tests/pos/interleaving-signatureCollision.scala index 77190284ae6d..be016e7bdbfe 100644 --- a/tests/pos/interleaving-signatureCollision.scala +++ b/tests/pos/interleaving-signatureCollision.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving import scala.annotation.targetName object signatureCollision: diff --git a/tests/pos/interleaving-typeApply.scala b/tests/pos/interleaving-typeApply.scala index 3c669cc76bfc..d8a7fd5d2ec1 100644 --- a/tests/pos/interleaving-typeApply.scala +++ b/tests/pos/interleaving-typeApply.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object typeApply: @@ -12,7 +11,6 @@ object typeApply: def f7[T <: Int](using DummyImplicit)[U <: String]()[X <: Unit]: X => X = ??? @main def test = { - import scala.language.experimental.namedTypeArguments f0[Int][String] f1[Int][String] f2[Int][String]() diff --git a/tests/pos/interleavingExperimental.scala b/tests/pos/interleavingExperimental.scala new file mode 100644 index 000000000000..63227ef1ebfe --- /dev/null +++ b/tests/pos/interleavingExperimental.scala @@ -0,0 +1,5 @@ +//> using options --source 3.5 + +import scala.language.experimental.clauseInterleaving + +def ba[A](x: A)[B](using B): B = summon[B] \ No newline at end of file diff --git a/tests/pos/namedTypeParams.scala b/tests/pos/namedTypeParams.scala index 388bcfa98bef..d538bef52a69 100644 --- a/tests/pos/namedTypeParams.scala +++ b/tests/pos/namedTypeParams.scala @@ -11,7 +11,6 @@ object Test { } object TestInterleaving{ - import language.experimental.clauseInterleaving def f2[X](using DummyImplicit)[Y](x: X, y: Y): Int = ??? f2[X = Int][Y = String](1, "") diff --git a/tests/pos/overrides.scala b/tests/pos/overrides.scala index c3b6235d7c1f..e56c4c941a7f 100644 --- a/tests/pos/overrides.scala +++ b/tests/pos/overrides.scala @@ -4,8 +4,6 @@ class A[T] { def f(x: T)(y: T = x) = y - import scala.language.experimental.clauseInterleaving - def b[U <: T](x: Int)[V >: T](y: String) = false } @@ -15,9 +13,6 @@ class B extends A[Int] { f(2)() - - import scala.language.experimental.clauseInterleaving - override def b[T <: Int](x: Int)[U >: Int](y: String) = true } diff --git a/tests/run/interleaving.scala b/tests/run/interleaving.scala index 6749e59168bc..cc52528486b1 100644 --- a/tests/run/interleaving.scala +++ b/tests/run/interleaving.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object Test extends App { trait Key { type Value } From 97b8e377050fb236c22c154e6e53501b028b2150 Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Thu, 4 Jul 2024 02:00:23 +0200 Subject: [PATCH 2/5] Add workflow to release to winget --- .github/workflows/publish-winget.yml | 36 ++++++++++++++++++++++++++++ .github/workflows/releases.yml | 9 ++++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish-winget.yml diff --git a/.github/workflows/publish-winget.yml b/.github/workflows/publish-winget.yml new file mode 100644 index 000000000000..8515f95ad799 --- /dev/null +++ b/.github/workflows/publish-winget.yml @@ -0,0 +1,36 @@ +################################################################################################### +### THIS IS A REUSABLE WORKFLOW TO PUBLISH SCALA TO WINGET ### +### HOW TO USE: ### +### - THE RELEASE WORKFLOW SHOULD CALL THIS WORKFLOW ### +### - IT WILL PUBLISH TO WINGET THE MSI ### +### ### +### NOTE: ### +### - WE SHOULD KEEP IN SYNC THE https://github.com/dottybot/winget-pkgs REPOSITORY ### +################################################################################################### + + +name: Publish Scala to winget +run-name: Publish Scala ${{ inputs.version }} to winget + +on: + workflow_call: + inputs: + version: + required: true + type: string + secrets: + DOTTYBOT-TOKEN: + required: true + +jobs: + publish: + runs-on: windows-latest + steps: + - uses: vedantmgoyal9/winget-releaser@b87a066d9e624db1394edcd947f8c4e5a7e30cd7 + with: + identifier : Scala.Scala.3 + version : ${{ inputs.version }} + installers-regex: '\.msi$' + release-tag : ${{ inputs.version }} + fork-user : dottybot + token : ${{ secrets.DOTTYBOT-WINGET-TOKEN }} \ No newline at end of file diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 4b75dd1b737d..a4977bc5ffd9 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -29,5 +29,12 @@ jobs: secrets: CONSUMER-KEY: ${{ secrets.SDKMAN_KEY }} CONSUMER-TOKEN: ${{ secrets.SDKMAN_TOKEN }} - + + publish-winget: + uses: ./.github/workflows/publish-winget.yml + with: + version: ${{ inputs.version }} + secrets: + DOTTYBOT-TOKEN: ${{ secrets.DOTTYBOT_WINGET_TOKEN }} + # TODO: ADD RELEASE WORKFLOW TO CHOCOLATEY AND OTHER PACKAGE MANAGERS HERE \ No newline at end of file From 6d5388bcf8613f7a951c7b3617717f4138ffb4a9 Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Thu, 4 Jul 2024 15:01:11 +0200 Subject: [PATCH 3/5] Update .github/workflows/publish-winget.yml Co-authored-by: Piotr Chabelski --- .github/workflows/publish-winget.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-winget.yml b/.github/workflows/publish-winget.yml index 8515f95ad799..03ebc5d0fa7d 100644 --- a/.github/workflows/publish-winget.yml +++ b/.github/workflows/publish-winget.yml @@ -2,7 +2,7 @@ ### THIS IS A REUSABLE WORKFLOW TO PUBLISH SCALA TO WINGET ### ### HOW TO USE: ### ### - THE RELEASE WORKFLOW SHOULD CALL THIS WORKFLOW ### -### - IT WILL PUBLISH TO WINGET THE MSI ### +### - IT WILL PUBLISH THE MSI TO WINGET ### ### ### ### NOTE: ### ### - WE SHOULD KEEP IN SYNC THE https://github.com/dottybot/winget-pkgs REPOSITORY ### From fc1ce142af7c8a36ea00de0531e5554eb0217c24 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Thu, 2 May 2024 15:36:19 -0700 Subject: [PATCH 4/5] Supplement structural givens doc --- docs/_docs/reference/contextual/givens.md | 41 ++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/docs/_docs/reference/contextual/givens.md b/docs/_docs/reference/contextual/givens.md index bf018278c9fc..5499fc39b53c 100644 --- a/docs/_docs/reference/contextual/givens.md +++ b/docs/_docs/reference/contextual/givens.md @@ -88,6 +88,45 @@ given (using config: Config): Factory = MemoizingFactory(config) An alias given can have type parameters and context parameters just like any other given, but it can only implement a single type. +## Abstract Givens + +A given may be an abstract member, with the restriction that it must have an explicit name. + +```scala +trait HasOrd[T]: + given ord: Ord[T] +``` + +## More Structural Givens + +If an alias given instance is analogous to a lazy val, +and a structural given instance is analogous to an object, +albeit an object with an explicit type, +then a structural given may also be specified without an explicit type: + +```scala +class IntOrd extends Ord[Int]: + def compare(x: Int, y: Int) = + if x < y then -1 else if x > y then +1 else 0 + +given IntOrd() +``` + +Compare this syntax to: + +```scala +object intOrd extends IntOrd() +``` + +The empty parentheses are optional in the extends clause when defining a class, +but are required when defining a given. + +Further mixins are allowed as usual: + +```scala +given IntOrd() with OrdOps[Int] +``` + ## Given Macros Given aliases can have the `inline` and `transparent` modifiers. @@ -191,4 +230,4 @@ of given instances: - A _structural instance_ contains one or more types or constructor applications, followed by `with` and a template body that contains member definitions of the instance. - An _alias instance_ contains a type, followed by `=` and a right-hand side expression. -- An _abstract instance_ contains just the type, which is not followed by anything. +- An _abstract instance_ contains just the name and type, which is not followed by anything. From f2829c3fab28cc6ab47a5627abda855884476572 Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Thu, 4 Jul 2024 19:15:59 +0200 Subject: [PATCH 5/5] Fix isomorphism tests of `AndOrType`s under non-empty `BinderPairs` (#21017) Before the changes, when comparing two `HKTypeLambda` result types, the list of binding pairs was lost when entering comparison of `AndOrType`s, which caused the `equals` to fail, and hence prevented hash-consing. Even though `M1` and `M2` in pos/i20858-min should still conform to one-another, we entered a deep-subtype comparison because of the order in which the TypeComparer does dealiasing of AppliedTypes, and comparison of MatchCases and AndTypes. Fix #20858 --- .../src/dotty/tools/dotc/core/Types.scala | 10 +++++++ tests/pos/i20858-min.scala | 10 +++++++ tests/pos/i20858/defns_1.scala | 27 +++++++++++++++++++ tests/pos/i20858/usages_2.scala | 2 ++ 4 files changed, 49 insertions(+) create mode 100644 tests/pos/i20858-min.scala create mode 100644 tests/pos/i20858/defns_1.scala create mode 100644 tests/pos/i20858/usages_2.scala diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index efb353c4050c..62880b14cdeb 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -3544,6 +3544,8 @@ object Types extends TypeUtils { else this match case tp: OrType => OrType.make(tp1, tp2, tp.isSoft) case tp: AndType => AndType.make(tp1, tp2, checkValid = true) + + override def hashIsStable: Boolean = tp1.hashIsStable && tp2.hashIsStable } abstract case class AndType(tp1: Type, tp2: Type) extends AndOrType { @@ -3589,6 +3591,10 @@ object Types extends TypeUtils { case that: AndType => tp1.eq(that.tp1) && tp2.eq(that.tp2) case _ => false } + + override protected def iso(that: Any, bs: BinderPairs) = that match + case that: AndType => tp1.equals(that.tp1, bs) && tp2.equals(that.tp2, bs) + case _ => false } final class CachedAndType(tp1: Type, tp2: Type) extends AndType(tp1, tp2) @@ -3741,6 +3747,10 @@ object Types extends TypeUtils { case that: OrType => tp1.eq(that.tp1) && tp2.eq(that.tp2) && isSoft == that.isSoft case _ => false } + + override protected def iso(that: Any, bs: BinderPairs) = that match + case that: OrType => tp1.equals(that.tp1, bs) && tp2.equals(that.tp2, bs) && isSoft == that.isSoft + case _ => false } final class CachedOrType(tp1: Type, tp2: Type, override val isSoft: Boolean) extends OrType(tp1, tp2) diff --git a/tests/pos/i20858-min.scala b/tests/pos/i20858-min.scala new file mode 100644 index 000000000000..9c47b04031e6 --- /dev/null +++ b/tests/pos/i20858-min.scala @@ -0,0 +1,10 @@ + +type M[F[_,_]] = Int match + case 0 => String & M[F] + +type M1 = M[[x,y] =>> x | y] +type M2 = M[[x,y] =>> x | y] + +def Test: Unit = + val x: M1 = ??? + val _: M2 = x // was error diff --git a/tests/pos/i20858/defns_1.scala b/tests/pos/i20858/defns_1.scala new file mode 100644 index 000000000000..7b4b84745b58 --- /dev/null +++ b/tests/pos/i20858/defns_1.scala @@ -0,0 +1,27 @@ +import scala.compiletime.* +import scala.deriving.* + +sealed trait ZIO[-R, +E, +A] +sealed abstract class ZLayer[-RIn, +E, +ROut] +object ZLayer: + def apply[RIn, E, ROut](zio: => ZIO[RIn, E, ROut]): ZLayer[RIn, E, ROut] = ??? +type URIO[-R, +A] = ZIO[R, Nothing, A] +type IAnyType[T <: Tuple] = Tuple.Fold[T, Any, [x, y] =>> x & y] +type UAnyType[T <: Tuple] = Tuple.Fold[T, Any, [x, y] =>> x | y] + + +trait AutoLayer[A]: + def zlayer(using + p: Mirror.ProductOf[A] + ): ZLayer[IAnyType[p.MirroredElemTypes], Nothing, A] + +object AutoLayer: + inline given derived[A](using p: Mirror.ProductOf[A]): AutoLayer[A] = { + val a: ZIO[IAnyType[p.MirroredElemTypes], Nothing, A] = ??? + new AutoLayer[A]: + override def zlayer(using + pp: Mirror.ProductOf[A] + ): ZLayer[IAnyType[pp.MirroredElemTypes], Nothing, A] = ZLayer { + a.asInstanceOf[ZIO[IAnyType[pp.MirroredElemTypes], Nothing, A]] + } + } \ No newline at end of file diff --git a/tests/pos/i20858/usages_2.scala b/tests/pos/i20858/usages_2.scala new file mode 100644 index 000000000000..3a05ba54e97a --- /dev/null +++ b/tests/pos/i20858/usages_2.scala @@ -0,0 +1,2 @@ + +case class TestService(port: Int) derives AutoLayer // was error