Skip to content

Commit 0deeed4

Browse files
committed
Fix crash: ensure class type is applied
Otherwise, looking up members will crash the compiler
1 parent b2d85d6 commit 0deeed4

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

compiler/src/dotty/tools/dotc/transform/init/Checking.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ object Checking {
190190
private def promote(pot: Refinable, source: Tree)(using state: State): Errors = trace("promoting " + pot.show, init, errs => Errors.show(errs.asInstanceOf[Errors])) {
191191
pot match
192192
case pot: ThisRef =>
193-
val classRef = state.thisClass.typeRef
193+
val classRef = state.thisClass.info.asInstanceOf[ClassInfo].appliedRef
194194
val allInit = classRef.fields.forall { denot =>
195195
val sym = denot.symbol
196196
sym.isOneOf(Flags.Lazy | Flags.Deferred) || state.fieldsInited.contains(sym)
@@ -203,7 +203,7 @@ object Checking {
203203
PromoteThis(pot, source, state.path).toErrors
204204

205205
case warm: Warm =>
206-
val classRef = warm.classSymbol.typeRef
206+
val classRef = warm.classSymbol.info.asInstanceOf[ClassInfo].appliedRef
207207

208208
// only check small classes
209209
val methods = classRef.decls.filter(sym => sym.is(Flags.Method))
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import scala.compiletime.ops.int._
2+
3+
object Test {
4+
class Vec[S <: Int] {
5+
infix def concat [RS <: Int](that : Vec[RS]) : Vec[S + RS] = new Vec[S + RS]
6+
}
7+
8+
val v1 = new Vec[1]
9+
val v2 = new Vec[2]
10+
val v3 : Vec[3] = v1 concat v2
11+
val v3a = v1 concat v2
12+
val v3b : Vec[3] = v3a
13+
}

0 commit comments

Comments
 (0)