Skip to content

Commit 1e26cc2

Browse files
authored
Merge branch 'master' into community-build/endpoints
2 parents 9291836 + 587945b commit 1e26cc2

File tree

191 files changed

+2266
-914
lines changed

Some content is hidden

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

191 files changed

+2266
-914
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,6 @@
9494
[submodule "community-build/community-projects/endpoints"]
9595
path = community-build/community-projects/endpoints
9696
url = [email protected]:dotty-staging/endpoints.git
97+
[submodule "community-build/community-projects/scalaz"]
98+
path = community-build/community-projects/scalaz
99+
url = https://github.com/dotty-staging/scalaz.git

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This is the process for committing code to the Scala project. There are of cours
1212
2. The ticket has been discussed and prioritized by the team.
1313
3. You should always perform your work in its own Git branch. The branch should be given a descriptive name that explains its intent. Some teams also like adding the ticket number and/or the [GitHub](http://github.com) user ID to the branch name, these details is up to each of the individual teams. (See below for more details on branch naming.)
1414
4. When the feature or fix is completed you should open a [Pull Request](https://help.github.com/articles/using-pull-requests) on GitHub.
15-
5. The Pull Request should be reviewed by other maintainers (as many as feasible/practical). Note that a reviewer can also be an outside contributor-- members of Typesafe and independent contributors are encouraged to participate in the review process. It is not a closed process. Please try to avoid conflict of interest -- the spirit of the review process is to evenly distribute the understanding of our code base across its maintainers as well as to load balance quality assurance. Assigning a review to a "sure win" reviewer is not a good long-term solution.
15+
5. The Pull Request should be reviewed by other maintainers (as many as feasible/practical). Note that a reviewer can also be an outside contributormembers of Typesafe and independent contributors are encouraged to participate in the review process. It is not a closed process. Please try to avoid conflict of interestthe spirit of the review process is to evenly distribute the understanding of our code base across its maintainers as well as to load balance quality assurance. Assigning a review to a "sure win" reviewer is not a good long-term solution.
1616
6. After the review, you should resolve issues brought up by the reviewers as needed (pushing a new commit to address reviewers' comments), iterating until the reviewers give their thumbs up, the "LGTM" (acronym for "Looks Good To Me").
1717
7. Once the code has passed review the Pull Request can be merged into the distribution.
1818

@@ -32,7 +32,7 @@ If *all* of these requirements are not met then the code should **not** be merge
3232

3333
## Documentation
3434

35-
All contributed code should come accompanied with documentation. Pull requests containing undocumented code will not be accepted. Both user-facing Scaladoc comments, as well as committer-facing internal documentation (i.e. important design decisions that other maintainers should know about should be placed inline with line comments `//`) should be accompanying all contributed code where possible.
35+
All contributed code should come accompanied by documentation. Pull requests containing undocumented code will not be accepted. Both user-facing Scaladoc comments, as well as committer-facing internal documentation (i.e. essential design decisions that other maintainers should know about should be placed inline with line comments `//`) should be accompanying all contributed code where possible.
3636

3737

3838
## Work In Progress
@@ -45,7 +45,7 @@ Also, to facilitate both well-formed commits and working together, the ``wip`` a
4545

4646
Follow these guidelines when creating public commits and writing commit messages.
4747

48-
1. If your work spans multiple local commits (for example; if you do safe point commits while working in a feature branch or work in a branch for long time doing merges/rebases etc.) then please do not commit it all but rewrite the history by squashing the commits into one large commit which is accompanied by a detailed commit message for (as discussed in the following sections). For more info, see the article: [Git Workflow](http://sandofsky.com/blog/git-workflow.html). Additionally, every commit should be able to be used in isolation-- that is, each commit must build and pass all tests.
48+
1. If your work spans multiple local commits (for example; if you do safe point commits while working in a feature branch or work in a branch for long time doing merges/rebases etc.) then please do not commit it all but rewrite the history by squashing the commits into one large commit which is accompanied by a detailed commit message for (as discussed in the following sections). For more info, see the article: [Git Workflow](http://sandofsky.com/blog/git-workflow.html). Additionally, every commit should be able to be used in isolationthat is, each commit must build and pass all tests.
4949
2. The first line should be a descriptive sentence about what the commit is doing. It should be possible to fully understand what the commit does by just reading this single line. It is **not ok** to only list the ticket number, type "minor fix" or similar. If the commit has a corresponding ticket, include a reference to the ticket number, prefixed with "Closes #", at the beginning of the first line followed by the title of the ticket, assuming that it aptly and concisely summarizes the commit in a single line. If the commit is a small fix, then you are done. If not, go to 3.
5050
3. Following the single line description (ideally no more than 70 characters long) should be a blank line followed by an enumerated list with the details of the commit.
5151
4. Add keywords for your commit (depending on the degree of automation we reach, the list may change over time):

NOTICE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ major authors were omitted by oversight.
8383
Adriaan Moors, Paul Phillips and others.
8484

8585
* dotty.tools.dottydoc: The Dottydoc documentation utility ships some
86-
third-party Javascript and CSS libraries which are located under
86+
third-party JavaScript and CSS libraries which are located under
8787
dotty-doc/resources/css/, dotty-doc/resources/js/, docs/css/ and
8888
docs/js/. Please refer to the license header of the concerned files for
8989
details.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ If you know anything useful at all about Dotty, feel free to log this knowledge:
3030
- [📜Log the Knowledge](https://github.com/lampepfl/dotty-knowledge/issues/new/choose)
3131
- [🎓More about Logging the Knowledge](https://github.com/lampepfl/dotty-knowledge/blob/master/README.md)
3232

33-
In short, no need to make it pretty, particularly human-readable or give it a particular structure. Just dump the knowledge you have and we'll take it from there.
33+
In short, no need to make it pretty, particularly human-readable or give it a particular structure. Just dump the knowledge you have, and we'll take it from there.
3434

3535
License
3636
=======

bench-run/src/main/scala/dotty/tools/benchmarks/Main.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.openjdk.jmh.runner.options._
88
import java.util.concurrent.TimeUnit
99

1010
import scala.io.Source
11+
import scala.util.Using
1112

1213
object Bench {
1314
def main(args: Array[String]): Unit = {
@@ -57,7 +58,7 @@ object Bench {
5758
}
5859

5960
def paramsFromFile(file: String): Array[(String, Array[String])] = {
60-
Source.fromFile(file).getLines.toArray.map { l =>
61+
Using(Source.fromFile(file))(_.getLines.toArray).get.map { l =>
6162
val Array(param, values) = l split ':'
6263
(param, values split ',')
6364
}

bench/src/main/scala/Benchmarks.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import java.util.concurrent.TimeUnit
1515
import java.io.{File, FileOutputStream, BufferedWriter, FileWriter}
1616
import scala.collection.JavaConverters._
1717
import scala.io.Source
18+
import scala.util.Using
1819

1920
object Bench {
2021
val COMPILE_OPTS_FILE = "compile.txt"
@@ -77,7 +78,7 @@ object Bench {
7778
}
7879

7980
def readCompileOptions: Seq[String] =
80-
Source.fromFile(COMPILE_OPTS_FILE).getLines.toSeq
81+
Using(Source.fromFile(COMPILE_OPTS_FILE))(_.getLines.toSeq).get
8182
}
8283

8384
@State(Scope.Benchmark)

bin/test/TestScripts.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.junit.{Before, After, Test}
55

66
import scala.io.Source
77
import scala.sys.process.{Process, ProcessLogger}
8+
import scala.util.Using
89
import java.io.{File => JFile, FileNotFoundException}
910

1011
class TestScripts {
@@ -29,7 +30,7 @@ class TestScripts {
2930

3031
private def deletePackages: Unit = {
3132
try {
32-
for (jar <- Source.fromFile("./.packages").getLines())
33+
for (jar <- Using(Source.fromFile("./.packages"))(_.getLines().toList).get)
3334
delete(jar)
3435

3536
delete("./.packages")
Submodule scalaz added at c36beee

community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ object projects:
283283
sbtTestCommand = ";json-schemaJVM/compile;algebraJVM/compile;openapiJVM/compile;http4s-server/compile;http4s-client/compile;play-server/compile;play-client/compile;akka-http-server/compile;akka-http-client/compile"
284284
)
285285

286+
lazy val scalaz = SbtCommunityProject(
287+
project = "scalaz",
288+
sbtTestCommand = "rootJVM/test",
289+
dependencies = List(scalacheck)
290+
)
291+
286292
end projects
287293

288294
@Category(Array(classOf[TestCategory]))
@@ -375,6 +381,7 @@ class CommunityBuildTest:
375381
@Test def scalaParserCombinators = projects.scalaParserCombinators.run()
376382
@Test def dottyCpsAsync = projects.dottyCpsAsync.run()
377383
@Test def endpoints = projects.endpoints.run()
384+
@Test def scalaz = projects.scalaz.run()
378385
end CommunityBuildTest
379386

380387
class TestCategory

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,10 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
483483
case NullTag => emit(asm.Opcodes.ACONST_NULL)
484484

485485
case ClazzTag =>
486-
val toPush: BType = {
487-
toTypeKind(const.typeValue) match {
488-
case kind: PrimitiveBType => boxedClassOfPrimitive(kind)
489-
case kind => kind
490-
}
491-
}
492-
mnode.visitLdcInsn(toPush.toASMType)
486+
val tp = toTypeKind(const.typeValue)
487+
// classOf[Int] is transformed to Integer.TYPE by ClassOf
488+
assert(!tp.isPrimitive, s"expected class type in classOf[T], found primitive type $tp")
489+
mnode.visitLdcInsn(tp.toASMType)
493490

494491
case EnumTag =>
495492
val sym = const.symbolValue

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ class Compiler {
6161
new CheckStatic, // Check restrictions that apply to @static members
6262
new BetaReduce, // Reduce closure applications
6363
new init.Checker) :: // Check initialization of objects
64-
List(new CompleteJavaEnums, // Fill in constructors for Java enums
65-
new ElimRepeated, // Rewrite vararg parameters and arguments
64+
List(new ElimRepeated, // Rewrite vararg parameters and arguments
6665
new ExpandSAMs, // Expand single abstract method closures to anonymous classes
6766
new ProtectedAccessors, // Add accessors for protected members
6867
new ExtensionMethods, // Expand methods of value classes with extension methods
@@ -101,6 +100,7 @@ class Compiler {
101100
new ArrayApply, // Optimize `scala.Array.apply([....])` and `scala.Array.apply(..., [....])` into `[...]`
102101
new ElimPolyFunction, // Rewrite PolyFunction subclasses to FunctionN subclasses
103102
new TailRec, // Rewrite tail recursion to loops
103+
new CompleteJavaEnums, // Fill in constructors for Java enums
104104
new Mixin, // Expand trait fields and trait initializers
105105
new LazyVals, // Expand lazy vals
106106
new Memoize, // Add private fields to getters and setters
@@ -146,6 +146,11 @@ class Compiler {
146146

147147
def newRun(implicit ctx: Context): Run = {
148148
reset()
149-
new Run(this, ctx)
149+
val rctx =
150+
if ctx.settings.Ysemanticdb.value
151+
ctx.addMode(Mode.ReadPositions)
152+
else
153+
ctx
154+
new Run(this, rctx)
150155
}
151156
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ object DesugarEnums {
124124

125125
/** A creation method for a value of enum type `E`, which is defined as follows:
126126
*
127-
* private def $new(_$ordinal: Int, $name: String) = new E {
127+
* private def $new(_$ordinal: Int, $name: String) = new E with scala.runtime.EnumValue {
128128
* def $ordinal = $tag
129129
* override def toString = $name
130130
* $values.register(this)
@@ -135,7 +135,7 @@ object DesugarEnums {
135135
val toStringDef = toStringMeth(Ident(nme.nameDollar))
136136
val creator = New(Template(
137137
constr = emptyConstructor,
138-
parents = enumClassRef :: Nil,
138+
parents = enumClassRef :: scalaRuntimeDot(tpnme.EnumValue) :: Nil,
139139
derived = Nil,
140140
self = EmptyValDef,
141141
body = List(ordinalDef, toStringDef) ++ registerCall
@@ -286,7 +286,9 @@ object DesugarEnums {
286286
val (tag, scaffolding) = nextOrdinal(CaseKind.Object)
287287
val ordinalDef = ordinalMethLit(tag)
288288
val toStringDef = toStringMethLit(name.toString)
289-
val impl1 = cpy.Template(impl)(body = List(ordinalDef, toStringDef) ++ registerCall)
289+
val impl1 = cpy.Template(impl)(
290+
parents = impl.parents :+ scalaRuntimeDot(tpnme.EnumValue),
291+
body = List(ordinalDef, toStringDef) ++ registerCall)
290292
.withAttachment(ExtendsSingletonMirror, ())
291293
val vdef = ValDef(name, TypeTree(), New(impl1)).withMods(mods.withAddedFlags(EnumValue, span))
292294
flatTree(scaffolding ::: vdef :: Nil).withSpan(span)

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,11 @@ object Trees {
669669
type ThisTree[-T >: Untyped] = LambdaTypeTree[T]
670670
}
671671

672+
case class TermLambdaTypeTree[-T >: Untyped] private[ast] (params: List[ValDef[T]], body: Tree[T])(implicit @constructorOnly src: SourceFile)
673+
extends TypTree[T] {
674+
type ThisTree[-T >: Untyped] = TermLambdaTypeTree[T]
675+
}
676+
672677
/** [bound] selector match { cases } */
673678
case class MatchTypeTree[-T >: Untyped] private[ast] (bound: Tree[T], selector: Tree[T], cases: List[CaseDef[T]])(implicit @constructorOnly src: SourceFile)
674679
extends TypTree[T] {
@@ -964,6 +969,7 @@ object Trees {
964969
type RefinedTypeTree = Trees.RefinedTypeTree[T]
965970
type AppliedTypeTree = Trees.AppliedTypeTree[T]
966971
type LambdaTypeTree = Trees.LambdaTypeTree[T]
972+
type TermLambdaTypeTree = Trees.TermLambdaTypeTree[T]
967973
type MatchTypeTree = Trees.MatchTypeTree[T]
968974
type ByNameTypeTree = Trees.ByNameTypeTree[T]
969975
type TypeBoundsTree = Trees.TypeBoundsTree[T]
@@ -1135,6 +1141,10 @@ object Trees {
11351141
case tree: LambdaTypeTree if (tparams eq tree.tparams) && (body eq tree.body) => tree
11361142
case _ => finalize(tree, untpd.LambdaTypeTree(tparams, body)(sourceFile(tree)))
11371143
}
1144+
def TermLambdaTypeTree(tree: Tree)(params: List[ValDef], body: Tree)(implicit ctx: Context): TermLambdaTypeTree = tree match {
1145+
case tree: TermLambdaTypeTree if (params eq tree.params) && (body eq tree.body) => tree
1146+
case _ => finalize(tree, untpd.TermLambdaTypeTree(params, body)(sourceFile(tree)))
1147+
}
11381148
def MatchTypeTree(tree: Tree)(bound: Tree, selector: Tree, cases: List[CaseDef])(implicit ctx: Context): MatchTypeTree = tree match {
11391149
case tree: MatchTypeTree if (bound eq tree.bound) && (selector eq tree.selector) && (cases eq tree.cases) => tree
11401150
case _ => finalize(tree, untpd.MatchTypeTree(bound, selector, cases)(sourceFile(tree)))
@@ -1293,6 +1303,10 @@ object Trees {
12931303
inContext(localCtx) {
12941304
cpy.LambdaTypeTree(tree)(transformSub(tparams), transform(body))
12951305
}
1306+
case TermLambdaTypeTree(params, body) =>
1307+
inContext(localCtx) {
1308+
cpy.TermLambdaTypeTree(tree)(transformSub(params), transform(body))
1309+
}
12961310
case MatchTypeTree(bound, selector, cases) =>
12971311
cpy.MatchTypeTree(tree)(transform(bound), transform(selector), transformSub(cases))
12981312
case ByNameTypeTree(result) =>
@@ -1422,6 +1436,10 @@ object Trees {
14221436
inContext(localCtx) {
14231437
this(this(x, tparams), body)
14241438
}
1439+
case TermLambdaTypeTree(params, body) =>
1440+
inContext(localCtx) {
1441+
this(this(x, params), body)
1442+
}
14251443
case MatchTypeTree(bound, selector, cases) =>
14261444
this(this(this(x, bound), selector), cases)
14271445
case ByNameTypeTree(result) =>

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
378378
def RefinedTypeTree(tpt: Tree, refinements: List[Tree])(implicit src: SourceFile): RefinedTypeTree = new RefinedTypeTree(tpt, refinements)
379379
def AppliedTypeTree(tpt: Tree, args: List[Tree])(implicit src: SourceFile): AppliedTypeTree = new AppliedTypeTree(tpt, args)
380380
def LambdaTypeTree(tparams: List[TypeDef], body: Tree)(implicit src: SourceFile): LambdaTypeTree = new LambdaTypeTree(tparams, body)
381+
def TermLambdaTypeTree(params: List[ValDef], body: Tree)(implicit src: SourceFile): TermLambdaTypeTree = new TermLambdaTypeTree(params, body)
381382
def MatchTypeTree(bound: Tree, selector: Tree, cases: List[CaseDef])(implicit src: SourceFile): MatchTypeTree = new MatchTypeTree(bound, selector, cases)
382383
def ByNameTypeTree(result: Tree)(implicit src: SourceFile): ByNameTypeTree = new ByNameTypeTree(result)
383384
def TypeBoundsTree(lo: Tree, hi: Tree, alias: Tree = EmptyTree)(implicit src: SourceFile): TypeBoundsTree = new TypeBoundsTree(lo, hi, alias)
@@ -450,6 +451,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
450451
def rootDot(name: Name)(implicit src: SourceFile): Select = Select(Ident(nme.ROOTPKG), name)
451452
def scalaDot(name: Name)(implicit src: SourceFile): Select = Select(rootDot(nme.scala), name)
452453
def scalaAnnotationDot(name: Name)(using SourceFile): Select = Select(scalaDot(nme.annotation), name)
454+
def scalaRuntimeDot(name: Name)(using SourceFile): Select = Select(scalaDot(nme.runtime), name)
453455
def scalaUnit(implicit src: SourceFile): Select = scalaDot(tpnme.Unit)
454456
def scalaAny(implicit src: SourceFile): Select = scalaDot(tpnme.Any)
455457
def javaDotLangDot(name: Name)(implicit src: SourceFile): Select = Select(Select(Ident(nme.java), nme.lang), name)
@@ -486,8 +488,14 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
486488
ValDef(nme.syntheticParamName(n), if (tpt == null) TypeTree() else tpt, EmptyTree)
487489
.withFlags(flags)
488490

489-
def lambdaAbstract(tparams: List[TypeDef], tpt: Tree)(implicit ctx: Context): Tree =
490-
if (tparams.isEmpty) tpt else LambdaTypeTree(tparams, tpt)
491+
def lambdaAbstract(params: List[ValDef] | List[TypeDef], tpt: Tree)(using Context): Tree =
492+
params match
493+
case Nil => tpt
494+
case (vd: ValDef) :: _ => TermLambdaTypeTree(params.asInstanceOf[List[ValDef]], tpt)
495+
case _ => LambdaTypeTree(params.asInstanceOf[List[TypeDef]], tpt)
496+
497+
def lambdaAbstractAll(paramss: List[List[ValDef] | List[TypeDef]], tpt: Tree)(using Context): Tree =
498+
paramss.foldRight(tpt)(lambdaAbstract)
491499

492500
/** A reference to given definition. If definition is a repeated
493501
* parameter, the reference will be a repeated argument.

compiler/src/dotty/tools/dotc/config/Feature.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dotc
33
package config
44

55
import core._
6-
import Contexts._, Symbols._, Names._
6+
import Contexts._, Symbols._, Names._, NameOps._
77
import StdNames.nme
88
import Decorators.{given _}
99
import util.SourcePosition
@@ -22,7 +22,7 @@ object Feature:
2222
def enabledBySetting(feature: TermName, owner: Symbol = NoSymbol)(using Context): Boolean =
2323
def toPrefix(sym: Symbol): String =
2424
if !sym.exists || sym == defn.LanguageModule.moduleClass then ""
25-
else toPrefix(sym.owner) + sym.name + "."
25+
else toPrefix(sym.owner) + sym.name.stripModuleClassSuffix + "."
2626
val prefix = if owner.exists then toPrefix(owner) else ""
2727
ctx.base.settings.language.value.contains(prefix + feature)
2828

@@ -38,7 +38,7 @@ object Feature:
3838
def enabledByImport(feature: TermName, owner: Symbol = NoSymbol)(using Context): Boolean =
3939
ctx.atPhase(ctx.typerPhase) {
4040
ctx.importInfo != null
41-
&& ctx.importInfo.featureImported(feature.toTermName,
41+
&& ctx.importInfo.featureImported(feature,
4242
if owner.exists then owner else defn.LanguageModule.moduleClass)
4343
}
4444

@@ -57,6 +57,9 @@ object Feature:
5757
def dynamicsEnabled(using Context): Boolean =
5858
enabled(nme.dynamics)
5959

60+
def dependentEnabled(using Context) =
61+
enabled(nme.dependent, defn.LanguageExperimentalModule.moduleClass)
62+
6063
def sourceVersionSetting(using Context): SourceVersion =
6164
SourceVersion.valueOf(ctx.settings.source.value)
6265

0 commit comments

Comments
 (0)