Skip to content

Fix returns inside while cycles. #297

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

Closed
wants to merge 3 commits into from
Closed
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
4 changes: 3 additions & 1 deletion src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ object SymDenotations {
}

/** Is this a user defined "def" method? Excluded are accessors. */
final def isSourceMethod(implicit ctx: Context) = this is (Method, butNot = Accessor)
final def isSourceMethod(implicit ctx: Context) = this is (Method, butNot = AccessorOrLabel)

/** Is this a setter? */
final def isGetter(implicit ctx: Context) =
Expand Down Expand Up @@ -1664,4 +1664,6 @@ object SymDenotations {
private final val NumBits = NumWords << WordSizeLog
private final val Mask = NumBits - 1
}

val AccessorOrLabel = Accessor | Label
}
6 changes: 6 additions & 0 deletions src/dotty/tools/dotc/transform/TreeChecker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ class TreeChecker {
res
}


override def typedReturn(tree: untpd.Return)(implicit ctx: Context): tpd.Return = {
assert(!(tree.from.symbol is Label), i"returns from labels aren't supported: $tree")
super.typedReturn(tree)
}

private def checkOwner(tree: untpd.Tree)(implicit ctx: Context): Unit = {
def ownerMatches(symOwner: Symbol, ctxOwner: Symbol): Boolean =
symOwner == ctxOwner ||
Expand Down