Skip to content

Commit 031f7ae

Browse files
authored
Merge branch 'scala:main' into patch-1
2 parents f1740ba + 8a3f375 commit 031f7ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+667
-184
lines changed

.github/workflows/build-msi.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ on:
1414
workflow_call:
1515

1616
env:
17-
# NECESSARY FLAG TO CORRECTLY CONFIGURE THE VERSION FOR SCALA
18-
RELEASEBUILD: yes
17+
# Release only happends when triggering CI by pushing tag
18+
RELEASEBUILD: ${{ startsWith(github.event.ref, 'refs/tags/') && 'yes' || 'no' }}
1919

2020
jobs:
2121
build:

.github/workflows/ci.yaml

+64-20
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ jobs:
737737
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
738738
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
739739
- ${{ github.workspace }}/../../cache/general:/root/.cache
740-
needs: [test_non_bootstrapped, test, mima, community_build_a, community_build_b, community_build_c, test_sbt, test_java8, build-sdk-package]
740+
needs: [test_non_bootstrapped, test, mima, community_build_a, community_build_b, community_build_c, test_sbt, test_java8, build-sdk-package, build-msi-package]
741741
if: "github.event_name == 'push'
742742
&& startsWith(github.event.ref, 'refs/tags/')"
743743

@@ -816,6 +816,18 @@ jobs:
816816
prepareSDK "-x86_64-apple-darwin" "dist-mac-x86_64" "./dist/mac-x86_64/"
817817
prepareSDK "-x86_64-pc-win32" "dist-win-x86_64" "./dist/win-x86_64/"
818818
819+
- name: Download MSI package
820+
uses: actions/download-artifact@v4
821+
with:
822+
name: scala.msi
823+
path: .
824+
- name: Prepare MSI package
825+
shell: bash
826+
run: |
827+
msiInstaller="scala3-${{ env.RELEASE_TAG }}.msi"
828+
mv scala.msi "${msiInstaller}"
829+
sha256sum "${msiInstaller}" > "${msiInstaller}.sha256"
830+
819831
# Create the GitHub release
820832
- name: Create GitHub Release
821833
id: create_gh_release
@@ -829,10 +841,10 @@ jobs:
829841
draft: true
830842
prerelease: ${{ contains(env.RELEASE_TAG, '-') }}
831843

832-
# The following steps are generated using template:
833-
# def template(distribution: String, suffix: String) =
834-
# def upload(kind: String, path: String, contentType: String) =
835-
# s"""- name: Upload $kind to GitHub Release ($distribution)
844+
# The following upload steps are generated using template:
845+
# val baseFileName = "scala3-${{ env.RELEASE_TAG }}"
846+
# def upload(kind: String, path: String, contentType: String, distribution: String) =
847+
# s"""- name: Upload $kind to GitHub Release ($distribution)
836848
# uses: actions/upload-release-asset@v1
837849
# env:
838850
# GITHUB_TOKEN: $${{ secrets.GITHUB_TOKEN }}
@@ -841,24 +853,33 @@ jobs:
841853
# asset_path: ./${path}
842854
# asset_name: ${path}
843855
# asset_content_type: ${contentType}"""
844-
# val filename = s"scala3-$${{ env.RELEASE_TAG }}${suffix}"
856+
# def uploadSDK(distribution: String, suffix: String) =
857+
# val filename = s"${baseFileName}${suffix}"
845858
# s"""
846859
# # $distribution
847-
# ${upload("zip archive", s"$filename.zip", "application/zip")}
848-
# ${upload("zip archive SHA", s"$filename.zip.sha256", "text/plain")}
849-
# ${upload("tar.gz archive", s"$filename.tar.gz", "application/gzip")}
850-
# ${upload("tar.gz archive SHA", s"$filename.tar.gz.sha256", "text/plain")}
860+
# ${upload("zip archive", s"$filename.zip", "application/zip", distribution)}
861+
# ${upload("zip archive SHA", s"$filename.zip.sha256", "text/plain", distribution)}
862+
# ${upload("tar.gz archive", s"$filename.tar.gz", "application/gzip", distribution)}
863+
# ${upload("tar.gz archive SHA", s"$filename.tar.gz.sha256", "text/plain", distribution)}
864+
# """
865+
# def uploadMSI() =
866+
# val distribution = "Windows x86_64 MSI"
867+
# s"""
868+
# # $distribution
869+
# ${upload(".msi file", s"${baseFileName}.msi", "application/x-msi", distribution)}
870+
# ${upload(".msi file SHA", s"${baseFileName}.msi.sha256", "text/plain", distribution)}
851871
# """
852-
853872
# @main def gen =
854873
# Seq(
855-
# template("Universal", ""),
856-
# template("Linux x86-64", "-x86_64-pc-linux"),
857-
# template("Linux aarch64", "-aarch64-pc-linux"),
858-
# template("Mac x86-64", "-x86_64-apple-darwin"),
859-
# template("Mac aarch64", "-aarch64-apple-darwin"),
860-
# template("Windows x86_64", "-x86_64-pc-win32")
874+
# uploadSDK("Universal", ""),
875+
# uploadSDK("Linux x86-64", "-x86_64-pc-linux"),
876+
# uploadSDK("Linux aarch64", "-aarch64-pc-linux"),
877+
# uploadSDK("Mac x86-64", "-x86_64-apple-darwin"),
878+
# uploadSDK("Mac aarch64", "-aarch64-apple-darwin"),
879+
# uploadSDK("Windows x86_64", "-x86_64-pc-win32"),
880+
# uploadMSI()
861881
# ).foreach(println)
882+
862883
# Universal
863884
- name: Upload zip archive to GitHub Release (Universal)
864885
uses: actions/upload-release-asset@v1
@@ -1092,8 +1113,29 @@ jobs:
10921113
asset_name: scala3-${{ env.RELEASE_TAG }}-x86_64-pc-win32.tar.gz.sha256
10931114
asset_content_type: text/plain
10941115

