Scala Programming Language
  1. Scala Programming Language
  2. SI-5415

reflective typechecker fails for singleton object containing trait

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.10.0-M1
    • Component/s: Reflection
    • Labels:
      None

      Description

      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)
      	[...]
      

        Activity

        Hide
        Eugene Burmako added a comment -

        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
        
        Show
        Eugene Burmako added a comment - 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
        Hide
        Eugene Burmako added a comment -

        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
        
        Show
        Eugene Burmako added a comment - 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
        Show
        Eugene Burmako added a comment - Fixed by https://github.com/scala/scala/commit/363f8af6a8c157485a644d00d75e2df10e71e661

          People

          • Assignee:
            Eugene Burmako
            Reporter:
            Christopher Vogt
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development