Skip to content

Fix #7103: Accept backquoted as as the name of a given #7106

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ object desugar {
case Some(DefDef(name, _, (vparam :: _) :: _, _, _)) =>
s"${name}_of_${inventTypeName(vparam.tpt)}"
case _ =>
ctx.error(i"anonymous instance must have `for` part or must define at least one extension method", impl.sourcePos)
ctx.error(i"anonymous instance must have `as` part or must define at least one extension method", impl.sourcePos)
nme.ERROR.toString
}
else
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2873,7 +2873,7 @@ object Parsers {
*/
def instanceDef(newStyle: Boolean, start: Offset, mods: Modifiers, instanceMod: Mod) = atSpan(start, nameStart) {
var mods1 = addMod(mods, instanceMod)
val name = if (isIdent && (!newStyle || in.name != nme.as)) ident() else EmptyTermName
val name = if (isIdent && !(newStyle && isIdent(nme.as))) ident() else EmptyTermName
val tparams = typeParamClauseOpt(ParamOwner.Def)
var leadingParamss =
if (in.token == LPAREN)
Expand Down
3 changes: 3 additions & 0 deletions tests/pos/i7103.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class X
object X extends X
given `as` as X = X