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

type mismatch in ValDef with inferred existential type

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.10.0
    • Component/s: Misc Compiler
    • Labels:
      None

      Description

      scala> val c = { class C; new C { def foo = 1 } }
      <console>:5: error: type mismatch;
       found   : $$anon(in value c) where type $$anon(in value c) <: C{def foo: Int}
       required: $$anon(in value c) forSome { type $$anon(in value c) <: C{def foo: Int}; type C <: java.lang.Object with ScalaObject }
             val c = { class C; new C { def foo = 1 } }
                 ^
      

      or without an anonymous class:

      
      scala> val a = { class B; class C extends B; new C }
      <console>:6: error: type mismatch;
       found   : C(in value a) where type C(in value a) <: B with ScalaObject
       required: C(in value a) forSome { type C(in value a) <: B with ScalaObject; type B <: java.lang.Object with ScalaObject }
             val a = { class B; class C extends B; new C }
                 ^
      

        Activity

        Hide
        Paul Phillips added a comment -

        Closely related to SI-1201.

        Show
        Paul Phillips added a comment - Closely related to SI-1201 .
        Hide
        Adriaan Moors added a comment -

        see also: SI-4110

        Show
        Adriaan Moors added a comment - see also: SI-4110
        Hide
        Adriaan Moors added a comment -

        see also: SI-3960

        Show
        Adriaan Moors added a comment - see also: SI-3960
        Hide
        Seth Tisue added a comment -

        SI-1195, too

        Show
        Seth Tisue added a comment - SI-1195 , too
        Hide
        Seth Tisue added a comment -

        this slight variant also triggers the error. could be part of the test coverage if a fix is found:

        scala> { class A; class B extends A; classOf[B] }
        <console>:7: error: type mismatch;
         found   : java.lang.Class[B(in value res4)] where type B(in value res4) <: A with ScalaObject
         required: java.lang.Class[_ <: A with ScalaObject]
               val res4 =
                   ^
        
        Show
        Seth Tisue added a comment - this slight variant also triggers the error. could be part of the test coverage if a fix is found: scala> { class A; class B extends A; classOf[B] } <console>:7: error: type mismatch; found : java.lang.Class[B(in value res4)] where type B(in value res4) <: A with ScalaObject required: java.lang.Class[_ <: A with ScalaObject] val res4 = ^
        Hide
        Paul Phillips added a comment -
        scala> val c = { class C; new C { def foo = 1 } }
        c: ScalaObject{def foo: Int} = $anon$1@7b26c885
        
        scala> c.foo
        res0: Int = 1
        
        Show
        Paul Phillips added a comment - scala> val c = { class C; new C { def foo = 1 } } c: ScalaObject{def foo: Int} = $anon$1@7b26c885 scala> c.foo res0: Int = 1
        Hide
        Seth Tisue added a comment -

        Paul: is your comment meant to imply this is now fixed? I'm not seeing that it is fixed on trunk, as of r25323.

        Show
        Seth Tisue added a comment - Paul: is your comment meant to imply this is now fixed? I'm not seeing that it is fixed on trunk, as of r25323.
        Hide
        Paul Phillips added a comment -

        Sorry, that was needlessly opaque. It was meant to show that I have fixed it in principle, but I'd have closed it if I was saying it's fixed. That code is not yet checked in.

        Show
        Paul Phillips added a comment - Sorry, that was needlessly opaque. It was meant to show that I have fixed it in principle, but I'd have closed it if I was saying it's fixed. That code is not yet checked in.
        Show
        Simon Ochsenreither added a comment - Closed in https://github.com/scala/scala/commit/c478eb770ddf27de64d55426f0fdd3fd81d11f22

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Lukas Rytz
            TracCC:
            Paul Phillips
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development