Open
Description
Compiler version
3.1.0
This feels very much like #13190, except it has a few more moving parts I haven't been able to remove while minimizing it.
Minimized code
// fileA.scala
class DiscordRecord[Obj] extends Selectable
trait DiscordRecordCompanion[AbsStructural[A] <: DiscordRecord[A], Supertypes] {
opaque type R <: AbsStructural[this.type] & Supertypes = AbsStructural[this.type] & Supertypes
}
type ChannelR[Obj] = DiscordRecord[Obj] {
val id: SnowflakeType[Channel]
}
type Channel = Channel.R
object Channel extends DiscordRecordCompanion[ChannelR, Any]
type GuildChannelR[Obj] = ChannelR[Obj] {
val id: SnowflakeType[GuildChannel]
}
type GuildChannel = GuildChannel.R
object GuildChannel extends DiscordRecordCompanion[GuildChannelR, Channel]
type TopLevelGuildChannelR[Obj] = GuildChannelR[Obj] {
val id: SnowflakeType[TopLevelGuildChannel]
}
type TopLevelGuildChannel = TopLevelGuildChannel.R
object TopLevelGuildChannel extends DiscordRecordCompanion[TopLevelGuildChannelR, GuildChannel]
// fileB.scala
trait TC[C]
opaque type SnowflakeType[+A] = Long
object SnowflakeType {
def useSubtype[C <: Channel]: TC[SnowflakeType[C]] = ???
given TC[SnowflakeType[TopLevelGuildChannel]] = useSubtype[TopLevelGuildChannel]
}
val ev = summon[GuildChannel <:< Channel]
//val ev2 = summon[GuildChannel <:< Channel]
Steps to reproduce
- Compile both files together in a project. Everything should compile fine.
- Uncomment
ev2
infileB.scala
- Try to compile again (and not cleaning beforehand). It will error for
ev1
andev2
- Clean and compile. It works again
Output
[error] -- Error: D:\DevProjects\Incubating\AckCordNext\src\main\scala\ackcordnext\data\datamodel\error\SnowflakeType.scala:11:42
[error] 11 |val ev = summon[GuildChannel <:< Channel]
[error] | ^
[error] |Cannot prove that ackcordnext.data.datamodel.error.GuildChannel <:< ackcordnext.data.datamodel.error.Channel.
[error] -- Error: D:\DevProjects\Incubating\AckCordNext\src\main\scala\ackcordnext\data\datamodel\error\SnowflakeType.scala:12:42
[error] 12 |val ev2 = summon[GuildChannel <:< Channel]
[error] | ^
[error] |Cannot prove that ackcordnext.data.datamodel.error.GuildChannel <:< ackcordnext.data.datamodel.error.Channel.
Expectation
It should compile in both cases, also when using incremental compilation.