Skip to content

Commit f8ad4fe

Browse files
committed
Fix #1443: Replace toplevel TypeBounds with Any
1 parent 62348de commit f8ad4fe

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,12 +648,17 @@ object Parsers {
648648
}
649649

650650
/* ------------- TYPES ------------------------------------------------------ */
651-
/** Same as [[typ]], but emits a syntax error if it returns a wildcard.
651+
/** Same as [[typ]], but if this results in a wildcard it emits a syntax error and
652+
* returns a tree for type `Any` instead.
652653
*/
653654
def toplevelTyp(): Tree = {
654655
val t = typ()
655-
for (wildcardPos <- findWildcardType(t)) syntaxError("unbound wildcard type", wildcardPos)
656-
t
656+
findWildcardType(t) match {
657+
case Some(wildcardPos) =>
658+
syntaxError("unbound wildcard type", wildcardPos)
659+
Ident(Names.typeName("Any")).withPos(t.pos)
660+
case None => t
661+
}
657662
}
658663

659664
/** Type ::= FunArgTypes `=>' Type

tests/pending/neg/unboundWildcard.scala renamed to tests/neg/unboundWildcard.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
object unboundWildcard {
22

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

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

0 commit comments

Comments
 (0)