Skip to content

Fixes @unchecked warnings #2168

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 3 commits into from
Apr 4, 2017
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
case SymbolLit(str) =>
cpy.SymbolLit(tree)(str)
case InterpolatedString(id, segments) =>
cpy.InterpolatedString(tree)(id, segments.map(transform(_)))
cpy.InterpolatedString(tree)(id, segments.mapConserve(transform))
case Function(args, body) =>
cpy.Function(tree)(transform(args), transform(body))
case InfixOp(left, op, right) =>
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/core/tasty/TreeBuffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ class TreeBuffer extends TastyBuffer(50000) {
val tree = it.next
treeAddrs.get(tree) match {
case addr: Addr => treeAddrs.put(tree, adjusted(addr))
case addrs: List[Addr] => treeAddrs.put(tree, addrs.map(adjusted))
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions compiler/src/dotty/tools/dotc/transform/PostTyper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dotty.tools.dotc
package transform

import dotty.tools.dotc.transform.TreeTransforms.{TransformerInfo, TreeTransform, TreeTransformer}
import dotty.tools.dotc.ast.{Trees, tpd}
import dotty.tools.dotc.ast.{Trees, tpd, untpd}
import scala.collection.{ mutable, immutable }
import ValueClasses._
import scala.annotation.tailrec
Expand Down Expand Up @@ -258,15 +258,15 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran
)
case Import(expr, selectors) =>
val exprTpe = expr.tpe
def checkIdent(ident: Ident): Unit = {
def checkIdent(ident: untpd.Ident): Unit = {
val name = ident.name.asTermName.encode
if (name != nme.WILDCARD && !exprTpe.member(name).exists && !exprTpe.member(name.toTypeName).exists)
ctx.error(s"${ident.name} is not a member of ${expr.show}", ident.pos)
}
selectors.foreach {
case ident: Ident => checkIdent(ident)
case Thicket((ident: Ident) :: _) => checkIdent(ident)
case _ =>
case ident: untpd.Ident => checkIdent(ident)
case Thicket((ident: untpd.Ident) :: _) => checkIdent(ident)
case _ =>
}
super.transform(tree)
case tree =>
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/transform/TreeChecker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ class TreeChecker extends Phase with SymTransformer {
class Checker(phasesToCheck: Seq[Phase]) extends ReTyper with Checking {

val nowDefinedSyms = new mutable.HashSet[Symbol]
val everDefinedSyms = new mutable.HashMap[Symbol, Tree]
val everDefinedSyms = new mutable.HashMap[Symbol, untpd.Tree]

// don't check value classes after typer, as the constraint about constructors doesn't hold after transform
override def checkDerivedValueClass(clazz: Symbol, stats: List[Tree])(implicit ctx: Context) = ()

def withDefinedSym[T](tree: untpd.Tree)(op: => T)(implicit ctx: Context): T = tree match {
case tree: DefTree =>
case tree: untpd.DefTree =>
val sym = tree.symbol
assert(isValidJVMName(sym.name), s"${sym.fullName} name is invalid on jvm")
everDefinedSyms.get(sym) match {
Expand All @@ -160,7 +160,7 @@ class TreeChecker extends Phase with SymTransformer {

if (ctx.settings.YcheckMods.value) {
tree match {
case t: MemberDef =>
case t: untpd.MemberDef =>
if (t.name ne sym.name) ctx.warning(s"symbol ${sym.fullName} name doesn't correspond to AST: ${t}")
// todo: compare trees inside annotations
case _ =>
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ object ProtoTypes {
/** Dummy tree to be used as an argument of a FunProto or ViewProto type */
object dummyTreeOfType {
def apply(tp: Type): Tree = untpd.Literal(Constant(null)) withTypeUnchecked tp
def unapply(tree: Tree): Option[Type] = tree match {
def unapply(tree: untpd.Tree): Option[Type] = tree match {
case Literal(Constant(null)) => Some(tree.typeOpt)
case _ => None
}
Expand Down