Commit 50b1c12
Fix #10769: change synthesized type in def ordinal
As pointed out by @smarter in #10769, for the following code:
package stm
trait STMLike[F[_]] {
import Internals._
sealed abstract class Txn[+A] {}
object Txn {
def abort[A](e: Throwable): Txn[A] = Abort(e)
}
object Internals {
case class Abort(error: Throwable) extends Txn[Nothing]
}
}
The compiler synthesized the following code for the object `Txn`:
object Txn {
type MirroredMonoType = STMLike.this.Txn[?]
def ordinal(x: Txn.MirroredMonoType): Int =
x match {
case _:stm.STMLike.Internals.Abort => 0
}
def abort[A](e: Throwable): Txn[A] = Abort(e)
}
In the method `ordinal`, the type for `Internals.Abort` is
TypeRef(ThisType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class stm)),trait STMLike)),module class Internals$)),class Abort)
This type is incorrect, as we are not in the object `Internals`. The
explicit outer can only handle such types if it's static. In this
case, the object is not static, thus it crashes the explicit outer.
Co-authored-by: Guillaume Martres <smarter@ubuntu.com>1 parent 87102a0 commit 50b1c12
File tree
4 files changed
+53
-5
lines changed- compiler/src/dotty/tools/dotc
- core
- transform
- tests/pos
4 files changed
+53
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1410 | 1410 | | |
1411 | 1411 | | |
1412 | 1412 | | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
1413 | 1440 | | |
1414 | 1441 | | |
1415 | 1442 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
227 | | - | |
228 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
521 | 521 | | |
522 | 522 | | |
523 | 523 | | |
524 | | - | |
| 524 | + | |
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
| |||
563 | 563 | | |
564 | 564 | | |
565 | 565 | | |
566 | | - | |
| 566 | + | |
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments