diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-25 12:31:13 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-09-25 16:53:53 +0200 |
commit | 2d908c792fcf4287b4cb493f0e51dfbdb106cf69 (patch) | |
tree | 1e520bbd6f9c52479773bd359deae8a149c7fc97 /src/dotty/tools/dotc/typer | |
parent | b2b475d2931f71220d0ed5390ec77608ca3d150e (diff) | |
download | dotty-2d908c792fcf4287b4cb493f0e51dfbdb106cf69.tar.gz dotty-2d908c792fcf4287b4cb493f0e51dfbdb106cf69.tar.bz2 dotty-2d908c792fcf4287b4cb493f0e51dfbdb106cf69.zip |
Drop Pair
Drop tree node class 'Pair'. It was used only in imports, where
it can easily be replaced by Thicket.
The envisaged use for generic pairs is almost sure better modelled
by a "Pair" class in Dotty's standard library.
Diffstat (limited to 'src/dotty/tools/dotc/typer')
-rw-r--r-- | src/dotty/tools/dotc/typer/ImportInfo.scala | 6 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/TypeAssigner.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 33 |
3 files changed, 16 insertions, 26 deletions
diff --git a/src/dotty/tools/dotc/typer/ImportInfo.scala b/src/dotty/tools/dotc/typer/ImportInfo.scala index 2105d9ccc..3aa289181 100644 --- a/src/dotty/tools/dotc/typer/ImportInfo.scala +++ b/src/dotty/tools/dotc/typer/ImportInfo.scala @@ -60,9 +60,9 @@ class ImportInfo(symf: => Symbol, val selectors: List[untpd.Tree], val isRootImp def recur(sels: List[untpd.Tree]): Unit = sels match { case sel :: sels1 => sel match { - case Pair(Ident(name: TermName), Ident(nme.WILDCARD)) => + case Thicket(Ident(name: TermName) :: Ident(nme.WILDCARD) :: Nil) => myExcluded += name - case Pair(Ident(from: TermName), Ident(to: TermName)) => + case Thicket(Ident(from: TermName) :: Ident(to: TermName) :: Nil) => myMapped = myMapped.updated(to, from) myExcluded += from myOriginals += from @@ -99,7 +99,7 @@ class ImportInfo(symf: => Symbol, val selectors: List[untpd.Tree], val isRootImp lazy val hiddenRoot: Symbol = { val sym = site.termSymbol def hasMaskingSelector = selectors exists { - case Pair(_, Ident(nme.WILDCARD)) => true + case Thicket(_ :: Ident(nme.WILDCARD) :: Nil) => true case _ => false } if ((defn.RootImportTypes exists (_.symbol == sym)) && hasMaskingSelector) sym else NoSymbol diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala index 740fa2658..42302e5ff 100644 --- a/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -376,9 +376,6 @@ trait TypeAssigner { tree.withType(ownType) } - def assignType(tree: untpd.Pair, left: Tree, right: Tree)(implicit ctx: Context) = - tree.withType(defn.PairType.appliedTo(left.tpe :: right.tpe :: Nil)) - def assignType(tree: untpd.Typed, tpt: Tree)(implicit ctx: Context) = tree.withType(tpt.tpe) diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index af09a8283..072240248 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -186,15 +186,19 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit } val Name = name.toTermName.decode selectors match { - case Pair(Ident(from), Ident(Name)) :: rest => - val selName = if (name.isTypeName) from.toTypeName else from - // Pass refctx so that any errors are reported in the context of the - // reference instead of the context of the import. - checkUnambiguous(selectionType(site, selName, tree.pos)(refctx)) - case Ident(Name) :: rest => - checkUnambiguous(selectionType(site, name, tree.pos)(refctx)) - case _ :: rest => - namedImportRef(site, rest) + case selector :: rest => + selector match { + case Thicket(fromId :: Ident(Name) :: _) => + val Ident(from) = fromId + val selName = if (name.isTypeName) from.toTypeName else from + // Pass refctx so that any errors are reported in the context of the + // reference instead of the context of the import. + checkUnambiguous(selectionType(site, selName, tree.pos)(refctx)) + case Ident(Name) => + checkUnambiguous(selectionType(site, name, tree.pos)(refctx)) + case _ => + namedImportRef(site, rest) + } case nil => NoType } @@ -448,16 +452,6 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit } } - def typedPair(tree: untpd.Pair, pt: Type)(implicit ctx: Context) = track("typedPair") { - val (leftProto, rightProto) = pt.argTypesLo match { - case l :: r :: Nil if pt isRef defn.PairClass => (l, r) - case _ => (WildcardType, WildcardType) - } - val left1 = typed(tree.left, leftProto) - val right1 = typed(tree.right, rightProto) - assignType(cpy.Pair(tree)(left1, right1), left1, right1) - } - def typedTyped(tree: untpd.Typed, pt: Type)(implicit ctx: Context): Tree = track("typedTyped") { /* Handles three cases: * @param ifPat how to handle a pattern (_: T) @@ -1422,7 +1416,6 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit case tree: untpd.This => typedThis(tree) case tree: untpd.Literal => typedLiteral(tree) case tree: untpd.New => typedNew(tree, pt) - case tree: untpd.Pair => typedPair(tree, pt) case tree: untpd.Typed => typedTyped(tree, pt) case tree: untpd.NamedArg => typedNamedArg(tree, pt) case tree: untpd.Assign => typedAssign(tree, pt) |