diff options
Diffstat (limited to 'src/dotty')
-rw-r--r-- | src/dotty/tools/dotc/ast/TreeInfo.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/ast/Trees.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Flags.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/parsing/Scanners.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Inliner.scala | 15 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 4 |
7 files changed, 17 insertions, 14 deletions
diff --git a/src/dotty/tools/dotc/ast/TreeInfo.scala b/src/dotty/tools/dotc/ast/TreeInfo.scala index bf375acde..7911840c6 100644 --- a/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -455,7 +455,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] => } } - /** If tree is a closure, it's body, otherwise tree itself */ + /** If tree is a closure, its body, otherwise tree itself */ def closureBody(tree: tpd.Tree)(implicit ctx: Context): tpd.Tree = tree match { case Block((meth @ DefDef(nme.ANON_FUN, _, _, _, _)) :: Nil, Closure(_, _, _)) => meth.rhs case _ => tree diff --git a/src/dotty/tools/dotc/ast/Trees.scala b/src/dotty/tools/dotc/ast/Trees.scala index 7e7c74928..6986e40e7 100644 --- a/src/dotty/tools/dotc/ast/Trees.scala +++ b/src/dotty/tools/dotc/ast/Trees.scala @@ -520,7 +520,7 @@ object Trees { case class Inlined[-T >: Untyped] private[ast] (call: tpd.Tree, bindings: List[MemberDef[T]], expansion: Tree[T]) extends Tree[T] { type ThisTree[-T >: Untyped] = Inlined[T] - } + } /** A type tree that represents an existing or inferred type */ case class TypeTree[-T >: Untyped] private[ast] (original: Tree[T]) diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala index b7befa6e2..3f4433708 100644 --- a/src/dotty/tools/dotc/core/Flags.scala +++ b/src/dotty/tools/dotc/core/Flags.scala @@ -529,7 +529,7 @@ object Flags { /** Either method or lazy or deferred */ final val MethodOrLazyOrDeferred = Method | Lazy | Deferred - /** Labeled `private` or `final` */ + /** Labeled `private`, `final`, or `inline` */ final val PrivateOrFinalOrInline = Private | Final | Inline /** A private method */ diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 00286156a..2f1b6b829 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -2448,7 +2448,7 @@ object Types { } /** Add @inlineParam to inline call-by-value parameters */ def translateInline(tp: Type): Type = tp match { - case tp @ ExprType(tp1) => tp + case _: ExprType => tp case _ => AnnotatedType(tp, Annotation(defn.InlineParamAnnot)) } def paramInfo(param: Symbol): Type = { @@ -2580,7 +2580,7 @@ object Types { x => paramBounds mapConserve (_.subst(this, x).bounds), x => resType.subst(this, x)) - /** Merge nested polytypes into one polytype. nested polytypes are normally not suported + /** Merge nested polytypes into one polytype. nested polytypes are normally not supported * but can arise as temporary data structures. */ def flatten(implicit ctx: Context): PolyType = resType match { diff --git a/src/dotty/tools/dotc/parsing/Scanners.scala b/src/dotty/tools/dotc/parsing/Scanners.scala index a1a21583c..e16aa670f 100644 --- a/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/src/dotty/tools/dotc/parsing/Scanners.scala @@ -220,7 +220,7 @@ object Scanners { private def treatAsIdent() = { - testScala2Mode(i"$name is now a keyword, put in `...` to keep as an identifier") + testScala2Mode(i"$name is now a keyword, write `$name` instead of $name to keep it as an identifier") patch(source, Position(offset), "`") patch(source, Position(offset + name.length), "`") IDENTIFIER diff --git a/src/dotty/tools/dotc/typer/Inliner.scala b/src/dotty/tools/dotc/typer/Inliner.scala index f0464c764..55008c0c5 100644 --- a/src/dotty/tools/dotc/typer/Inliner.scala +++ b/src/dotty/tools/dotc/typer/Inliner.scala @@ -80,9 +80,14 @@ object Inliner { */ def addAccessor(tree: Tree, refPart: Tree, targs: List[Tree], argss: List[List[Tree]], accessedType: Type, rhs: (Tree, List[Type], List[List[Tree]]) => Tree)(implicit ctx: Context): Tree = { + val qual = qualifier(refPart) + def refIsLocal = qual match { + case qual: This => qual.symbol == refPart.symbol.owner + case _ => false + } val (accessorDef, accessorRef) = - if (refPart.symbol.isStatic) { - // Easy case: Reference to a static symbol + if (refPart.symbol.isStatic || refIsLocal) { + // Easy case: Reference to a static symbol or a symbol referenced via `this.` val accessorType = accessedType.ensureMethodic val accessor = accessorSymbol(tree, accessorType).asTerm val accessorDef = polyDefDef(accessor, tps => argss => @@ -90,8 +95,7 @@ object Inliner { val accessorRef = ref(accessor).appliedToTypeTrees(targs).appliedToArgss(argss) (accessorDef, accessorRef) } else { - // Hard case: Reference needs to go via a dyanmic prefix - val qual = qualifier(refPart) + // Hard case: Reference needs to go via a dynamic prefix inlining.println(i"adding inline accessor for $tree -> (${qual.tpe}, $refPart: ${refPart.getClass}, [$targs%, %], ($argss%, %))") // Need to dealias in order to catch all possible references to abstracted over types in @@ -246,12 +250,11 @@ object Inliner { tpd.seq(inlined.bindings, reposition.transform(inlined.expansion)) } - /** The qualifier part of a Select, Ident, or SelectFromTypeTree tree. + /** The qualifier part of a Select or Ident. * For an Ident, this is the `This` of the current class. (TODO: use elsewhere as well?) */ private def qualifier(tree: Tree)(implicit ctx: Context) = tree match { case Select(qual, _) => qual - case SelectFromTypeTree(qual, _) => qual case _ => This(ctx.owner.enclosingClass.asClass) } } diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index fb7f26f36..e32805e0f 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -1357,7 +1357,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def typedTypedSplice(tree: untpd.TypedSplice)(implicit ctx: Context): Tree = tree.tree match { case tree1: TypeTree => tree1 // no change owner necessary here ... - case tree1: Ident => tree1 // ... or here + case tree1: Ident => tree1 // ... or here, since these trees cannot contain bindings case tree1 => if (ctx.owner ne tree.owner) tree1.changeOwner(tree.owner, ctx.owner) else tree1 @@ -1859,7 +1859,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit if (folded ne tree) return adaptConstant(folded, folded.tpe.asInstanceOf[ConstantType]) // drop type if prototype is Unit if (pt isRef defn.UnitClass) - return tpd.Block(tree :: Nil, Literal(Constant(()))) + return adapt(tpd.Block(tree :: Nil, Literal(Constant(()))), pt) // convert function literal to SAM closure tree match { case Closure(Nil, id @ Ident(nme.ANON_FUN), _) |