File tree 2 files changed +9
-4
lines changed
src/dotty/tools/dotc/parsing 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -648,12 +648,18 @@ object Parsers {
648
648
}
649
649
650
650
/* ------------- 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.
652
653
*/
653
654
def toplevelTyp (): Tree = {
654
655
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
+ Select (Select (Ident (Names .termName(" _root_" )), Names .termName(" scala" )),
660
+ Names .typeName(" Any" )).withPos(t.pos)
661
+ case None => t
662
+ }
657
663
}
658
664
659
665
/** Type ::= FunArgTypes `=>' Type
Original file line number Diff line number Diff line change 1
1
object unboundWildcard {
2
2
3
- // TODO: move this to tests/neg once it doesn't crash the compiler anymore
4
3
val wildcardVal : _ = 0 // error: unbound wildcard type
5
4
6
5
val annotated : _ @ unchecked = 0 // error: unbound wildcard type
You can’t perform that action at this time.
0 commit comments