diff options
Diffstat (limited to 'compiler/src')
7 files changed, 51 insertions, 6 deletions
diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index fd2ded0b5..21a6c1165 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -69,7 +69,7 @@ class ScalaSettings extends Settings.SettingGroup { val genPhaseGraph = StringSetting("-Xgenerate-phase-graph", "file", "Generate the phase graphs (outputs .dot files) to fileX.dot.", "") val XlogImplicits = BooleanSetting("-Xlog-implicits", "Show more detail on why some implicits are not applicable.") val XminImplicitSearchDepth = IntSetting("-Xmin-implicit-search-depth", "Set number of levels of implicit searches undertaken before checking for divergence.", 5) - val xmaxInlines = IntSetting("-Xmax-inlines", "Maximal number of successive inlines", 70) + val xmaxInlines = IntSetting("-Xmax-inlines", "Maximal number of successive inlines", 32) val logImplicitConv = BooleanSetting("-Xlog-implicit-conversions", "Print a message whenever an implicit conversion is inserted.") val logReflectiveCalls = BooleanSetting("-Xlog-reflective-calls", "Print a message when a reflective method call is generated") val logFreeTerms = BooleanSetting("-Xlog-free-terms", "Print a message when reification creates a free term.") diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 1e8fb9d26..18f0b42f5 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -676,7 +676,7 @@ object Parsers { val t = typ() findWildcardType(t) match { case Some(wildcardPos) => - syntaxError("unbound wildcard type", wildcardPos) + syntaxError(UnboundWildcardType(), wildcardPos) scalaAny case None => t } diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index b55b7e868..25db28e4a 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -923,4 +923,47 @@ object messages { |""" } + case class UnboundWildcardType()(implicit ctx: Context) extends Message(35) { + val kind = "Syntax" + val msg = "Unbound wildcard type" + val explanation = + hl"""|The wildcard type syntax (`_`) was used where it could not be bound. + |Replace `_` with a non-wildcard type. If the type doesn't matter, + |try replacing `_` with ${"Any"}. + | + |Examples: + | + |- Parameter lists + | + | Instead of: + | ${"def foo(x: _) = ..."} + | + | Use ${"Any"} if the type doesn't matter: + | ${"def foo(x: Any) = ..."} + | + |- Type arguments + | + | Instead of: + | ${"val foo = List[_](1, 2)"} + | + | Use: + | ${"val foo = List[Int](1, 2)"} + | + |- Type bounds + | + | Instead of: + | ${"def foo[T <: _](x: T) = ..."} + | + | Remove the bounds if the type doesn't matter: + | ${"def foo[T](x: T) = ..."} + | + |- ${"val"} and ${"def"} types + | + | Instead of: + | ${"val foo: _ = 3"} + | + | Use: + | ${"val foo: Int = 3"} + |""" + } } diff --git a/compiler/src/dotty/tools/dotc/transform/ElimByName.scala b/compiler/src/dotty/tools/dotc/transform/ElimByName.scala index 71ced3175..2814baf1e 100644 --- a/compiler/src/dotty/tools/dotc/transform/ElimByName.scala +++ b/compiler/src/dotty/tools/dotc/transform/ElimByName.scala @@ -71,7 +71,8 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform def transformArg(arg: Tree, formal: Type): Tree = formal.dealias match { case formalExpr: ExprType => - val argType = arg.tpe.widenIfUnstable + var argType = arg.tpe.widenIfUnstable + if (defn.isBottomType(argType)) argType = formal.widenExpr val argFun = arg match { case Apply(Select(qual, nme.apply), Nil) if qual.tpe.derivesFrom(defn.FunctionClass(0)) && isPureExpr(qual) => diff --git a/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala index 1eb12e9de..c2aacf826 100644 --- a/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala +++ b/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -276,7 +276,8 @@ object ExplicitOuter { if (tpe.prefix eq NoPrefix) cls.owner.enclosingClass.thisType else tpe.prefix case _ => - outerPrefix(tpe.underlying) + // Need to be careful to dealias before erasure, otherwise we lose prefixes. + outerPrefix(tpe.underlying(ctx.withPhaseNoLater(ctx.erasurePhase))) } case tpe: TypeProxy => outerPrefix(tpe.underlying) diff --git a/compiler/src/dotty/tools/dotc/transform/Memoize.scala b/compiler/src/dotty/tools/dotc/transform/Memoize.scala index 0314d4ec4..63edc0256 100644 --- a/compiler/src/dotty/tools/dotc/transform/Memoize.scala +++ b/compiler/src/dotty/tools/dotc/transform/Memoize.scala @@ -102,7 +102,7 @@ import Decorators._ case _ => t } skipBlocks(tree.rhs) match { - case lit: Literal if sym.is(Final) && isIdempotentExpr(tree.rhs) => + case lit: Literal if sym.is(Final, butNot = Mutable) && isIdempotentExpr(tree.rhs) => // duplicating scalac behavior: for final vals that have rhs as constant, we do not create a field // and instead return the value. This seemingly minor optimization has huge effect on initialization // order and the values that can be observed during superconstructor call diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 63f3a59d6..b70a51d1e 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1150,7 +1150,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit // classes defined in a such arguments should not be entered into the // enclosing class. c.exprContext(mdef, exprOwner) - case None => c + case _ => c } } // necessary in order to mark the typed ahead annotations as definitely typed: |