Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix #15514 in Parser#15524

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
odersky merged 2 commits intoscala:mainfromdotty-staging:fix-15514-in-parser
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
4 changes: 2 additions & 2 deletionscompiler/src/dotty/tools/dotc/parsing/Parsers.scala
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3957,8 +3957,8 @@ object Parsers {
*/
def selfType(): ValDef =
if (in.isIdent || in.token == THIS)
&& in.lookahead.isColon && followingIsSelfType()
|| in.lookahead.token == ARROW
&&(in.lookahead.isColon && followingIsSelfType()
|| in.lookahead.token == ARROW)
then
atSpan(in.offset) {
val selfName =
Expand Down
22 changes: 12 additions & 10 deletionscompiler/src/dotty/tools/dotc/parsing/Scanners.scala
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -662,7 +662,7 @@ object Scanners {
true
else token == COLONfollow && (inTemplate || fewerBracesEnabled)
if enabled then
lookAhead()
peekAhead()
val atEOL = isAfterLineEnd || token == EOF
reset()
if atEOL then token = COLONeol
Expand DownExpand Up@@ -690,15 +690,14 @@ object Scanners {
insert(OUTDENT, offset)
case _ =>

deflookAhead() =
defpeekAhead() =
prev.copyFrom(this)
getNextToken(token)
if token == END && !isEndMarker then token = IDENTIFIER

def reset() = {
def reset() =
next.copyFrom(this)
this.copyFrom(prev)
}

def closeIndented() = currentRegion match
case r: Indented if !r.isOutermost => insert(OUTDENT, offset)
Expand All@@ -717,12 +716,12 @@ object Scanners {
}
(token: @switch) match {
case CASE =>
lookAhead()
peekAhead()
if (token == CLASS) fuse(CASECLASS)
else if (token == OBJECT) fuse(CASEOBJECT)
else reset()
case SEMI =>
lookAhead()
peekAhead()
if (token != ELSE) reset()
case COMMA =>
def isEnclosedInParens(r: Region): Boolean = r match
Expand All@@ -733,7 +732,7 @@ object Scanners {
case r: Indented if isEnclosedInParens(r.outer) =>
insert(OUTDENT, offset)
case _ =>
lookAhead()
peekAhead()
if isAfterLineEnd
&& currentRegion.commasExpected
&& (token == RPAREN || token == RBRACKET || token == RBRACE || token == OUTDENT)
Expand DownExpand Up@@ -1083,11 +1082,14 @@ object Scanners {
* The token is computed via fetchToken, so complex two word
* tokens such as CASECLASS are not recognized.
* Newlines and indent/unindent tokens are skipped.
*
* Restriction: `lookahead` is illegal if the current token is INTERPOLATIONID
*/
def lookahead: TokenData =
def lookahead: TokenData =
if next.token == EMPTY then
lookAhead()
assert(token != INTERPOLATIONID)
// INTERPOLATONIDs are followed by a string literal, which can set next
// in peekAhead(). In that case, the following reset() would forget that token.
peekAhead()
reset()
next

Expand Down
4 changes: 4 additions & 0 deletionstests/pos/i15514.scala
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@

object Main { s"Hello $Main.toStr!" }

object Alt { s"Hello ${Alt}.toStr!" }

[8]ページ先頭

©2009-2025 Movatter.jp