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

warn on implicit def without explicit result type #5265

Open
scabug opened this Issue Dec 3, 2011 · 6 comments

Comments

Projects
None yet
3 participants
@scabug
Copy link

scabug commented Dec 3, 2011

The following code snipet : https://gist.github.com/1427587
does not compile.

import java.util.Date

trait TDate 

trait TT[A1,T1]

trait TTFactory[F,G] {
  def create(f: F) : TT[F,G]
  def sample: F
}

object Impls {

  // If the c1 is declared before c2, it compiles fine
  // or if the implicit's result type is specified explicitly
  implicit def c2(s: Date)/* : TT[Date, TDate] */ = c1.create(s)  

  implicit val c1 = new TTFactory[Date,TDate] {
    def create(v: Date): TT[Date,TDate] = sys.error("")
    def sample = new Date
  }
}
@scabug

This comment has been minimized.

Copy link

scabug commented Dec 3, 2011

Imported From: https://issues.scala-lang.org/browse/SI-5265?orig=1
Reporter: maxime.levesque
Affected Versions: 2.9.1
See #5348, #2206, #801

@scabug

This comment has been minimized.

Copy link

scabug commented Jun 11, 2012

@adriaanm said:
see #2206, #801 and a plethora of duplicates

@scabug

This comment has been minimized.

Copy link

scabug commented Jul 3, 2012

@adriaanm said:
warn unless enabled by feature flag

@scabug

This comment has been minimized.

Copy link

scabug commented Jul 10, 2013

@adriaanm said:
Unassigning and rescheduling to M6 as previous deadline was missed.

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 10, 2014

@retronym said:
I have a feeling there actually isn't a cycle in this example. Even if there is, we should report it.

Instead, I think the problem here is that typedBlock can trigger a type completion which causes the typedBlock for the same block to be reentered. Crucially, this happens after the DefTrees in the block have the symbols assigned. In the second run through typedBlock, the namer sees the attributed trees and decides not to enter them in scope.

The presentation compiler has a more robust namer to account for the sort of symptom, as caused by cancellation. I've moved that in to the regular namer in this WIP branch.

https://github.com/retronym/scala/tree/ticket/5265

That said, I definetely agree we should also have a warning / migration for unannotated implicits.

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 10, 2014

@retronym said:
That branch fails on (at least)

// t4716.scala
trait Bug2[ +A] extends TraversableOnce[A] {
  def ++[B >: A](that: TraversableOnce[B]) = {
    lazy val it = that.toIterator
    it
  }
}

I'm going to park this ticket again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment