Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
pkskpro committed Jan 21, 2025
2 parents c5b6f1d + 5adcac1 commit 2b39941
Show file tree
Hide file tree
Showing 21 changed files with 209 additions and 50 deletions.
46 changes: 23 additions & 23 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
## Workaround for https://github.com/actions/runner/issues/2033 (See https://github.com/scala/scala3/pull/19720)
- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Checkout cleanup script
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:

- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Checkout cleanup script
Expand Down Expand Up @@ -190,7 +190,7 @@ jobs:

- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Checkout cleanup script
Expand Down Expand Up @@ -229,7 +229,7 @@ jobs:
- name: Reset existing repo
shell: cmd
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Git Checkout
Expand Down Expand Up @@ -273,7 +273,7 @@ jobs:
- name: Reset existing repo
shell: cmd
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Git Checkout
Expand Down Expand Up @@ -319,7 +319,7 @@ jobs:

- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Checkout cleanup script
Expand Down Expand Up @@ -374,7 +374,7 @@ jobs:
run: echo "/usr/lib/jvm/java-8-openjdk-amd64/bin" >> $GITHUB_PATH
- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Checkout cleanup script
Expand All @@ -391,7 +391,7 @@ jobs:

- name: Test
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git submodule sync
git submodule update --init --recursive --jobs 7
./project/scripts/sbt "community-build/testOnly dotty.communitybuild.CommunityBuildTestA"
Expand Down Expand Up @@ -431,7 +431,7 @@ jobs:
run: echo "/usr/lib/jvm/java-8-openjdk-amd64/bin" >> $GITHUB_PATH
- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Checkout cleanup script
Expand All @@ -448,7 +448,7 @@ jobs:

- name: Test
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git submodule sync
git submodule update --init --recursive --jobs 7
./project/scripts/sbt "community-build/testOnly dotty.communitybuild.CommunityBuildTestB"
Expand Down Expand Up @@ -488,7 +488,7 @@ jobs:
run: echo "/usr/lib/jvm/java-8-openjdk-amd64/bin" >> $GITHUB_PATH
- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Checkout cleanup script
Expand All @@ -505,7 +505,7 @@ jobs:

- name: Test
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git submodule sync
git submodule update --init --recursive --jobs 7
./project/scripts/sbt "community-build/testOnly dotty.communitybuild.CommunityBuildTestC"
Expand Down Expand Up @@ -541,7 +541,7 @@ jobs:

- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Checkout cleanup script
Expand Down Expand Up @@ -593,7 +593,7 @@ jobs:

- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Checkout cleanup script
Expand Down Expand Up @@ -648,7 +648,7 @@ jobs:
run: echo "/usr/lib/jvm/java-8-openjdk-amd64/bin" >> $GITHUB_PATH
- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Checkout cleanup script
Expand Down Expand Up @@ -706,7 +706,7 @@ jobs:
steps:
- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Checkout cleanup script
Expand All @@ -723,7 +723,7 @@ jobs:

- name: Generate Website
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
./project/scripts/genDocs -doc-snapshot
- name: Deploy Website to https://dotty.epfl.ch
Expand Down Expand Up @@ -764,7 +764,7 @@ jobs:
run: echo "/usr/lib/jvm/java-8-openjdk-amd64/bin" >> $GITHUB_PATH
- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Checkout cleanup script
Expand Down Expand Up @@ -826,15 +826,15 @@ jobs:
path: .
- name: Prepare MSI package
shell: bash
run: |
run: |
msiInstaller="scala3-${{ env.RELEASE_TAG }}.msi"
mv scala.msi "${msiInstaller}"
sha256sum "${msiInstaller}" > "${msiInstaller}.sha256"
- name: Install GH CLI
uses: dev-hanz-ops/[email protected]
with:
gh-cli-version: 2.59.0
gh-cli-version: 2.59.0

# Create the GitHub release
- name: Create GitHub Release
Expand All @@ -844,7 +844,7 @@ jobs:
run: |
# We need to config safe.directory in every step that might reference git
# It is not persisted between steps
git config --global --add safe.directory /__w/scala3/scala3
git config --global --add safe.directory $GITHUB_WORKSPACE
gh release create \
--draft \
--title "${{ env.RELEASE_TAG }}" \
Expand Down Expand Up @@ -911,14 +911,14 @@ jobs:
uses: ./.github/workflows/build-chocolatey.yml
needs: [ build-sdk-package ]
with:
version: 3.6.0-local # TODO: FIX THIS
version: 3.6.0-SNAPSHOT # Fake version, used only for choco tests
url : https://api.github.com/repos/scala/scala3/actions/artifacts/${{ needs.build-sdk-package.outputs.win-x86_64-id }}/zip
digest : ${{ needs.build-sdk-package.outputs.win-x86_64-digest }}

test-chocolatey-package:
uses: ./.github/workflows/test-chocolatey.yml
with:
version : 3.6.0-local # TODO: FIX THIS
version : 3.6.0-SNAPSHOT # Fake version, used only for choco tests
java-version: 8
if: github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_chocolatey]')
needs: [ build-chocolatey-package ]
5 changes: 4 additions & 1 deletion .github/workflows/test-chocolatey.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ on:

env:
CHOCOLATEY-REPOSITORY: chocolatey-pkgs
DOTTY_CI_INSTALLATION: ${{ secrets.GITHUB_TOKEN }}
# Controls behaviour of chocolatey{Install,Uninstall}.ps1 scripts
# During snapshot releases it uses a different layout and requires access token to GH Actions artifacts
# During stable releases it uses publically available archives
DOTTY_CI_INSTALLATION: ${{ endsWith(inputs.version, '-SNAPSHOT') && secrets.GITHUB_TOKEN || '' }}

jobs:
test:
Expand Down
18 changes: 10 additions & 8 deletions compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import StdNames.nme
import java.io.{BufferedWriter, OutputStreamWriter}
import java.nio.charset.StandardCharsets

import scala.collection.mutable
import scala.collection.mutable, mutable.ListBuffer
import scala.util.control.NonFatal
import scala.io.Codec

Expand Down Expand Up @@ -69,7 +69,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
private var myFiles: Set[AbstractFile] = uninitialized

// `@nowarn` annotations by source file, populated during typer
private val mySuppressions: mutable.LinkedHashMap[SourceFile, mutable.ListBuffer[Suppression]] = mutable.LinkedHashMap.empty
private val mySuppressions: mutable.LinkedHashMap[SourceFile, ListBuffer[Suppression]] = mutable.LinkedHashMap.empty
// source files whose `@nowarn` annotations are processed
private val mySuppressionsComplete: mutable.Set[SourceFile] = mutable.Set.empty
// warnings issued before a source file's `@nowarn` annotations are processed, suspended so that `@nowarn` can filter them
Expand Down Expand Up @@ -99,8 +99,9 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
}

def addSuppression(sup: Suppression): Unit =
val source = sup.annotPos.source
mySuppressions.getOrElseUpdate(source, mutable.ListBuffer.empty) += sup
val suppressions = mySuppressions.getOrElseUpdate(sup.annotPos.source, ListBuffer.empty)
if sup.start != sup.end && suppressions.forall(x => x.start != sup.start || x.end != sup.end) then
suppressions += sup

