Skip to content
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

assertion failed in TreeGen.mkAttributedQualifier #3995

Closed
scabug opened this issue Nov 12, 2010 · 4 comments
Closed

assertion failed in TreeGen.mkAttributedQualifier #3995

scabug opened this issue Nov 12, 2010 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Nov 12, 2010

In Scala 2.8.1.final, the following definition causes the compiler to crash when compiling (new Lift[String])((_: String).length):

class Lift[T] {                                                          
   def apply[R](f: F0[R]): T => R = f.f

   class F0[R](val f: T => R)
   object F0 {
      implicit def f2f0[R](fn: T => R): F0[R] = new F0(fn)
   }
}

.

The session and stack trace:

Welcome to Scala version 2.8.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.

scala> class Lift[T] {                                                          
     |    def apply[R](f: F0[R]): T => R = f.f
     | 
     |    class F0[R](val f: T => R)
     |    object F0 {
     |       implicit def f2f0[R](fn: T => R): F0[R] = new F0(fn)
     |    }
     | }
defined class Lift

scala> (new Lift[String])((_: String).length)
java.lang.AssertionError: assertion failed
        at scala.Predef$$.assert(Predef.scala:77)
        at scala.tools.nsc.ast.TreeGen.mkAttributedQualifier(TreeGen.scala:82)
        at scala.tools.nsc.ast.TreeGen.mkAttributedQualifier(TreeGen.scala:45)
        at scala.tools.nsc.ast.TreeGen.mkAttributedRef(TreeGen.scala:107)
        at scala.tools.nsc.ast.TreeGen.mkAttributedStableRef(TreeGen.scala:149)
        at scala.tools.nsc.ast.TreeGen.mkAttributedQualifier(TreeGen.scala:60)
@scabug
Copy link
Author

@scabug scabug commented Nov 12, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3995?orig=1
Reporter: Aaron Novstrup (anovstrup)
Affected Versions: 2.9.2, 2.10.0-RC5
See #4225

Loading

@scabug
Copy link
Author

@scabug scabug commented Nov 12, 2010

@paulp said:
I was going to say this is fixed in trunk, because it no longer crashes the repl. But while creating a test case to guard it I found it still crashes scalac.

class Lift[T] {                                                          
   def apply[R](f: F0[R]): T => R = f.f

   class F0[R](val f: T => R)
   object F0 {
      implicit def f2f0[R](fn: T => R): F0[R] = new F0(fn)
   }
}

object Test {
  def main(args: Array[String]): Unit = {
    (new Lift[String])((_: String).length)
  }
}

In the repl a type error (and the type error looks right to me):

<console>:8: error: type mismatch;
 found   : (String) => Int
 required: _1.F0[?] where val _1: Lift[String]
           (new Lift[String])((_: String).length)
                                          ^

Same crash outside.

	at scala.tools.nsc.ast.TreeGen.mkAttributedQualifier(TreeGen.scala:82)
	at scala.tools.nsc.ast.TreeGen.mkAttributedQualifier(TreeGen.scala:45)
	at scala.tools.nsc.ast.TreeGen.mkAttributedRef(TreeGen.scala:107)
	at scala.tools.nsc.ast.TreeGen.mkAttributedStableRef(TreeGen.scala:149)
	at scala.tools.nsc.ast.TreeGen.mkAttributedQualifier(TreeGen.scala:60)

Loading

@scabug
Copy link
Author

@scabug scabug commented Dec 4, 2012

@retronym said:
Minimized a little:

class Lift {
  def apply(f: F0) {}

  class F0
  object F0 {
    implicit def f2f0(fn: String): F0 = ???
  }
}

object Test {
  val l = new Lift
  val f = ""

  "": l.FO // okay

  (new Lift).apply("") // fails trying to mkAttributedQualifier for pre = Skolem(_1 <: Lift with Singletom).F0
                       // should this even have shown up in `companionImplicitMap`? It says that:
                       //
                       // "@return For those parts that refer to classes with companion objects that
                       // can be accessed with unambiguous stable prefixes, the implicits infos
                       // which are members of these companion objects."
}

Loading

@scabug
Copy link
Author

@scabug scabug commented Dec 4, 2012

Loading

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

Successfully merging a pull request may close this issue.

None yet
3 participants