Skip to content

Commit e78e97a

Browse files
Merge pull request #11900 from dotty-staging/fix-#11896
Do not drop `erased` flag from `given erased` parameters
2 parents 45e77e8 + ec0f5b8 commit e78e97a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,12 +2910,12 @@ object Parsers {
29102910

29112911
/** ContextTypes ::= Type {‘,’ Type}
29122912
*/
2913-
def contextTypes(ofClass: Boolean, nparams: Int): List[ValDef] =
2913+
def contextTypes(ofClass: Boolean, nparams: Int, impliedMods: Modifiers): List[ValDef] =
29142914
val tps = commaSeparated(typ)
29152915
var counter = nparams
29162916
def nextIdx = { counter += 1; counter }
29172917
val paramFlags = if ofClass then Private | Local | ParamAccessor else Param
2918-
tps.map(makeSyntheticParameter(nextIdx, _, paramFlags | Synthetic | Given))
2918+
tps.map(makeSyntheticParameter(nextIdx, _, paramFlags | Synthetic | impliedMods.flags))
29192919

29202920
/** ClsParamClause ::= ‘(’ [‘erased’] ClsParams ‘)’ | UsingClsParamClause
29212921
* UsingClsParamClause::= ‘(’ ‘using’ [‘erased’] (ClsParams | ContextTypes) ‘)’
@@ -3016,7 +3016,7 @@ object Parsers {
30163016
|| startParamTokens.contains(in.token)
30173017
|| isIdent && (in.name == nme.inline || in.lookahead.isColon())
30183018
if isParams then commaSeparated(() => param())
3019-
else contextTypes(ofClass, nparams)
3019+
else contextTypes(ofClass, nparams, impliedMods)
30203020
checkVarArgsRules(clause)
30213021
clause
30223022
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import scala.language.experimental.erasedDefinitions
2+
3+
type X
4+
erased def x: X = compiletime.erasedValue
5+
6+
def foo(using erased X): Unit = ()
7+
8+
def test: Unit = foo(using x)

0 commit comments

Comments
 (0)