Type parameters via intersection types crash the compiler
See original GitHub issueApparently the syntax class Cont[type A]
has been removed. So I wrote this:
class Cont[A0](val x: A0) { type A = A0 }
val c: Cont[_] & { type A = Int } = new Cont(1)
c.x : Int
It fails to compile with “found: c.A0(c.x); required: Int
”.
So I tried this:
class Cont[A0](x0: A0) { type A = A0; val x: A = x0 }
But the compiler crashes with:
assertion failure for (Cont[_] & Object{A = Int})(c) <:< ?{ x: ? }, frozen = false
[info]
[info] (Cont[_] & Object{A = Int})(c) is a class dotty.tools.dotc.core.Types$TermRefWithFixedSym
[info]
[info] ?{ x: ? } is a class dotty.tools.dotc.typer.ProtoTypes$CachedSelectionProto
[info]
[info] exception occurred while typechecking src/main/scala/Main.scala
[info]
[info] exception occurred while compiling src/main/scala/Main.scala
java.lang.AssertionError: NoDenotation.owner
at dotty.tools.dotc.core.SymDenotations$NoDenotation.owner(SymDenotations.scala:1816)
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
JDK-6738538 javac crashes when using a type parameter as ...
JDK-6738538 : javac crashes when using a type parameter as a covariant method return type ... JDK-6718388 - 4.9: Specify subtyping of intersection...
Read more >Why can I create impossible intersection types in Typescript?
It is possible to intersect primitive types (e.g. string & number ), but it is not possible to actually create values of such...
Read more >Discussion: Union and Intersection types #399 - GitHub
In Typescript, just like JavaScript, types are mostly dictionaries of string keys and members of different types as values. So, the union or...
Read more >Documentation - Everyday Types - TypeScript
It might be confusing that a union of types appears to have the intersection of those types' properties. This is not an accident...
Read more >spf_development_guide_final.pdf
Estimation of SPFs for Different Crash Types and Severities . ... The first step is to select the appropriate SPF for this roadway...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In theory I’d expect them to be equivalent yeah, in practice though, who knows ¯\_(ツ)_/¯
Ok. I was confused by the output message
exception while typing c.x of class class dotty.tools.dotc.ast.Trees$Select
but now I see it’s raised fromReTyper
.