aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-08-15 02:56:04 -0700
committerGitHub <noreply@github.com>2016-08-15 02:56:04 -0700
commit3179b03969ad95363094b343618a29e0e961126b (patch)
tree21951b49beae25664a2f0cb36b7202b87c6ca90b /src
parent3265323f96f69bded3edb832519825bc7c89e40f (diff)
parentb0298945ddbea26ef00099dc37db5e396af94de4 (diff)
downloaddotty-3179b03969ad95363094b343618a29e0e961126b.tar.gz
dotty-3179b03969ad95363094b343618a29e0e961126b.tar.bz2
dotty-3179b03969ad95363094b343618a29e0e961126b.zip
Merge pull request #1450 from cswinter/elim-toplevel-typebound
Fix #1443: Replace toplevel TypeBounds with Any
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/ast/untpd.scala1
-rw-r--r--src/dotty/tools/dotc/parsing/Parsers.scala11
2 files changed, 9 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/ast/untpd.scala b/src/dotty/tools/dotc/ast/untpd.scala
index 8400e9352..cef78c6e6 100644
--- a/src/dotty/tools/dotc/ast/untpd.scala
+++ b/src/dotty/tools/dotc/ast/untpd.scala
@@ -205,6 +205,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
def rootDot(name: Name) = Select(Ident(nme.ROOTPKG), name)
def scalaDot(name: Name) = Select(rootDot(nme.scala_), name)
def scalaUnit = scalaDot(tpnme.Unit)
+ def scalaAny = scalaDot(tpnme.Any)
def makeConstructor(tparams: List[TypeDef], vparamss: List[List[ValDef]], rhs: Tree = EmptyTree)(implicit ctx: Context): DefDef =
DefDef(nme.CONSTRUCTOR, tparams, vparamss, TypeTree(), rhs)
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala
index 12f629c57..edc9d3f66 100644
--- a/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -648,12 +648,17 @@ object Parsers {
}
/* ------------- TYPES ------------------------------------------------------ */
- /** Same as [[typ]], but emits a syntax error if it returns a wildcard.
+ /** Same as [[typ]], but if this results in a wildcard it emits a syntax error and
+ * returns a tree for type `Any` instead.
*/
def toplevelTyp(): Tree = {
val t = typ()
- for (wildcardPos <- findWildcardType(t)) syntaxError("unbound wildcard type", wildcardPos)
- t
+ findWildcardType(t) match {
+ case Some(wildcardPos) =>
+ syntaxError("unbound wildcard type", wildcardPos)
+ scalaAny
+ case None => t
+ }
}
/** Type ::= FunArgTypes `=>' Type