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

reflective typechecker fails for singleton object containing trait #5415

Closed
scabug opened this issue Jan 27, 2012 · 4 comments
Closed

reflective typechecker fails for singleton object containing trait #5415

scabug opened this issue Jan 27, 2012 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jan 27, 2012

Reproduce Code:

import scala.reflect.mirror._
import scala.reflect.Code
import scala.tools.nsc.reporters._
import scala.tools.nsc.Settings
import scala.reflect.runtime.Mirror.ToolBox

package scala.collection.slick{
  case class Queryable2[T](){
    def filter( predicate: T => Boolean ) = ???
  }
  object Test2 extends App{
    def typecheck( tree:Tree ) = {
      val reporter = new ConsoleReporter(new Settings)
      val toolbox = new ToolBox(reporter)
      val typed_tree = toolbox.typeCheck(tree)
    }
    val q = Queryable2[CoffeesTable]()
    trait CoffeesTable{
      def sales : Int
    }
    typecheck(Code.lift[Tree]{ q.filter(_.sales > 5) }.tree )
    q.filter(_.sales > 5)
  }
}

Code compiles fine, but fails at runtime during reflective type checking.

Expected result:

Exception in thread "main" scala.NotImplementedError: an implementation is missing
	[...]
	at scala.collection.slick.Test2$delayedInit$body.apply(Bug.scala:22)
	[...]

Actual result:

Exception in thread "main" scala.reflect.internal.Types$TypeError: type mismatch;
 found   : scala.collection.slick.Test2.CoffeesTable => Boolean
 required: scala.collection.slick.Test2#CoffeesTable => Boolean	at 	[...]
	at scala.collection.slick.Test2$delayedInit$body.apply(Bug.scala:21)
	[...]
@scabug
Copy link
Author

scabug commented Jan 27, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5415?orig=1
Reporter: @cvogt

@scabug
Copy link
Author

scabug commented Jan 27, 2012

@xeno-by said:
The bug manifests itself even if the entire thing is in an empty package. Also, enabling -uniqid in settings has provided sort of more accurate error message

scala.reflect.internal.Types$TypeError: type mismatch;
 found   : Test2.CoffeesTable#1915 => Boolean#196
 required: Test2#1910.CoffeesTable#1915 => Boolean#196

@scabug
Copy link
Author

scabug commented Jan 27, 2012

@xeno-by said:
After being upgraded to also print symbol kinds, error message reveals the root of the problem:

 found   : Test2#1909#MC.CoffeesTable#1915#TR => Boolean#196#CLS
 required: Test2#1910#FV.CoffeesTable#1915#TR => Boolean#196#CLS

@scabug
Copy link
Author

scabug commented Feb 3, 2012

@xeno-by said:
Fixed by scala/scala@363f8af

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

2 participants