def reportSuspendedMessages(source: SourceFile)(using Context): Unit = {
// sort suppressions. they are not added in any particular order because of lazy type completion
Expand All @@ -115,11 +116,12 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
mySuspendedMessages.keysIterator.toList.foreach(reportSuspendedMessages)
// report unused nowarns only if all all phases are done
if !hasErrors && ctx.settings.WunusedHas.nowarn then
for {
for
source <- mySuppressions.keysIterator.toList
sups <- mySuppressions.remove(source)
sup <- sups.reverse
} if (!sup.used)
if !sup.used
do
report.warning("@nowarn annotation does not suppress any warnings", sup.annotPos)

/** The compilation units currently being compiled, this may return different
Expand All @@ -130,7 +132,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
private def units_=(us: List[CompilationUnit]): Unit =
myUnits = us

var suspendedUnits: mutable.ListBuffer[CompilationUnit] = mutable.ListBuffer()
var suspendedUnits: ListBuffer[CompilationUnit] = ListBuffer.empty
var suspendedHints: mutable.Map[CompilationUnit, (String, Boolean)] = mutable.HashMap()

/** Were any units suspended in the typer phase? if so then pipeline tasty can not complete. */
Expand Down Expand Up @@ -172,7 +174,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
val staticRefs = util.EqHashMap[Name, Denotation](initialCapacity = 1024)

/** Actions that need to be performed at the end of the current compilation run */
private var finalizeActions = mutable.ListBuffer[() => Unit]()
private var finalizeActions = ListBuffer.empty[() => Unit]

private var _progress: Progress | Null = null // Set if progress reporting is enabled

Expand Down
12 changes: 7 additions & 5 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,20 @@ object desugar {
case ContextBounds(tbounds, ctxbounds) =>
val isMember = evidenceFlags.isAllOf(DeferredGivenFlags)
for bound <- ctxbounds do
val evidenceName = bound match
val (evidenceName, spanPoint) = bound match
case ContextBoundTypeTree(_, _, ownName) if !ownName.isEmpty =>
ownName // if there is an explicitly given name, use it.
val realName = ownName.stripModuleClassSuffix.lastPart
(ownName, bound.span.end - realName.length) // if there is an explicitly given name, use it.
case _ =>
if Config.nameSingleContextBounds
&& !isMember
&& ctxbounds.tail.isEmpty
&& Feature.enabled(Feature.modularity)
then tdef.name.toTermName
else freshName(bound)
then (tdef.name.toTermName, bound.span.point)
else (freshName(bound), bound.span.point)
evidenceNames += evidenceName
val evidenceParam = ValDef(evidenceName, bound, EmptyTree).withFlags(evidenceFlags)
val evidenceParam =
ValDef(evidenceName, bound, EmptyTree).withFlags(evidenceFlags).withSpan(bound.span.withPoint(spanPoint))
evidenceParam.pushAttachment(ContextBoundParam, ())
evidenceBuf += evidenceParam
tbounds
Expand Down
46 changes: 44 additions & 2 deletions compiler/src/dotty/tools/dotc/inlines/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,28 @@ object Inliner:
else Nil
case _ => Nil
val refinements = openOpaqueAliases(cls.givenSelfType)

// Map references in the refinements from the proxied termRef
// to the recursive type of the refined type
// e.g.: Obj.type{type A = Obj.B; type B = Int} -> Obj.type{type A = <recthis>.B; type B = Int}
def mapRecTermRefReferences(recType: RecType, refinedType: Type) =
new TypeMap {
def apply(tp: Type) = tp match
case RefinedType(a: RefinedType, b, info) => RefinedType(apply(a), b, apply(info))
case RefinedType(a, b, info) => RefinedType(a, b, apply(info))
case TypeRef(prefix, des) => TypeRef(apply(prefix), des)
case termRef: TermRef if termRef == ref => recType.recThis
case _ => mapOver(tp)
}.apply(refinedType)

val refinedType = refinements.foldLeft(ref: Type): (parent, refinement) =>
RefinedType(parent, refinement._1, TypeAlias(refinement._2))
val refiningSym = newSym(InlineBinderName.fresh(), Synthetic, refinedType, span)

val recType = RecType.closeOver ( recType =>
mapRecTermRefReferences(recType, refinedType)
)

val refiningSym = newSym(InlineBinderName.fresh(), Synthetic, recType, span)
refiningSym.termRef

def unapply(refiningRef: TermRef)(using Context): Option[TermRef] =
Expand Down Expand Up @@ -387,7 +406,9 @@ class Inliner(val call: tpd.Tree)(using Context):
val refiningRef = OpaqueProxy(ref, cls, call.span)
val refiningSym = refiningRef.symbol.asTerm
val refinedType = refiningRef.info
val refiningDef = ValDef(refiningSym, tpd.ref(ref).cast(refinedType), inferred = true).withSpan(span)
val refiningDef = addProxiesForRecurrentOpaques(
ValDef(refiningSym, tpd.ref(ref).cast(refinedType), inferred = true).withSpan(span)
)
inlining.println(i"add opaque alias proxy $refiningDef for $ref in $tp")
bindingsBuf += refiningDef
opaqueProxies += ((ref, refiningSym.termRef))
Expand All @@ -407,6 +428,27 @@ class Inliner(val call: tpd.Tree)(using Context):
}
)

/** Transforms proxies that reference other opaque types, like for:
* object Obj1 { opaque type A = Int }
* object Obj2 { opaque type B = A }
* and proxy$1 of type Obj2.type{type B = Obj1.A}
* creates proxy$2 of type Obj1.type{type A = Int}
* and transforms proxy$1 into Obj2.type{type B = proxy$2.A}
*/
private def addProxiesForRecurrentOpaques(binding: ValDef)(using Context): ValDef =
def fixRefinedTypes(ref: Type): Unit =
ref match
case recType: RecType => fixRefinedTypes(recType.underlying)
case RefinedType(parent, name, info) =>
addOpaqueProxies(info.widen, binding.span, true)
fixRefinedTypes(parent)
case _ =>
fixRefinedTypes(binding.symbol.info)
binding.symbol.info = mapOpaques.typeMap(binding.symbol.info)
mapOpaques.transform(binding).asInstanceOf[ValDef]
.showing(i"transformed this binding exposing opaque aliases: $result", inlining)
end addProxiesForRecurrentOpaques

/** If `binding` contains TermRefs that refer to objects with opaque
* type aliases, add proxy definitions that expose these aliases
* and substitute such TermRefs with theproxies. Example from pos/opaque-inline1.scala:
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2265,7 +2265,8 @@ object Parsers {
in.nextToken()
ident()
else EmptyTermName
ContextBoundTypeTree(t, pname, ownName)
val newSpan = t.span.withPoint(t.span.end).withEnd(in.lastOffset)
ContextBoundTypeTree(t, pname, ownName).withSpan(newSpan)

/** ContextBounds ::= ContextBound [`:` ContextBounds]
* | `{` ContextBound {`,` ContextBound} `}`
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/reporting/WConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ object WConf:
if (parseErrorss.nonEmpty) Left(parseErrorss.flatten)
else Right(WConf(configs))

class Suppression(val annotPos: SourcePosition, filters: List[MessageFilter], val start: Int, end: Int, val verbose: Boolean):
class Suppression(val annotPos: SourcePosition, filters: List[MessageFilter], val start: Int, val end: Int, val verbose: Boolean):
private var _used = false
def used: Boolean = _used
def markUsed(): Unit = { _used = true }
Expand Down
Loading

0 comments on commit 2b39941

Please sign in to comment.