Skip to content

Commit

Permalink
A top-level function declaration may not have a body
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Sep 10, 2023
1 parent 8b210b7 commit 25abc16
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2671,7 +2671,7 @@ class KotlinParserVisitor(
returnTypeExpression = visitElement(simpleFunction.returnTypeRef, data) as TypeTree?
saveCursor = cursor
before = whitespace()
if (source[cursor] == '?') {
if (at('?')) {
returnTypeExpression = returnTypeExpression!!.withMarkers(
returnTypeExpression.markers.addIfAbsent(IsNullable(randomId(), before))
)
Expand Down Expand Up @@ -4878,6 +4878,8 @@ class KotlinParserVisitor(
return if (currentFile == null) null else currentFile!!.symbol
}

private fun at(c: Char) = cursor < source.length && source[cursor] == c

private fun skip(token: String?): Boolean {
if (token != null && source.startsWith(token, cursor)) {
cursor += token.length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,15 @@ fun size(): Int = (-1)
)
);
}

@Test
void multiplatformExpectDeclaration() {
rewriteRun(
kotlin(
"""
expect suspend fun Any.executeAsync(): Any
"""
)
);
}
}

0 comments on commit 25abc16

Please sign in to comment.