question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type parameters via intersection types crash the compiler

See original GitHub issue

Apparently 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:closed
  • Created 6 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
smartercommented, Jul 12, 2017

In theory I’d expect them to be equivalent yeah, in practice though, who knows ¯\_(ツ)_/¯

0reactions
LPTKcommented, Jul 14, 2017

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 from ReTyper.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found