Skip to content

Commit 00e2e7b

Browse files
noti0na1bracevac
authored andcommitted
Tight the condition for retrying InCaptureSet
1 parent edd7d13 commit 00e2e7b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: compiler/src/dotty/tools/dotc/typer/Typer.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
715715
&& ctx.owner.owner.unforcedDecls.lookup(tree.name).exists
716716
then // we are in the arguments of a this(...) constructor call
717717
errorTree(tree, em"$tree is not accessible from constructor arguments")
718-
else if ctx.mode.is(Mode.InCaptureSet) then
718+
else if name.isTermName && ctx.mode.is(Mode.InCaptureSet) then
719719
// If we are in a capture set and the identifier is not a term name,
720720
// try to type it with the same name but as a type
721721
typed(untpd.makeCapsOf(untpd.cpy.Ident(tree)(name.toTypeName)), pt)
@@ -927,7 +927,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
927927
// Otherwise, if we are in a capture set, try to type it as a capture variable
928928
// reference (as selecting a type name).
929929
def trySelectTypeInCaptureSet() =
930-
if ctx.mode.is(Mode.InCaptureSet) && tree0.name.isTypeName then
930+
if tree0.name.isTermName && ctx.mode.is(Mode.InCaptureSet) then
931931
typedSelectWithAdapt(untpd.cpy.Select(tree0)(qual, tree0.name.toTypeName), pt, qual)
932932
else EmptyTree
933933

0 commit comments

Comments
 (0)