1116+
1117+
# Windows x86_64 MSI
1118+
- name: Upload .msi file to GitHub Release (Windows x86_64 MSI)
1119+
uses: actions/upload-release-asset@v1
1120+
env:
1121+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1122+
with:
1123+
upload_url: ${{ steps.create_gh_release.outputs.upload_url }}
1124+
asset_path: ./scala3-${{ env.RELEASE_TAG }}.msi
1125+
asset_name: scala3-${{ env.RELEASE_TAG }}.msi
1126+
asset_content_type: application/x-msi
1127+
- name: Upload .msi file SHA to GitHub Release (Windows x86_64 MSI)
1128+
uses: actions/upload-release-asset@v1
1129+
env:
1130+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1131+
with:
1132+
upload_url: ${{ steps.create_gh_release.outputs.upload_url }}
1133+
asset_path: ./scala3-${{ env.RELEASE_TAG }}.msi.sha256
1134+
asset_name: scala3-${{ env.RELEASE_TAG }}.msi.sha256
1135+
asset_content_type: text/plain
1136+
10951137
- name: Publish Release
1096-
run: ./project/scripts/sbtPublish ";project scala3-bootstrapped ;publishSigned ;sonatypeBundleRelease"
1138+
run: ./project/scripts/sbtPublish ";project scala3-bootstrapped ;publishSigned ;sonatypeBundleUpload"
10971139

10981140

10991141
open_issue_on_failure:
@@ -1118,14 +1160,16 @@ jobs:
11181160

11191161
build-msi-package:
11201162
uses: ./.github/workflows/build-msi.yml
1121-
if : github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_msi]')
1163+
if :
1164+
(github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_msi]')) ||
1165+
(github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/'))
11221166

11231167
test-msi-package:
11241168
uses: ./.github/workflows/test-msi.yml
11251169
needs: [build-msi-package]
11261170
with:
11271171
# Ensure that version starts with prefix 3.
1128-
# In the future it can be adapted to compare with with git tag or version set in the build.s
1172+
# In the future it can be adapted to compare with with git tag or version set in the project/Build.scala
11291173
version: "3."
11301174
java-version: 8
11311175

compiler/src/dotty/tools/dotc/ast/tpd.scala

+16
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Symbols.*, StdNames.*, Annotations.*, Trees.*, Symbols.*
1111
import Decorators.*, DenotTransformers.*
1212
import collection.{immutable, mutable}
1313
import util.{Property, SourceFile}
14+
import config.Printers.typr
1415
import NameKinds.{TempResultName, OuterSelectName}
1516
import typer.ConstFold
1617

@@ -1165,6 +1166,21 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
11651166
tree
11661167
}
11671168

1169+
/** Make sure tree has given symbol. This is called when typing or unpickling
1170+
* a ValDef or DefDef. It turns out that under very rare circumstances the symbol
1171+
* computed for a tree is not correct. The only known test case is i21755.scala.
1172+
* Here we have a self type that mentions a supertype as well as a type parameter
1173+
* upper-bounded by the current class and it turns out that we compute the symbol
1174+
* for a member method (named `root` in this case) in a subclass to be the
1175+
* corresponding symbol in the superclass. It is not known what are the precise
1176+
* conditions where this happens, but my guess would be that it's connected to the
1177+
* recursion in the self type.
1178+
*/
1179+
def ensureHasSym(sym: Symbol)(using Context): Unit =
1180+
if sym.exists && sym != tree.symbol then
1181+
typr.println(i"correcting definition symbol from ${tree.symbol.showLocated} to ${sym.showLocated}")
1182+
tree.overwriteType(NamedType(sym.owner.thisType, sym.asTerm.name, sym.denot))
1183+
11681184
def etaExpandCFT(using Context): Tree =
11691185
def expand(target: Tree, tp: Type)(using Context): Tree = tp match
11701186
case defn.ContextFunctionType(argTypes, resType) =>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ object ContextOps:
132132
}
133133

134134
def packageContext(tree: untpd.PackageDef, pkg: Symbol): Context = inContext(ctx) {
135-
if (pkg.is(Package)) ctx.fresh.setOwner(pkg.moduleClass).setTree(tree)
135+
if (pkg.is(Package)) ctx.fresh.setOwner(pkg.moduleClass).setTree(tree).setNewScope
136136
else ctx
137137
}
138138
end ContextOps

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

