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.

Cannot abstract over erased classes

See original GitHub issue

Compiler version

3.0.1

Minimized example

import language.experimental.erasedDefinitions

erased class Capability

def f(using Capability): Int = 1
def g[C <: Capability](using C): Int = 1

Output

6 |def g[C <: Capability](using C): Int = 1
  |                             ^
  |illegal reference to erased trait Capability in definition that is not itself erased

Expectation

We should be able to abstract over erased classes.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
arturopalacommented, Aug 31, 2021

Does it work with (using erased C)?

0reactions
oderskycommented, Aug 31, 2021

If the type of a val definition or parameter is a (possibly aliased, refined, or instantiated) erased class, the definition is assumed to be erased itself.

So that does not cover the example, since there C is neither aliased, nor refined nor instantiated. Should it also work? I am not sure about that yet. Maybe better be conservative at first?

If we wanted to generalize it, what would the right rule be? In particular considering that bounds can be unions or intersections?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't override operator delete/new from pure abstract class in ...
I want to override new and delete operators of a class to make it use my memory pool. It works with normal classes...
Read more >
Cannot instantiate abstract class or interface exception
Hi, I am using NHibernate version 2.0.1. I have an User class which has a collection of 'Role'. Role is an abstract class...
Read more >
Incorrect "Creating an instance of the Abstract class is not ...
Hi! Trying to instantiate a derived class, query_dev, whose classdef has not a single occurrence of the word Abstract, I get the complaint...
Read more >
Abstract Classes - Taylorial.com
We can declare references from an abstract class. We cannot create objects from an abstract class. In Java, we can only inherit from...
Read more >
Classes - JavaScript - MDN Web Docs
Classes in JS are built on prototypes but also have some syntax and semantics ... their class and cannot be called through a...
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