Skip to content

Commit ef3dacb

Browse files
Merge branch 'master' into 0.25.x
2 parents c89cf41 + cc4eeb5 commit ef3dacb

File tree

75 files changed

+2916
-152
lines changed

Some content is hidden

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

75 files changed

+2916
-152
lines changed

README.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
Dotty
22
=====
3-
[![Build Status](http://dotty-ci.epfl.ch/api/badges/lampepfl/dotty/status.svg)](http://dotty-ci.epfl.ch/lampepfl/dotty)
43
[![Dotty CI](https://github.com/lampepfl/dotty/workflows/Dotty%20CI/badge.svg?branch=master)](https://github.com/lampepfl/dotty/actions?query=branch%3Amaster)
54
[![Join the chat at https://gitter.im/lampepfl/dotty](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/lampepfl/dotty?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
6-
[![Log Knowledge](https://img.shields.io/badge/log-knowledge-blueviolet.svg)](https://github.com/lampepfl/dotty-knowledge/issues/new/choose)
7-
85

96
* [Homepage](http://dotty.epfl.ch)
10-
* [Documentation](https://dotty.epfl.ch/docs) [![Deadlink Status](https://travis-ci.org/nicolasstucki/dotty-website-linkcheck.svg?branch=master)](https://travis-ci.org/nicolasstucki/dotty-website-linkcheck)
7+
* [Documentation](https://dotty.epfl.ch/docs)
118

129
Try it out
1310
==========
@@ -24,14 +21,6 @@ How to Contribute
2421
* [Getting Started as Contributor](https://dotty.epfl.ch/docs/contributing/getting-started.html)
2522
* [Issues](https://github.com/lampepfl/dotty/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
2623

27-
## Contribute Internals-related Knowledge
28-
If you know anything useful at all about Dotty, feel free to log this knowledge:
29-
30-
- [📜Log the Knowledge](https://github.com/lampepfl/dotty-knowledge/issues/new/choose)
31-
- [🎓More about Logging the Knowledge](https://github.com/lampepfl/dotty-knowledge/blob/master/README.md)
32-
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.
34-
3524
License
3625
=======
3726
Dotty is licensed under the [Apache License Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,9 +1531,9 @@ class JSCodeGen()(implicit ctx: Context) {
15311531
case jstpe.LongType =>
15321532
js.BinaryOp(js.BinaryOp.Long_-, js.LongLiteral(0), genArg)
15331533
case jstpe.FloatType =>
1534-
js.BinaryOp(js.BinaryOp.Float_-, js.FloatLiteral(0.0f), genArg)
1534+
js.BinaryOp(js.BinaryOp.Float_*, js.FloatLiteral(-1.0f), genArg)
15351535
case jstpe.DoubleType =>
1536-
js.BinaryOp(js.BinaryOp.Double_-, js.DoubleLiteral(0), genArg)
1536+
js.BinaryOp(js.BinaryOp.Double_*, js.DoubleLiteral(-1.0), genArg)
15371537
}
15381538

15391539
case NOT =>

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ import scala.util.control.NonFatal
3131
/** A compiler run. Exports various methods to compile source files */
3232
class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with ConstraintRunInfo {
3333

34+
/** Default timeout to stop looking for further implicit suggestions, in ms.
35+
* This is usually for the first import suggestion; subsequent suggestions
36+
* may get smaller timeouts. @see ImportSuggestions.reduceTimeBudget
37+
*/
38+
private var myImportSuggestionBudget: Int =
39+
Int.MinValue // sentinel value; means whatever is set in command line option
40+
41+
def importSuggestionBudget =
42+
if myImportSuggestionBudget == Int.MinValue then ictx.settings.XimportSuggestionTimeout.value
43+
else myImportSuggestionBudget
44+
45+
def importSuggestionBudget_=(x: Int) =
46+
myImportSuggestionBudget = x
47+
3448
/** If this variable is set to `true`, some core typer operations will
3549
* return immediately. Currently these early abort operations are
3650
* `Typer.typed` and `Implicits.typedImplicit`.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ object desugar {
11281128
case TypeDef(_, rhs) =>
11291129
def rhsOK(tree: Tree): Boolean = tree match {
11301130
case bounds: TypeBoundsTree => !bounds.alias.isEmpty
1131-
case _: Template => false
1131+
case _: Template | _: MatchTypeTree => false
11321132
case LambdaTypeTree(_, body) => rhsOK(body)
11331133
case _ => true
11341134
}

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
421421
t
422422
}
423423

424-
def singleton(tp: Type)(implicit ctx: Context): Tree = tp match {
424+
def singleton(tp: Type)(implicit ctx: Context): Tree = tp.dealias match {
425425
case tp: TermRef => ref(tp)
426426
case tp: ThisType => This(tp.cls)
427427
case tp: SkolemType => singleton(tp.narrow)
@@ -1214,6 +1214,12 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
12141214
/** A key to be used in a context property that tracks enclosing inlined calls */
12151215
private val InlinedCalls = Property.Key[List[Tree]]()
12161216

1217+
/** A key to be used in a context property that tracks the number of inlined trees */
1218+
private val InlinedTrees = Property.Key[Counter]()
1219+
final class Counter {
1220+
var count: Int = 0
1221+
}
1222+
12171223
/** Record an enclosing inlined call.
12181224
* EmptyTree calls (for parameters) cancel the next-enclosing call in the list instead of being added to it.
12191225
* We assume parameters are never nested inside parameters.
@@ -1230,14 +1236,25 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
12301236
else
12311237
call :: oldIC
12321238

1233-
ctx.fresh.setProperty(InlinedCalls, newIC)
1239+
val ctx1 = ctx.fresh.setProperty(InlinedCalls, newIC)
1240+
if oldIC.isEmpty then ctx1.setProperty(InlinedTrees, new Counter) else ctx1
12341241
}
12351242

12361243
/** All enclosing calls that are currently inlined, from innermost to outermost.
12371244
*/
12381245
def enclosingInlineds(implicit ctx: Context): List[Tree] =
12391246
ctx.property(InlinedCalls).getOrElse(Nil)
12401247

1248+
/** Record inlined trees */
1249+
def addInlinedTrees(n: Int)(implicit ctx: Context): Unit =
1250+
ctx.property(InlinedTrees).foreach(_.count += n)
1251+
1252+
/** Check if the limit on the number of inlined trees has been reached */
1253+
def reachedInlinedTreesLimit(implicit ctx: Context): Boolean =
1254+
ctx.property(InlinedTrees) match
1255+
case Some(c) => c.count > ctx.settings.XmaxInlinedTrees.value
1256+
case None => false
1257+
12411258
/** The source file where the symbol of the `inline` method referred to by `call`
12421259
* is defined
12431260
*/

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class ScalaSettings extends Settings.SettingGroup {
7272
val Xhelp: Setting[Boolean] = BooleanSetting("-X", "Print a synopsis of advanced options.")
7373
val XnoForwarders: Setting[Boolean] = BooleanSetting("-Xno-forwarders", "Do not generate static forwarders in mirror classes.")
7474
val XmaxInlines: Setting[Int] = IntSetting("-Xmax-inlines", "Maximal number of successive inlines.", 32)
75+
val XmaxInlinedTrees: Setting[Int] = IntSetting("-Xmax-inlined-trees", "Maximal number of inlined trees.", 2_000_000)
7576
val Xmigration: Setting[ScalaVersion] = VersionSetting("-Xmigration", "Warn about constructs whose behavior may have changed since version.")
7677
val Xprint: Setting[List[String]] = PhasesSetting("-Xprint", "Print out program after")
7778
val XprintTypes: Setting[Boolean] = BooleanSetting("-Xprint-types", "Print tree types (debugging option).")
@@ -87,6 +88,7 @@ class ScalaSettings extends Settings.SettingGroup {
8788
val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Xfatal-warnings", "Fail the compilation if there are any warnings.")
8889
val XverifySignatures: Setting[Boolean] = BooleanSetting("-Xverify-signatures", "Verify generic signatures in generated bytecode.")
8990
val XignoreScala2Macros: Setting[Boolean] = BooleanSetting("-Xignore-scala2-macros", "Ignore errors when compiling code that calls Scala2 macros, these will fail at runtime.")
91+
val XimportSuggestionTimeout: Setting[Int] = IntSetting("-Ximport-suggestion-timeout", "Timeout (in ms) for searching for import suggestions when errors are reported.", 8000)
9092

9193
val XmixinForceForwarders = ChoiceSetting(
9294
name = "-Xmixin-force-forwarders",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ object NameOps {
270270
original.fieldName
271271
}
272272
else getterName.fieldName
273-
else FieldName(name)
273+
else FieldName(name.toSimpleName)
274274

275275
def stripScala2LocalSuffix: TermName =
276276
if (name.isScala2LocalSuffix) name.asSimpleName.dropRight(1) else name

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ class TreeUnpickler(reader: TastyReader,
578578
else
579579
ctx.newSymbol(ctx.owner, name, flags, completer, privateWithin, coord)
580580
}
581-
sym.annotations = annotFns.map(_(sym))
581+
sym.annotations = annotFns.map(_(sym.owner))
582582
if sym.isOpaqueAlias then sym.setFlag(Deferred)
583583
val isScala2MacroDefinedInScala3 = flags.is(Macro, butNot = Inline) && flags.is(Erased)
584584
ctx.owner match {

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2004,7 +2004,12 @@ object Parsers {
20042004
}
20052005

20062006
val finalizer =
2007-
if (in.token == FINALLY) { in.nextToken(); subExpr() }
2007+
if (in.token == FINALLY) {
2008+
in.nextToken();
2009+
val expr = subExpr()
2010+
if expr.span.exists then expr
2011+
else Literal(Constant(())) // finally without an expression
2012+
}
20082013
else {
20092014
if (handler.isEmpty) warning(
20102015
EmptyCatchAndFinallyBlock(body),

0 commit comments

Comments
 (0)