Skip to content

Commit d31b8c4

Browse files
author
soronpo
committed
Merge branch 'master' of https://github.com/lampepfl/dotty into summonInline
� Conflicts: � docs/docs/reference/metaprogramming/compiletime-ops.md
2 parents dfc8858 + 4410752 commit d31b8c4

File tree

96 files changed

+1621
-1445
lines changed

Some content is hidden

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

96 files changed

+1621
-1445
lines changed

.github/workflows/scaladoc.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,25 @@ jobs:
7070
echo uplading docs to https://scala3doc.virtuslab.com/$DOC_DEST
7171
az storage container create --name $DOC_DEST --account-name scala3docstorage --public-access container
7272
az storage blob upload-batch -s scaladoc/output -d $DOC_DEST --account-name scala3docstorage
73+
74+
stdlib-sourcelinks-test:
75+
runs-on: ubuntu-latest
76+
if: "( github.event_name == 'pull_request'
77+
&& !contains(github.event.pull_request.body, '[skip ci]')
78+
&& !contains(github.event.pull_request.body, '[skip docs]')
79+
)
80+
|| contains(github.event.ref, 'scaladoc')
81+
|| contains(github.event.ref, 'scala3doc')
82+
|| contains(github.event.ref, 'master')"
83+
84+
steps:
85+
- name: Git Checkout
86+
uses: actions/checkout@v2
87+
88+
- name: Set up JDK 8
89+
uses: actions/setup-java@v1
90+
with:
91+
java-version: 8
92+
93+
- name: Test sourcelinks to stdlib
94+
run: ./project/scripts/sbt scaladoc/sourceLinksIntegrationTest:test

bench/profiles/exhaustivity.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ charts:
4141
- key: exhaustivity-i12241
4242
label: bootstrapped
4343

44+
- name: "exhaustivity i12358"
45+
url: https://github.com/lampepfl/dotty/blob/master/tests/patmat/i12358.scala
46+
lines:
47+
- key: exhaustivity-i12358
48+
label: bootstrapped
49+
4450
scripts:
4551

4652
patmatexhaust:
@@ -64,5 +70,8 @@ scripts:
6470
exhaustivity-i12241:
6571
- measure 20 40 3 $PROG_HOME/dotty/tests/patmat/i12241.scala
6672

73+
exhaustivity-i12358:
74+
- measure 20 40 3 $PROG_HOME/dotty/tests/patmat/i12358.scala
75+
6776
config:
6877
pr_base_url: "https://github.com/lampepfl/dotty/pull/"

compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
228228
resKind
229229
}
230230

231-
def genPrimitiveOp(tree: Apply, expectedType: BType): BType = tree match {
231+
def genPrimitiveOp(tree: Apply, expectedType: BType): BType = (tree: @unchecked) match {
232232
case Apply(fun @ DesugaredSelect(receiver, _), _) =>
233233
val sym = tree.symbol
234234

@@ -610,7 +610,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
610610
}
611611
}
612612

