@@ -17,10 +17,11 @@ import NameKinds.WildcardParamName
17
17
import NameOps ._
18
18
import ast .{Positioned , Trees }
19
19
import ast .Trees ._
20
+ import typer .ImportInfo
20
21
import StdNames ._
21
22
import util .Spans ._
22
23
import Constants ._
23
- import Symbols .defn
24
+ import Symbols .{ defn , NoSymbol }
24
25
import ScriptParsers ._
25
26
import Decorators ._
26
27
import util .Chars
@@ -492,20 +493,19 @@ object Parsers {
492
493
* Parameters appear in reverse order.
493
494
*/
494
495
var placeholderParams : List [ValDef ] = Nil
496
+ var languageImportContext : Context = ctx
495
497
496
- def checkNoEscapingPlaceholders [T ](op : => T ): T = {
498
+ def checkNoEscapingPlaceholders [T ](op : => T ): T =
497
499
val savedPlaceholderParams = placeholderParams
500
+ val savedLanguageImportContext = languageImportContext
498
501
placeholderParams = Nil
499
-
500
502
try op
501
- finally {
502
- placeholderParams match {
503
+ finally
504
+ placeholderParams match
503
505
case vd :: _ => syntaxError(UnboundPlaceholderParameter (), vd.span)
504
506
case _ =>
505
- }
506
507
placeholderParams = savedPlaceholderParams
507
- }
508
- }
508
+ languageImportContext = savedLanguageImportContext
509
509
510
510
def isWildcard (t : Tree ): Boolean = t match {
511
511
case Ident (name1) => placeholderParams.nonEmpty && name1 == placeholderParams.head.name
@@ -1625,7 +1625,7 @@ object Parsers {
1625
1625
typeIdent()
1626
1626
else
1627
1627
def singletonArgs (t : Tree ): Tree =
1628
- if in.token == LPAREN && dependentEnabled
1628
+ if in.token == LPAREN && dependentEnabled( using languageImportContext)
1629
1629
then singletonArgs(AppliedTypeTree (t, inParens(commaSeparated(singleton))))
1630
1630
else t
1631
1631
singletonArgs(simpleType1())
@@ -3090,7 +3090,9 @@ object Parsers {
3090
3090
3091
3091
/** Create an import node and handle source version imports */
3092
3092
def mkImport (outermost : Boolean = false ): ImportConstr = (tree, selectors) =>
3093
+ val imp = Import (tree, selectors)
3093
3094
if isLanguageImport(tree) then
3095
+ languageImportContext = languageImportContext.importContext(imp, NoSymbol )
3094
3096
for
3095
3097
case ImportSelector (id @ Ident (imported), EmptyTree , _) <- selectors
3096
3098
if allSourceVersionNames.contains(imported)
@@ -3101,7 +3103,7 @@ object Parsers {
3101
3103
syntaxError(i " duplicate source version import " , id.span)
3102
3104
else
3103
3105
ctx.compilationUnit.sourceVersion = Some (SourceVersion .valueOf(imported.toString))
3104
- Import (tree, selectors)
3106
+ imp
3105
3107
3106
3108
/** ImportExpr ::= SimpleRef {‘.’ id} ‘.’ ImportSpec
3107
3109
* | SimpleRef ‘as’ id
0 commit comments