Skip to content

Fix #1443: Replace toplevel TypeBounds with Any #1450

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 1 commit into from
Aug 15, 2016
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
1 change: 1 addition & 0 deletions src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 8 additions & 3 deletions src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
object unboundWildcard {

// TODO: move this to tests/neg once it doesn't crash the compiler anymore
val wildcardVal: _ = 0 // error: unbound wildcard type

val annotated: _ @unchecked = 0 // error: unbound wildcard type
Expand Down