Skip to content

Commit 71e4dab

Browse files
committed
Fix
1 parent cf788d3 commit 71e4dab

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ object SymDenotations {
152152
println(i"${" " * indent}completing ${if (isType) "type" else "val"} $name")
153153
indent += 1
154154

155-
if (myFlags.is(Touched)) throw CyclicReference(this)
155+
if myFlags.is(Touched) then
156+
throw CyclicReference(this)(using ctx.withOwner(symbol))
156157
myFlags |= Touched
157158

158159
// completions.println(s"completing ${this.debugString}")
@@ -164,7 +165,7 @@ object SymDenotations {
164165
}
165166
finally {
166167
indent -= 1
167-
println(i"${" " * indent}completed $name in $owner")
168+
println(i"${" " * indent}completed ${if (isType) "type" else "val"} $name in $owner")
168169
}
169170
}
170171
else

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3713,10 +3713,13 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
37133713

37143714
/** Checks if `tree` is a named tuple with one element that could be
37153715
* interpreted as an assignment, such as `(x = 1)`. If so, issues a warning.
3716+
* However, only checking the Tuple case if we're not within a type,
3717+
* not only because that's not useful, but because it can lead to cyclic references while checking,
3718+
* e.g., `val foo: (f: String) = ... ; val f = foo.f`
37163719
*/
3717-
def checkDeprecatedAssignmentSyntax(tree: untpd.Tuple | untpd.Parens)(using Context): Unit =
3720+
def checkDeprecatedAssignmentSyntax(tree: untpd.Tuple | untpd.Parens)(using ctx: Context): Unit =
37183721
val assignmentArgs = tree match {
3719-
case untpd.Tuple(List(NamedArg(name, value))) =>
3722+
case untpd.Tuple(List(NamedArg(name, value))) if !ctx.mode.is(Mode.Type) =>
37203723
val tmpCtx = ctx.fresh.setNewTyperState()
37213724
typedAssign(untpd.Assign(untpd.Ident(name), value), WildcardType)(using tmpCtx)
37223725
Option.unless(tmpCtx.reporter.hasErrors)(name -> value)

0 commit comments

Comments
 (0)