Skip to content

Commit e3650c7

Browse files
committed
Fix #5004: Turn assertion into test
1 parent 844754f commit e3650c7

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ object Contexts {
378378
* - as scope: The parameters of the auxiliary constructor.
379379
*/
380380
def thisCallArgContext: Context = {
381-
assert(owner.isClassConstructor)
382381
val constrCtx = outersIterator.dropWhile(_.outer.owner == owner).next()
383382
superOrThisCallContext(owner, constrCtx.scope)
384383
.setTyperState(typerState)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
747747
* otherwise the current context.
748748
*/
749749
def argCtx(app: untpd.Tree)(implicit ctx: Context): Context =
750-
if (untpd.isSelfConstrCall(app)) ctx.thisCallArgContext else ctx
750+
if (ctx.owner.isClassConstructor && untpd.isSelfConstrCall(app)) ctx.thisCallArgContext
751+
else ctx
751752

752753
/** Typecheck application. Result could be an `Apply` node,
753754
* or, if application is an operator assignment, also an `Assign` or

tests/neg/i5004.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object i0 {
2+
1 match {
3+
def this(): Int // error // error
4+
def this() // error
5+
} // error
6+
}

0 commit comments

Comments
 (0)