Skip to content

ShortcutImplicits conflicts with RefChecks #4753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
allanrenucci opened this issue Jul 2, 2018 · 1 comment
Closed

ShortcutImplicits conflicts with RefChecks #4753

allanrenucci opened this issue Jul 2, 2018 · 1 comment

Comments

@allanrenucci
Copy link
Contributor

allanrenucci commented Jul 2, 2018

class A

trait Foo {
  def foo: implicit A => Int
}

class Test {
  new FooI{}
}

class FooI extends Foo {
  def foo: implicit A => Int = 3
}

fails to compile:

> dotc Test.scala
-- Error: tests/allan/Test.scala:8:2 -------------------------------------------
8 |  new FooI{}
  |  ^
  |object creation impossible, since def foo$direct(implicit x$0: A): Int is not defined 

The issue is that at the time RefChecks transforms new FooI{}, class FooI hasn't gone through ShortcutImplicits which creates the member def foo$direct(implicit x$0: A): Int but trait Foo has

@allanrenucci
Copy link
Contributor Author

Reopening as ShortcutImplicits still conflicts with RefChecks.

class Foo1 {
  def foo: implicit String => Int = 1
}

class Foo2 extends Foo1 {
  override def foo: implicit String => Int = 2
}
> dotc -d out tests/allan/Test.scala
-- Error: tests/allan/Test.scala:6:15 ------------------------------------------
6 |  override def foo: implicit String => Int = 2
  |               ^
  |error overriding method foo$direct in class Foo1 of type (implicit x$0: String): Int;
  |  method foo$direct of type (implicit x$0: String): Int needs `override' modifier
one error found

@allanrenucci allanrenucci reopened this Jul 13, 2018
@liufengyun liufengyun assigned liufengyun and unassigned odersky Jul 13, 2018
liufengyun added a commit to dotty-staging/dotty that referenced this issue Jul 13, 2018
…empty

It is the case if the overriden symbol is in the same compilation unit.
allanrenucci added a commit that referenced this issue Jul 17, 2018
Fix #4753: Direct method should keep `Override` if overriden nonempty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants