diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 6577c6a12ff3..faa335a6ac07 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -3534,7 +3534,9 @@ object Parsers { newLinesOpt() val noParams = tparams.isEmpty && vparamss.isEmpty if !(name.isEmpty && noParams) then accept(COLON) - val parents = constrApp() :: withConstrApps() + val parents = + if isSimpleLiteral then toplevelTyp() :: Nil + else constrApp() :: withConstrApps() val parentsIsType = parents.length == 1 && parents.head.isType if in.token == EQUALS && parentsIsType then accept(EQUALS) diff --git a/tests/pos/i11102.scala b/tests/pos/i11102.scala new file mode 100644 index 000000000000..cb1621dbba7f --- /dev/null +++ b/tests/pos/i11102.scala @@ -0,0 +1,3 @@ +given s: "literal" = "literal" // compile error +given "foo" = "foo" +given x: 1 = 1