Skip to content

Commit f414dc8

Browse files
committed
Merge branch 'main' of https://github.com/rochala/dotty into fix-uncompiling-snippets
2 parents 7af9a40 + 8c404b1 commit f414dc8

File tree

78 files changed

+3436
-235
lines changed

Some content is hidden

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

78 files changed

+3436
-235
lines changed

.github/workflows/ci.yaml

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ jobs:
115115
./project/scripts/cmdTests
116116
./project/scripts/bootstrappedOnlyCmdTests
117117
118-
- name: MiMa
119-
run: |
120-
./project/scripts/sbt ";scala3-interfaces/mimaReportBinaryIssues ;scala3-library-bootstrapped/mimaReportBinaryIssues ;scala3-library-bootstrappedJS/mimaReportBinaryIssues; tasty-core-bootstrapped/mimaReportBinaryIssues"
121-
122118
test_windows_fast:
123119
runs-on: [self-hosted, Windows]
124120
if: "(
@@ -189,6 +185,47 @@ jobs:
189185
run: sbt ";sjsJUnitTests/test ;sjsCompilerTests/test"
190186
shell: cmd
191187

188+
mima:
189+
name: MiMa
190+
runs-on: [self-hosted, Linux]
191+
container:
192+
image: lampepfl/dotty:2021-03-22
193+
options: --cpu-shares 4096
194+
volumes:
195+
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
196+
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
197+
- ${{ github.workspace }}/../../cache/general:/root/.cache
198+
if: "github.event_name == 'schedule' && github.repository == 'lampepfl/dotty'
199+
|| github.event_name == 'push'
200+
|| (
201+
github.event_name == 'pull_request'
202+
&& !contains(github.event.pull_request.body, '[skip ci]')
203+
&& !contains(github.event.pull_request.body, '[skip mima]')
204+
)
205+
|| (
206+
github.event_name == 'workflow_dispatch'
207+
&& github.repository == 'lampepfl/dotty'
208+
)"
209+
steps:
210+
- name: Reset existing repo
211+
run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true
212+
213+
- name: Checkout cleanup script
214+
uses: actions/checkout@v2
215+
216+
- name: Cleanup
217+
run: .github/workflows/cleanup.sh
218+
219+
- name: Git Checkout
220+
uses: actions/checkout@v2
221+
222+
- name: Add SBT proxy repositories
223+
run: cp -vf .github/workflows/repositories /root/.sbt/ ; true
224+
225+
- name: MiMa
226+
run: |
227+
./project/scripts/sbt ";scala3-interfaces/mimaReportBinaryIssues ;scala3-library-bootstrapped/mimaReportBinaryIssues ;scala3-library-bootstrappedJS/mimaReportBinaryIssues; tasty-core-bootstrapped/mimaReportBinaryIssues"
228+
192229
community_build_a:
193230
runs-on: [self-hosted, Linux]
194231
container:
@@ -472,7 +509,7 @@ jobs:
472509
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
473510
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
474511
- ${{ github.workspace }}/../../cache/general:/root/.cache
475-
needs: [test_non_bootstrapped, test, community_build_a, community_build_b, community_build_c, community_build_forward_compat, test_sbt, test_java8]
512+
needs: [test_non_bootstrapped, test, mima, community_build_a, community_build_b, community_build_c, community_build_forward_compat, test_sbt, test_java8]
476513
if: "(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.repository == 'lampepfl/dotty'"
477514
env:
478515
NIGHTLYBUILD: yes
@@ -573,7 +610,7 @@ jobs:
573610
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
574611
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
575612
- ${{ github.workspace }}/../../cache/general:/root/.cache
576-
needs: [test_non_bootstrapped, test, community_build_a, community_build_b, community_build_c, test_sbt, test_java8]
613+
needs: [test_non_bootstrapped, test, mima, community_build_a, community_build_b, community_build_c, test_sbt, test_java8]
577614
if: "github.event_name == 'push'
578615
&& startsWith(github.event.ref, 'refs/tags/')"
579616

@@ -600,11 +637,10 @@ jobs:
600637
- name: Add SBT proxy repositories
601638
run: cp -vf .github/workflows/repositories /root/.sbt/ ; true
602639

603-
- name: Publish Release
640+
- name: Prepare Release
604641
run: |
605642
./project/scripts/sbt dist/packArchive
606643
sha256sum dist/target/scala3-* > dist/target/sha256sum.txt
607-
./project/scripts/sbtPublish ";project scala3-bootstrapped ;publishSigned ;sonatypeBundleRelease"
608644
echo "RELEASE_TAG=${GITHUB_REF#*refs/tags/}" >> $GITHUB_ENV
609645
610646
- name: Create GitHub Release
@@ -615,9 +651,9 @@ jobs:
615651
with:
616652
tag_name: ${{ github.ref }}
617653
release_name: ${{ github.ref }}
618-
body:
619-
draft: false
620-
prerelease: ${{ contains(env.RELEASE_TAG, 'M') }}
654+
body_path: ./changelogs/${{ env.RELEASE_TAG }}.md
655+
draft: true
656+
prerelease: ${{ contains(env.RELEASE_TAG, '-') }}
621657

