Skip to content

Do not drop erased flag from given erased parameters #11900

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
Mar 26, 2021
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
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2910,12 +2910,12 @@ object Parsers {

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

/** ClsParamClause ::= ‘(’ [‘erased’] ClsParams ‘)’ | UsingClsParamClause
* UsingClsParamClause::= ‘(’ ‘using’ [‘erased’] (ClsParams | ContextTypes) ‘)’
Expand Down Expand Up @@ -3016,7 +3016,7 @@ object Parsers {
|| startParamTokens.contains(in.token)
|| isIdent && (in.name == nme.inline || in.lookahead.isColon())
if isParams then commaSeparated(() => param())
else contextTypes(ofClass, nparams)
else contextTypes(ofClass, nparams, impliedMods)
checkVarArgsRules(clause)
clause
}
Expand Down
8 changes: 8 additions & 0 deletions tests/pos-custom-args/erased/i11896.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import scala.language.experimental.erasedDefinitions

type X
erased def x: X = compiletime.erasedValue

def foo(using erased X): Unit = ()

def test: Unit = foo(using x)