Skip to content

Tweaks to indent syntax #7363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ object desugar {
case None, Exhaustive, IrrefutablePatDef, IrrefutableGenFrom
}

/** Info of a variable in a pattern: The named tree and its type */
private type VarInfo = (NameTree, Tree)

/** Is `name` the name of a method that can be invalidated as a compiler-generated
* case class method if it clashes with a user-defined method?
*/
Expand Down Expand Up @@ -1685,16 +1682,6 @@ object desugar {
TypeDef(tpnme.REFINE_CLASS, impl).withFlags(Trait)
}

/** If tree is of the form `id` or `id: T`, return its name and type, otherwise return None.
*/
private object IdPattern {
def unapply(tree: Tree)(implicit ctx: Context): Option[VarInfo] = tree match {
case id: Ident if id.name != nme.WILDCARD => Some(id, TypeTree())
case Typed(id: Ident, tpt) => Some((id, tpt))
case _ => None
}
}

/** Returns list of all pattern variables, possibly with their types,
* without duplicates
*/
Expand Down
12 changes: 12 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,18 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped]
def bodyKind(body: List[Tree])(implicit ctx: Context): FlagSet =
body.foldLeft(NoInitsInterface)((fs, stat) => fs & defKind(stat))

/** Info of a variable in a pattern: The named tree and its type */
type VarInfo = (NameTree, Tree)

/** An extractor for trees of the form `id` or `id: T` */
object IdPattern {
def unapply(tree: Tree)(implicit ctx: Context): Option[VarInfo] = tree match {
case id: Ident if id.name != nme.WILDCARD => Some(id, TypeTree())
case Typed(id: Ident, tpt) => Some((id, tpt))
case _ => None
}
}

// todo: fill with other methods from TreeInfo that only apply to untpd.Tree's
}

Expand Down
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/config/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ object Config {
/** Assume -indent by default */
final val defaultIndent = true

/** Assume indentation is significant after a class, object, ... signature */
final val silentTemplateIndent = true

/** If set, prints a trace of all symbol completions */
final val showCompletions = false

Expand Down
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -832,11 +832,12 @@ object SymDenotations {
| Access to protected $this not permitted because enclosing ${ctx.owner.enclosingClass.showLocated}
| is not a subclass of ${owner.showLocated} where target is defined""")
else if
(!( isType // allow accesses to types from arbitrary subclasses fixes #4737
!( isType // allow accesses to types from arbitrary subclasses fixes #4737
|| pre.derivesFrom(cls)
|| isConstructor
|| owner.is(ModuleClass) // don't perform this check for static members
))
)
then
fail(
i"""
| Access to protected ${symbol.show} not permitted because prefix type ${pre.widen.show}
Expand Down
Loading