+14-7
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,23 @@ object SymbolLoaders {
5151
*/
5252
def enterClass(
5353
owner: Symbol, name: PreName, completer: SymbolLoader,
54-
flags: FlagSet = EmptyFlags, scope: Scope = EmptyScope)(using Context): Symbol = {
55-
val cls = newClassSymbol(owner, name.toTypeName.unmangleClassName.decode, flags, completer, compUnitInfo = completer.compilationUnitInfo)
54+
flags: FlagSet = EmptyFlags, scope: Scope = EmptyScope, privateWithin: Symbol = NoSymbol,
55+
)(using Context): Symbol = {
56+
val cls = newClassSymbol(owner, name.toTypeName.unmangleClassName.decode, flags, completer, privateWithin, compUnitInfo = completer.compilationUnitInfo)
5657
enterNew(owner, cls, completer, scope)
5758
}
5859

5960
/** Enter module with given `name` into scope of `owner`.
6061
*/
6162
def enterModule(
6263
owner: Symbol, name: PreName, completer: SymbolLoader,
63-
modFlags: FlagSet = EmptyFlags, clsFlags: FlagSet = EmptyFlags, scope: Scope = EmptyScope)(using Context): Symbol = {
64+
modFlags: FlagSet = EmptyFlags, clsFlags: FlagSet = EmptyFlags,
65+
scope: Scope = EmptyScope, privateWithin: Symbol = NoSymbol,
66+
)(using Context): Symbol = {
6467
val module = newModuleSymbol(
6568
owner, name.toTermName.decode, modFlags, clsFlags,
6669
(module, _) => completer.proxy.withDecls(newScope).withSourceModule(module),
70+
privateWithin,
6771
compUnitInfo = completer.compilationUnitInfo)
6872
enterNew(owner, module, completer, scope)
6973
enterNew(owner, module.moduleClass, completer, scope)
@@ -103,13 +107,16 @@ object SymbolLoaders {
103107
*/
104108
def enterClassAndModule(
105109
owner: Symbol, name: PreName, completer: SymbolLoader,
106-
flags: FlagSet = EmptyFlags, scope: Scope = EmptyScope)(using Context): Unit = {
107-
val clazz = enterClass(owner, name, completer, flags, scope)
110+
flags: FlagSet = EmptyFlags, scope: Scope = EmptyScope, privateWithin: Symbol = NoSymbol,
111+
)(using Context): Unit = {
112+
val clazz = enterClass(owner, name, completer, flags, scope, privateWithin)
108113
val module = enterModule(
109114
owner, name, completer,
110115
modFlags = flags.toTermFlags & RetainedModuleValFlags,
111116
clsFlags = flags.toTypeFlags & RetainedModuleClassFlags,
112-
scope = scope)
117+
scope = scope,
118+
privateWithin = privateWithin,
119+
)
113120
}
114121

115122
/** Enter all toplevel classes and objects in file `src` into package `owner`, provided
@@ -337,7 +344,7 @@ abstract class SymbolLoader extends LazyType { self =>
337344
val sym = root.symbol
338345
def associatedFile = root.symbol.associatedFile match
339346
case file: AbstractFile => file
340-
case _ => NoAbstractFile
347+
case null => NoAbstractFile
341348
ctx.profiler.onCompletion(sym, associatedFile)(body)
342349
}
343350

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

+23-5
Original file line numberDiff line numberDiff line change
@@ -3196,9 +3196,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
31963196
cls.is(Sealed) && !cls.hasAnonymousChild
31973197

31983198
def decompose(cls: Symbol): List[Symbol] =
3199-
cls.children.map { child =>
3200-
if child.isTerm then child.info.classSymbol
3201-
else child
3199+
cls.children.flatMap { child =>
3200+
if child.isTerm then
3201+
child.info.classSymbols // allow enum vals to be decomposed to their enum class (then filtered out) and any mixins
3202+
else child :: Nil
32023203
}.filter(child => child.exists && child != cls)
32033204

32043205
def eitherDerivesFromOther(cls1: Symbol, cls2: Symbol): Boolean =
@@ -3231,6 +3232,12 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
32313232
end provablyDisjointClasses
32323233

32333234
private def provablyDisjointTypeArgs(cls: ClassSymbol, args1: List[Type], args2: List[Type], pending: util.HashSet[(Type, Type)])(using Context): Boolean =
3235+
// sjrd: I will not be surprised when this causes further issues in the future.
3236+
// This is a compromise to be able to fix #21295 without breaking the world.
3237+
def cannotBeNothing(tp: Type): Boolean = tp match
3238+
case tp: TypeParamRef => cannotBeNothing(tp.paramInfo)
3239+
case _ => !(tp.loBound.stripTypeVar <:< defn.NothingType)
3240+
32343241
// It is possible to conclude that two types applied are disjoint by
32353242
// looking at covariant type parameters if the said type parameters
32363243
// are disjoint and correspond to fields.
@@ -3239,9 +3246,20 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
32393246
def covariantDisjoint(tp1: Type, tp2: Type, tparam: TypeParamInfo): Boolean =
32403247
provablyDisjoint(tp1, tp2, pending) && typeparamCorrespondsToField(cls.appliedRef, tparam)
32413248

3242-
// In the invariant case, direct type parameter disjointness is enough.
3249+
// In the invariant case, we have more ways to prove disjointness:
3250+
// - either the type param corresponds to a field, like in the covariant case, or
3251+
// - one of the two actual args can never be `Nothing`.
3252+
// The latter condition, as tested by `cannotBeNothing`, is ad hoc and was
3253+
// not carefully evaluated to be sound. We have it because we had to
3254+
// reintroduce the former condition to fix #21295, and alone, that broke a
3255+
// lot of existing test cases.
3256+
// Having either one of the two conditions be true is better than not requiring
3257+
// any, which was the status quo before #21295.
32433258
def invariantDisjoint(tp1: Type, tp2: Type, tparam: TypeParamInfo): Boolean =
3244-
provablyDisjoint(tp1, tp2, pending)
3259+
provablyDisjoint(tp1, tp2, pending) && {
3260+
typeparamCorrespondsToField(cls.appliedRef, tparam)
3261+
|| (cannotBeNothing(tp1) || cannotBeNothing(tp2))
3262+
}
32453263

32463264
args1.lazyZip(args2).lazyZip(cls.typeParams).exists {
32473265
(arg1, arg2, tparam) =>

0 commit comments

Comments
 (0)