622658
- name: Upload zip archive to GitHub Release
623659
uses: actions/upload-release-asset@v1
@@ -649,6 +685,10 @@ jobs:
649685
asset_name: sha256sum.txt
650686
asset_content_type: text/plain
651687

688+
- name: Publish Release
689+
run: ./project/scripts/sbtPublish ";project scala3-bootstrapped ;publishSigned ;sonatypeBundleRelease"
690+
691+
652692
open_issue_on_failure:
653693
runs-on: [self-hosted, Linux]
654694
container:

.github/workflows/scaladoc.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ jobs:
5252
- name: Generate testcases documentation
5353
run: ./project/scripts/sbt scaladoc/generateTestcasesDocumentation
5454

55-
- name: Generate reference documentation
56-
run: ./project/scripts/sbt scaladoc/generateReferenceDocumentation
55+
- name: Generate reference documentation and check links stability
56+
run: |
57+
./project/scripts/sbt scaladoc/generateReferenceDocumentation
58+
./project/scripts/docsLinksStability ./scaladoc/output/reference ./project/scripts/expected-links/reference-expected-links.txt
5759
58-
- name: Generate Scala 3 documentation
59-
run: ./project/scripts/sbt scaladoc/generateScalaDocumentation
60+
- name: Generate Scala 3 documentation and check links stability
61+
run: |
62+
./project/scripts/sbt scaladoc/generateScalaDocumentation
63+
./project/scripts/docsLinksStability ./scaladoc/output/scala3 ./project/scripts/expected-links/scala3-expected-links.txt
6064
6165
- name: Generate documentation for example project using dotty-sbt
6266
run: ./project/scripts/sbt "sbt-test/scripted sbt-dotty/scaladoc"
@@ -74,7 +78,7 @@ jobs:
7478
DOC_DEST=$(echo pr-${PR_NUMBER:-${GITHUB_REF##*/}} | tr -d -c "[-A-Za-z0-9]")
7579
echo uplading docs to https://scala3doc.virtuslab.com/$DOC_DEST
7680
az storage container create --name $DOC_DEST --account-name scala3docstorage --public-access container
77-
az storage blob upload-batch -s scaladoc/output -d $DOC_DEST --account-name scala3docstorage
81+
az storage blob upload-batch --overwrite true -s scaladoc/output -d $DOC_DEST --account-name scala3docstorage
7882
7983
stdlib-sourcelinks-test:
8084
runs-on: ubuntu-latest

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,13 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
744744
}
745745

746746
def tryBaseType(cls2: Symbol) = {
747+
val allowBaseType = !caseLambda.exists || (tp1 match {
748+
case tp: TypeRef if tp.symbol.isClass => true
749+
case AppliedType(tycon: TypeRef, _) if tycon.symbol.isClass => true
750+
case _ => false
751+
})
747752
val base = nonExprBaseType(tp1, cls2)
748-
if (base.exists && (base `ne` tp1))
753+
if (base.exists && base.ne(tp1) && allowBaseType)
749754
isSubType(base, tp2, if (tp1.isRef(cls2)) approx else approx.addLow) ||
750755
base.isInstanceOf[OrType] && fourthTry
751756
// if base is a disjunction, this might have come from a tp1 type that
@@ -764,7 +769,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
764769
|| narrowGADTBounds(tp1, tp2, approx, isUpper = true))
765770
&& (tp2.isAny || GADTusage(tp1.symbol))
766771

767-
isSubType(hi1, tp2, approx.addLow) || compareGADT || tryLiftedToThis1
772+
!caseLambda.exists && isSubType(hi1, tp2, approx.addLow) || compareGADT || tryLiftedToThis1
768773
case _ =>
769774
// `Mode.RelaxedOverriding` is only enabled when checking Java overriding
770775
// in explicit nulls, and `Null` becomes a bottom type, which allows
@@ -2535,8 +2540,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
25352540
def fullyInstantiated(tp: Type): Boolean = new TypeAccumulator[Boolean] {
25362541
override def apply(x: Boolean, t: Type) =
25372542
x && {
2538-
t match {
2539-
case tp: TypeRef if tp.symbol.isAbstractOrParamType => false
2543+
t.dealias match {
2544+
case tp: TypeRef if !tp.symbol.isClass => false
25402545
case _: SkolemType | _: TypeVar | _: TypeParamRef => false
25412546
case _ => foldOver(x, t)
25422547
}

compiler/src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ abstract class Reporter extends interfaces.ReporterResult {
153153
case w: Warning if ctx.settings.XfatalWarnings.value => w.toError
154154
case _ => dia
155155
if !isHidden(d) then // avoid isHidden test for summarized warnings so that message is not forced
156+
markReported(d)
156157
withMode(Mode.Printing)(doReport(d))
157158
d match {
158159
case _: Warning => _warningCount += 1
@@ -236,6 +237,8 @@ abstract class Reporter extends interfaces.ReporterResult {
236237
def isHidden(dia: Diagnostic)(using Context): Boolean =
237238
ctx.mode.is(Mode.Printing)
238239

240+
def markReported(dia: Diagnostic)(using Context): Unit = ()
241+
239242
/** Does this reporter contain errors that have yet to be reported by its outer reporter ?
240243
* Note: this is always false when there is no outer reporter.
241244
*/

compiler/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,27 @@ trait UniqueMessagePositions extends Reporter {
1212

1313
private val positions = new mutable.HashMap[(SourceFile, Integer), Diagnostic]
1414

15+
extension (dia1: Diagnostic)
16+
private def hides(dia2: Diagnostic)(using Context): Boolean =
17+
if dia2.msg.showAlways then dia1.msg.getClass == dia2.msg.getClass
18+
else dia1.level >= dia2.level
19+
1520
/** Logs a position and returns true if it was already logged.
1621
* @note Two positions are considered identical for logging if they have the same point.
1722
*/
1823
override def isHidden(dia: Diagnostic)(using Context): Boolean =
19-
extension (dia1: Diagnostic) def hides(dia2: Diagnostic): Boolean =
20-
if dia2.msg.showAlways then dia1.msg.getClass == dia2.msg.getClass
21-
else dia1.level >= dia2.level
22-
super.isHidden(dia) || {
24+
super.isHidden(dia)
25+
||
2326
dia.pos.exists
2427
&& !ctx.settings.YshowSuppressedErrors.value
25-
&& {
26-
var shouldHide = false
27-
for (pos <- dia.pos.start to dia.pos.end)
28-
positions get (ctx.source, pos) match {
29-
case Some(dia1) if dia1.hides(dia) => shouldHide = true
30-
case _ => positions((ctx.source, pos)) = dia
31-
}
32-
shouldHide
33-
}
34-
}
28+
&& (dia.pos.start to dia.pos.end).exists(pos =>
29+
positions.get((ctx.source, pos)).exists(_.hides(dia)))
30+
31+
override def markReported(dia: Diagnostic)(using Context): Unit =
32+
if dia.pos.exists then
33+
for (pos <- dia.pos.start to dia.pos.end)
34+
positions.get(ctx.source, pos) match
35+
case Some(dia1) if dia1.hides(dia) =>
36+
case _ => positions((ctx.source, pos)) = dia
37+
super.markReported(dia)
3538
}

compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,12 @@ class ExtractSemanticDB extends Phase:
234234
val sym = tree.symbol.adjustIfCtorTyparam
235235
if qualSpan.exists && qualSpan.hasLength then
236236
traverse(qual)
237-
registerUseGuarded(qual.symbol.ifExists, sym, selectSpan(tree), tree.source)
237+
if (sym != NoSymbol)
238+
registerUseGuarded(qual.symbol.ifExists, sym, selectSpan(tree), tree.source)
239+
else
240+
qual.symbol.info.lookupSym(tree.name).foreach(sym =>
241+
registerUseGuarded(qual.symbol.ifExists, sym, selectSpan(tree), tree.source)
242+
)
238243
case tree: Import =>
239244
if tree.span.exists && tree.span.hasLength then
240245
traverseChildren(tree)
@@ -422,19 +427,22 @@ class ExtractSemanticDB extends Phase:
422427
else
423428
val symkinds = mutable.HashSet.empty[SymbolKind]
424429
tree match
425-
case tree: ValDef =>
426-
if !tree.symbol.is(Param) then
427-
symkinds += (if tree.mods is Mutable then SymbolKind.Var else SymbolKind.Val)
428-
if tree.rhs.isEmpty && !tree.symbol.isOneOf(TermParam | CaseAccessor | ParamAccessor) then
429-
symkinds += SymbolKind.Abstract
430-
case tree: DefDef =>
431-
if tree.isSetterDef then
432-
symkinds += SymbolKind.Setter
433-
else if tree.rhs.isEmpty then
434-
symkinds += SymbolKind.Abstract
435-
case tree: Bind =>
436-
symkinds += SymbolKind.Val
437-
case _ =>
430+
case tree: ValDef =>
431+
if !tree.symbol.is(Param) then
432+
symkinds += (if tree.mods is Mutable then SymbolKind.Var else SymbolKind.Val)
433+
if tree.rhs.isEmpty && !tree.symbol.isOneOf(TermParam | CaseAccessor | ParamAccessor) then
434+
symkinds += SymbolKind.Abstract
435+
case tree: DefDef =>
436+
if tree.isSetterDef then
437+
symkinds += SymbolKind.Setter
438+
else if tree.rhs.isEmpty then
439+
symkinds += SymbolKind.Abstract
440+
// if symbol isType, it's type variable
441+
case tree: Bind if (!tree.symbol.isType) =>
442+
symkinds += SymbolKind.Val
443+
case tree: Bind if (tree.symbol.isType) =>
444+
symkinds += SymbolKind.TypeVal
445+
case _ =>
438446
symkinds.toSet
439447

440448
private def ctorParams(

compiler/src/dotty/tools/dotc/semanticdb/PPrint.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,12 @@ class SymbolInformationPrinter (symtab: PrinterSymtab):
191191
s"=> ${normal(utpe)}"
192192
case RepeatedType(utpe) =>
193193
s"${normal(utpe)}*"
194-
case _ =>
194+
case MatchType(scrutinee, cases) =>
195+
val casesStr = cases.map { caseType =>
196+
s"${pprint(caseType.key)} => ${pprint(caseType.body)}"
197+
}.mkString(", ")
198+
s"${pprint(scrutinee)} match { ${casesStr} }"
199+
case x =>
195200
"<?>"
196201

197202
def normal(tpe: Type): String = tpe match

compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import core.StdNames.nme
1212
import SymbolInformation.{Kind => k}
1313
import dotty.tools.dotc.util.SourceFile
1414
import dotty.tools.dotc.util.Spans.Span
15+
import dotty.tools.dotc.core.Names.Designator
1516

1617
import java.lang.Character.{isJavaIdentifierPart, isJavaIdentifierStart}
1718

@@ -34,23 +35,30 @@ object Scala3:
3435
val (endLine, endCol) = lineCol(span.end)
3536
Some(Range(startLine, startCol, endLine, endCol))
3637

37-
def namePresentInSource(sym: Symbol, span: Span, source:SourceFile)(using Context): Boolean =
38+
def namePresentInSource(desig: Designator, span: Span, source:SourceFile)(using Context): Boolean =
3839
if !span.exists then false
3940
else
4041
val content = source.content()
4142
val (start, end) =
4243
if content.lift(span.end - 1).exists(_ == '`') then
4344
(span.start + 1, span.end - 1)
4445
else (span.start, span.end)
46+
// println(s"${start}, $end")
4547
val nameInSource = content.slice(start, end).mkString
4648
// for secondary constructors `this`
47-
if sym.isConstructor && nameInSource == nme.THISkw.toString then
48-
true
49-
else
50-
val target =
51-
if sym.isPackageObject then sym.owner
52-
else sym
53-
nameInSource == target.name.stripModuleClassSuffix.lastPart.toString
49+
desig match
50+
case sym: Symbol =>
51+
if sym.isConstructor && nameInSource == nme.THISkw.toString then
52+
true
53+
else
54+
val target =
55+
if sym.isPackageObject then sym.owner
56+
else sym
57+
nameInSource == target.name.stripModuleClassSuffix.lastPart.toString
58+
case name: Name =>
59+
// println(nameInSource)
60+
// println(name.mangledString)
61+
nameInSource == name.mangledString
5462

5563
sealed trait FakeSymbol {
5664
private[Scala3] var sname: Option[String] = None
@@ -153,12 +161,13 @@ object Scala3:
153161
enum SymbolKind derives CanEqual:
154162
kind =>
155163

156-
case Val, Var, Setter, Abstract
164+
case Val, Var, Setter, Abstract, TypeVal
157165

158166
def isVar: Boolean = kind match
159167
case Var | Setter => true
160168
case _ => false
161169
def isVal: Boolean = kind == Val
170+
def isTypeVal: Boolean = kind == TypeVal
162171
def isVarOrVal: Boolean = kind.isVar || kind.isVal
163172

164173
end SymbolKind
@@ -309,7 +318,9 @@ object Scala3:
309318
props |= SymbolInformation.Property.IMPLICIT.value
310319
if sym.is(Lazy, butNot=Module) then
311320
props |= SymbolInformation.Property.LAZY.value
312-
if sym.isAllOf(Case | Module) || sym.is(CaseClass) || sym.isAllOf(EnumCase) then
321+
if sym.isAllOf(Case | Module) ||
322+
(sym.is(CaseClass) && !symkinds.exists(_.isTypeVal)) || // `t` of `case List[t] =>` (which has `CaseClass` flag) shouldn't be `CASE`
323+
sym.isAllOf(EnumCase) then
313324
props |= SymbolInformation.Property.CASE.value
314325
if sym.is(Covariant) then
315326
props |= SymbolInformation.Property.COVARIANT.value

0 commit comments

Comments
 (0)