File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
main/kotlin/tools/samt/parser
test/kotlin/tools/samt/parser Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -493,6 +493,16 @@ class Parser private constructor(
493493 check<OpenBraceToken >() -> parseObjectNode()
494494
495495 skip<AsteriskToken >() -> WildcardNode (locationFromStart(start))
496+ skip<QuestionMarkToken >() -> {
497+ val literal = parseLiteral()
498+ diagnostic.error {
499+ message(" Nullability is indicated after a type" )
500+ highlight(locationFromStart(start), highlightBeginningOnly = true )
501+ info(" A valid nullable type looks like 'Int?' or 'String(size(1..*))?'" )
502+ help(" To declare the type nullable move the question mark to the end of the type" )
503+ }
504+ literal
505+ }
496506
497507 else -> {
498508 diagnostic.fatal {
Original file line number Diff line number Diff line change @@ -550,8 +550,8 @@ class ParserTest {
550550
551551 typealias A = ?String
552552 """
553- val exception = parseWithFatalError (source)
554- assertEquals(" Expected an expression " , exception .message)
553+ val (_, diagnostics) = parseWithRecoverableError (source)
554+ assertEquals(" Nullability is indicated after a type " , diagnostics.messages.single() .message)
555555 }
556556 }
557557
You can’t perform that action at this time.
0 commit comments