Skip to content

Commit c870c97

Browse files
committed
Let only value types derive from Capabilities
Fixes crash with opaque types reported by @natsukagami
1 parent 21bd994 commit c870c97

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/cc/CaptureOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ extension (tp: Type)
272272
val sym = tp.typeSymbol
273273
if sym.isClass then sym.derivesFrom(defn.Caps_Capability)
274274
else tp.superType.derivesFromCapability
275-
case tp: TypeProxy =>
275+
case tp: (TypeProxy & ValueType) =>
276276
tp.superType.derivesFromCapability
277277
case tp: AndType =>
278278
tp.tp1.derivesFromCapability || tp.tp2.derivesFromCapability
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import language.experimental.captureChecking
2+
3+
trait A extends caps.Capability
4+
5+
object O:
6+
opaque type B = A

0 commit comments

Comments
 (0)