613-
def genTypeApply(t: TypeApply): BType = t match {
613+
def genTypeApply(t: TypeApply): BType = (t: @unchecked) match {
614614
case TypeApply(fun@DesugaredSelect(obj, _), targs) =>
615615

616616
val sym = fun.symbol

compiler/src/dotty/tools/backend/jvm/BCodeSyncAndTry.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
2727
*/
2828
abstract class SyncAndTryBuilder(cunit: CompilationUnit) extends PlainBodyBuilder(cunit) {
2929

30-
def genSynchronized(tree: Apply, expectedType: BType): BType = tree match {
30+
def genSynchronized(tree: Apply, expectedType: BType): BType = (tree: @unchecked) match {
3131
case Apply(TypeApply(fun, _), args) =>
3232
val monitor = locals.makeLocal(ObjectReference, "monitor", defn.ObjectType, tree.span)
3333
val monCleanup = new asm.Label

compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ object GenericSignatures {
131131
*/
132132
def splitIntersection(parents: List[Type])(using Context): (List[Type], List[Type]) =
133133
val erasedParents = parents.map(erasure)
134-
val erasedCls = erasedGlb(erasedParents).classSymbol
134+
val erasedTp = erasedGlb(erasedParents)
135135
parents.zip(erasedParents)
136136
.partitionMap((parent, erasedParent) =>
137-
if erasedParent.classSymbol eq erasedCls then
137+
if erasedParent =:= erasedTp then
138138
Left(parent)
139139
else
140140
Right(parent))

compiler/src/dotty/tools/dotc/transform/localopt/StringInterpolatorOpt.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class StringInterpolatorOpt extends MiniPhase {
121121
(sym.name == nme.f && sym.eq(defn.StringContext_f)) ||
122122
(sym.name == nme.s && sym.eq(defn.StringContext_s))
123123
if (isInterpolatedMethod)
124-
tree match {
124+
(tree: @unchecked) match {
125125
case StringContextIntrinsic(strs: List[Literal], elems: List[Tree]) =>
126126
val stri = strs.iterator
127127
val elemi = elems.iterator

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,17 @@ trait SpaceLogic {
113113
/** Display space in string format */
114114
def show(sp: Space): String
115115

116-
/** Simplify space using the laws, there's no nested union after simplify */
116+
/** Simplify space such that a space equal to `Empty` becomes `Empty` */
117117
def simplify(space: Space)(using Context): Space = trace(s"simplify ${show(space)} --> ", debug, x => show(x.asInstanceOf[Space]))(space match {
118118
case Prod(tp, fun, spaces) =>
119-
val sp = Prod(tp, fun, spaces.map(simplify(_)))
120-
if (sp.params.contains(Empty)) Empty
119+
val sps = spaces.map(simplify(_))
120+
if (sps.contains(Empty)) Empty
121121
else if (canDecompose(tp) && decompose(tp).isEmpty) Empty
122-
else sp
122+
else Prod(tp, fun, sps)
123123
case Or(spaces) =>
124124
val spaces2 = spaces.map(simplify(_)).filter(_ != Empty)
125125
if spaces2.isEmpty then Empty
126+
else if spaces2.lengthCompare(1) == 0 then spaces2.head
126127
else Or(spaces2)
127128
case Typ(tp, _) =>
128129
if (canDecompose(tp) && decompose(tp).isEmpty) Empty
@@ -243,10 +244,10 @@ trait SpaceLogic {
243244
tryDecompose1(tp1)
244245
else
245246
a
246-
case (_, Or(ss)) =>
247-
ss.foldLeft(a)(minus)
248247
case (Or(ss), _) =>
249248
Or(ss.map(minus(_, b)))
249+
case (_, Or(ss)) =>
250+
ss.foldLeft(a)(minus)
250251
case (Prod(tp1, fun, ss), Typ(tp2, _)) =>
251252
// uncovered corner case: tp2 :< tp1, may happen when inheriting case class
252253
if (isSubType(tp1, tp2))
@@ -272,7 +273,10 @@ trait SpaceLogic {
272273
else if cache.forall(sub => isSubspace(sub, Empty)) then Empty
273274
else
274275
// `(_, _, _) - (Some, None, _)` becomes `(None, _, _) | (_, Some, _) | (_, _, Empty)`
275-
Or(LazyList(range: _*).map { i => Prod(tp1, fun1, ss1.updated(i, sub(i))) })
276+
val spaces = LazyList(range: _*).flatMap { i =>
277+
flatten(sub(i)).map(s => Prod(tp1, fun1, ss1.updated(i, s)))
278+
}
279+
Or(spaces)
276280
}
277281
}
278282
}
@@ -771,7 +775,7 @@ class SpaceEngine(using Context) extends SpaceLogic {
771775
if (ctx.definitions.isTupleType(tp))
772776
"(" + params.map(doShow(_)).mkString(", ") + ")"
773777
else if (tp.isRef(scalaConsType.symbol))
774-
if (flattenList) params.map(doShow(_, flattenList)).mkString(", ")
778+
if (flattenList) params.map(doShow(_, flattenList)).filter(_.nonEmpty).mkString(", ")
775779
else params.map(doShow(_, flattenList = true)).filter(!_.isEmpty).mkString("List(", ", ", ")")
776780
else {
777781
val sym = fun.symbol
@@ -791,16 +795,18 @@ class SpaceEngine(using Context) extends SpaceLogic {
791795
def isCheckable(tp: Type): Boolean =
792796
!tp.hasAnnotation(defn.UncheckedAnnot) && {
793797
val tpw = tp.widen.dealias
798+
val classSym = tpw.classSymbol
794799
ctx.settings.YcheckAllPatmat.value ||
795-
tpw.typeSymbol.is(Sealed) ||
800+
classSym.is(Sealed) ||
796801
tpw.isInstanceOf[OrType] ||
797802
(tpw.isInstanceOf[AndType] && {
798803
val and = tpw.asInstanceOf[AndType]
799804
isCheckable(and.tp1) || isCheckable(and.tp2)
800805
}) ||
801806
tpw.isRef(defn.BooleanClass) ||
802-
tpw.typeSymbol.isAllOf(JavaEnumTrait) ||
803-
(defn.isTupleType(tpw) && tpw.argInfos.exists(isCheckable(_)))
807+
classSym.isAllOf(JavaEnumTrait) ||
808+
(defn.isProductSubType(tpw) && classSym.is(Case)
809+
&& productSelectorTypes(tpw, sel.srcPos).exists(isCheckable(_)))
804810
}
805811

806812
val res = isCheckable(sel.tpe)

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ trait Applications extends Compatibility {
990990
* { val xs = es; e' = e' + args }
991991
*/
992992
def typedOpAssign(using Context): Tree = {
993-
val (lhs1, name, rhss) = tree match
993+
val (lhs1, name, rhss) = (tree: @unchecked) match
994994
case Apply(Select(lhs, name), rhss) => (typedExpr(lhs), name, rhss)
995995
case Apply(untpd.TypedSplice(Select(lhs1, name)), rhss) => (lhs1, name, rhss)
996996
val liftedDefs = new mutable.ListBuffer[Tree]

compiler/src/dotty/tools/dotc/typer/ImportSuggestions.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,15 @@ trait ImportSuggestions:
167167
allCandidates.map(_.implicitRef.underlyingRef.symbol).toSet
168168
}
169169

170+
def testContext(): Context =
171+
ctx.fresh.retractMode(Mode.ImplicitsEnabled).setExploreTyperState()
172+
170173
/** Test whether the head of a given instance matches the expected type `pt`,
171174
* ignoring any dependent implicit arguments.
172175
*/
173176
def shallowTest(ref: TermRef): Boolean =
174177
System.currentTimeMillis < deadLine
175-
&& inContext(ctx.fresh.setExploreTyperState()) {
178+
&& inContext(testContext()) {
176179
def test(pt: Type): Boolean = pt match
177180
case ViewProto(argType, OrType(rt1, rt2)) =>
178181
// Union types do not constrain results, since comparison with a union
@@ -209,7 +212,7 @@ trait ImportSuggestions:
209212
try
210213
timer.schedule(task, testOneImplicitTimeOut)
211214
typedImplicit(candidate, expectedType, argument, span)(
212-
using ctx.fresh.setExploreTyperState()).isSuccess
215+
using testContext()).isSuccess
213216
finally
214217
if task.cancel() then // timer task has not run yet
215218
assert(!ctx.run.isCancelled)

dist/bin/common

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ SBT_INTF=$(find_lib "*compiler-interface*")
159159
JLINE_READER=$(find_lib "*jline-reader-3*")
160160
JLINE_TERMINAL=$(find_lib "*jline-terminal-3*")
161161
JLINE_TERMINAL_JNA=$(find_lib "*jline-terminal-jna-3*")
162-
[[ ${conemu-} ]] || JNA=$(find_lib "*jna-5*")
163162

163+
# jna-5 only appropriate for some combinations
164+
[[ ${conemu-} && ${msys-} ]] || JNA=$(find_lib "*jna-5*")
164165

165166
compilerJavaClasspathArgs () {
166167
# echo "dotty-compiler: $DOTTY_COMP"

0 commit comments

Comments
 (0)