File tree 2 files changed +9
-3
lines changed
compiler/src/dotty/tools/dotc/parsing
tests/pos-custom-args/captures
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -225,6 +225,7 @@ object Parsers {
225
225
def isErasedKw = isErased && in.isSoftModifierInParamModifierPosition
226
226
// Are we seeing a `cap` soft keyword for declaring a capture-set member or at the beginning a capture-variable parameter list?
227
227
def isCapKw = Feature .ccEnabled && isIdent(nme.cap)
228
+ // This will typically be used at the beginning of a type parameter list to check if it is a capture-variable parameter list:
228
229
def isCapKwNext = Feature .ccEnabled && in.lookahead.isIdent(nme.cap)
229
230
def isSimpleLiteral =
230
231
simpleLiteralTokens.contains(in.token)
@@ -1916,7 +1917,7 @@ object Parsers {
1916
1917
refinedTypeRest(atSpan(startOffset(t)) {
1917
1918
RefinedTypeTree (rejectWildcardType(t), refinement(indentOK = true ))
1918
1919
})
1919
- else if Feature .ccEnabled && in.isIdent(nme.UPARROW ) && isCaptureUpArrow then
1920
+ else if Feature .ccEnabled && in.isIdent(nme.UPARROW ) && isCaptureUpArrow then // TODO remove
1920
1921
atSpan(t.span.start):
1921
1922
in.nextToken()
1922
1923
if in.token == LBRACE
@@ -4858,7 +4859,7 @@ object Parsers {
4858
4859
fail(em " this kind of definition cannot be a refinement " )
4859
4860
4860
4861
while
4861
- val dclFound = isDclIntro
4862
+ val dclFound = isDclIntro || isCapKw // TODO grammar doc
4862
4863
if dclFound then
4863
4864
stats ++= checkLegal(defOrDcl(in.offset, Modifiers ()))
4864
4865
var what = " declaration"
Original file line number Diff line number Diff line change @@ -38,4 +38,9 @@ def test2 =
38
38
def foo [cap A , B >: A ](x : Int ) = 1
39
39
foo[cap x, x](0 )
40
40
foo[cap A = x, B = {x}](0 )
41
- foo[cap A = {x}](0 )
41
+ foo[cap A = {x}](0 )
42
+
43
+ trait Bar :
44
+ cap C
45
+
46
+ def useFoo [cap D ](x : Bar { cap C = D } ): Any ^ {x.C } = ???
You can’t perform that action at this time.
0 commit comments